Function Reference: geodir_publish_payment_listing_form_before_msg

Summary

Add the content on the add listing preview page inside the publish
listings form, before the publish message.

Global Values

$post
(object) (required) The current post object.

Default: None
$wpdb
(object) (required) WordPress Database object.

Default: None

Change Log

Since: 1.0.0

Filters

‘geodir_subscription_methods’ [Line: 1341]

Source Code

function geodir_publish_payment_listing_form_before_msg() {
    global $post, $wpdb;

    $post_type = $post->listing_type;

    $req_package_id = isset($_REQUEST['package_id']) ? (int)$_REQUEST['package_id'] : '';
    $pid = isset($_REQUEST['pid']) ? (int)$_REQUEST['pid'] : '';
    $coupon_code = isset($_REQUEST['coupon_code']) ? sanitize_text_field($_REQUEST['coupon_code']) : '';

    if ($req_package_id != '') {
        $package_price_info = geodir_get_post_package_info($req_package_id);
    } else {
        if (!empty($post) && isset($post->package_id)) {
            $package_price_info = geodir_get_post_package_info($post->package_id);
        }
    }

    $package_id = isset($package_price_info['pid']) ? $package_price_info['pid'] : '';
    $payable_amount = isset($package_price_info['amount']) ? $package_price_info['amount'] : 0;
    $alive_days = isset($package_price_info['days']) ? $package_price_info['days'] : 0;
    $type_title = isset($package_price_info['title']) ? $package_price_info['title'] : '';
    $sub_active = isset($package_price_info['sub_active']) ? $package_price_info['sub_active'] : '';

    $recurring_desc = '';
    $free_trial_desc = '';
    if ( $sub_active ) {
        $sub_units_num_var = $package_price_info['sub_units_num'];
        $sub_units_var = $package_price_info['sub_units'];
        $sub_units_num_times = $package_price_info['sub_units_num_times'];
        $alive_days = geodir_payment_get_units_to_days( $sub_units_num_var, $sub_units_var );
        
        // paypal free trial
        $sub_num_trial_days_var = $package_price_info['sub_num_trial_days'];
        $sub_num_trial_units_var = $package_price_info['sub_num_trial_units'];
        
        $desc_suffix = '';
        if ( $sub_num_trial_days_var > 0 ) {
            $desc_suffix = __( 'Then charged' , 'geodir_payments' );
            $alive_days = geodir_payment_get_units_to_days( $sub_num_trial_days_var, $sub_num_trial_units_var );
            $free_trial_desc = geodir_payment_checkout_free_trial_desc( $sub_num_trial_days_var, $sub_num_trial_units_var );
        }
        
        $recurring_desc = geodir_payment_recurring_pay_desc($sub_units_var, $sub_units_num_var, $sub_units_num_times, $desc_suffix);
    }

    $org_payable_amount = $payable_amount;

    $alive_days = $alive_days == 0 ? UNLIMITED : $alive_days;

    $preview_message = __('This is a preview of your listing and it\'s not updated yet. 
If there is something wrong then "Go Back and Edit" or if you want to update listing then click on "Publish".', 'geodir_payments'); $preview_button_label = __('Publish', 'geodir_payments'); $coupon_code_msg = ''; if ($coupon_code != '') { if (geodir_payment_allow_coupon_usage(array('package_id' => $package_id)) && geodir_is_valid_coupon($post_type, $coupon_code) && geodir_payment_coupon_usage_count_left($coupon_code)) { $payable_amount = geodir_get_payable_amount_with_coupon($payable_amount, $coupon_code); } else { $coupon_code = ''; $coupon_code_msg = '

' . WRONG_COUPON_MSG . '

'; } } $payable_amount_display = geodir_payment_price($payable_amount); if ($recurring_desc !== '' || $free_trial_desc !== '') { $free_trial_desc = '' . $free_trial_desc . ''; $recurring_desc = '' . $recurring_desc . ''; $payable_amount_display .= ' ( ' . trim($free_trial_desc . ' ' . $recurring_desc) . ' )'; } $gd_pay_type = 'new'; if (!$pid > 0 && !$payable_amount > 0) { // new } elseif ($pid > 0 && !$payable_amount > 0) { // update $gd_pay_type = 'update'; $preview_message = __('This is a preview of your listing and it\'s not updated yet.
If there is something wrong then "Go Back and Edit" or if you want to update listing then click on "Update Now".', 'geodir_payments'); $preview_button_label = __('Update Now', 'geodir_payments'); } elseif ($req_package_id > 0 && $payable_amount > 0 && !$pid > 0) { // paid new $preview_message = wp_sprintf(__('This is a preview of your listing and it\'s not published yet.
If there is something wrong then "Go Back and Edit" or if you want to add listing then click on "Confirm Preview & Go to Checkout".
You are going to pay %s & alive days are %s as %s listing.', 'geodir_payments'), $payable_amount_display , $alive_days , $type_title); $preview_button_label = __('Confirm Preview & Go to Checkout', 'geodir_payments'); } elseif ($req_package_id > 0 && $org_payable_amount > 0 && $pid > 0) { // paid update $post_package_id = geodir_get_post_meta($pid, 'package_id', true); if ($post_package_id == $package_id) { // paid renew $gd_pay_type = 'renew'; $preview_message = wp_sprintf(__('This is a preview of your listing and it\'s not updated yet.
If there is something wrong then "Go Back and Edit" or if you want to renew listing then click on "Checkout to Renew Now".
You are going to pay %s & alive days are %s as %s listing.', 'geodir_payments'), $payable_amount_display , $alive_days , $type_title); $preview_button_label = __('Checkout to Renew Now', 'geodir_payments'); } else { // paid upgrade $gd_pay_type = 'upgrade'; $preview_message = wp_sprintf(__('This is a preview of your listing and it\'s not updated yet.
If there is something wrong then "Go Back and Edit" or if you want to upgrade listing then click on "Checkout to Upgrade Now".
You are going to pay %s & alive days are %s as %s listing.', 'geodir_payments'), $payable_amount_display , $alive_days , $type_title); $preview_button_label = __('Checkout to Upgrade Now', 'geodir_payments'); } } /* -------- START LISTING FORM MESSAGE*/ ob_start(); echo $coupon_code_msg; echo '
' . $preview_message . '
'; /* -------- END LISTING FORM MESSAGE*/ /* -------- START LISTING FORM BUTTON*/ ?> '; /* -------- END LISTING FORM BUTTON*/ /* -------- START LISTING GO BACK LINK*/ $post_id = ''; if (isset($post->pid)) { $post_id = (int)$post->pid; } else if ($pid) { $post_id = (int)$pid; } $postlink = get_permalink(geodir_add_listing_page_id()); $postlink = geodir_getlink($postlink, array('pid' => $post_id, 'backandedit' => '1', 'listing_type' => $post_type ), false); if ($req_package_id != '') { $postlink = geodir_getlink($postlink, array('package_id' => $req_package_id), false); } ?>