public function vtprd_post_purchase_maybe_before_thankyou($order_id)
 {
     global $wpdb, $vtprd_rules_set, $vtprd_cart, $vtprd_setup_options;
     //v1.1.0.3 moved below
     /*
     //v1.0.9.1 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon')  {   		
     	return;
     }
     //v1.0.9.1 end      
     */
     vtprd_debug_options();
     //v1.0.5
     $message = '';
     //v1.0.8.0
     $log_Id = $order_id;
     //if there's a discount history, let's find it...
     $vtprd_purchase_log = $wpdb->get_row("SELECT * FROM `" . VTPRD_PURCHASE_LOG . "` WHERE `cart_parent_purchase_log_id`='" . $log_Id . "' LIMIT 1", ARRAY_A);
     //if purchase log, use that info instead of current
     if ($vtprd_purchase_log) {
         $vtprd_cart = unserialize($vtprd_purchase_log['cart_object']);
         $vtprd_rules_set = unserialize($vtprd_purchase_log['ruleset_object']);
     } else {
         return;
     }
     //NO discount found, no msg changes
     //v1.1.0.6 begin
     //if (!($vtprd_cart->yousave_cart_total_amt > 0)) {
     if ($vtprd_cart->yousave_cart_total_amt > 0 || $vtprd_cart->cart_has_zero_price_auto_add_free_item == 'yes') {
         $carry_on = true;
     } else {
         //v1.1.0.6 end
         return;
     }
     //*****************
     //Save LIfetime data
     //*****************
     //v1.0.7.3 begin
     //  moved HERE so that abandoned carts are avoided in lifetime info
     if (defined('VTPRD_PRO_DIRNAME') && $vtprd_setup_options['use_lifetime_max_limits'] == 'yes') {
         vtprd_save_lifetime_purchase_info($log_id);
     }
     //v1.0.7.3 end
     //v1.1.0.3 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon') {
         return;
     }
     //v1.1.1.0.3end
     //get the Discount detail report...
     $discount_reporting = vtprd_thankyou_cart_reporting();
     //overwrite $message old message parts, new info as well...
     //    $message  =  '<br>';
     $message .= $discount_reporting;
     //    $message .=  '<br>';
     echo $message;
     /*
     echo '$message= <pre>'.print_r($message, true).'</pre>' ; 
     echo '$order_info[id]= ' .$order_info->id . '<br>';
     echo '$order_info= <pre>'.print_r($order_info, true).'</pre>' ; 
     	 wp_die( __('<strong>DIED in vtprd_get_product_catalog_price_new.</strong>', 'vtprd'), __('VT Pricing Deals not compatible - WP', 'vtprd'), array('back_link' => true)); 
     */
     return;
 }
 public function vtprd_post_purchase_maybe_before_thankyou($order_id)
 {
     //error_log( print_r(  'Function begin - vtprd_post_purchase_maybe_before_thankyou', true ) );
     //v1.1.1 begin -
     // "do_no_actions" set/unset in function  vtprd_build_product_price_array
     if (!isset($_SESSION)) {
         session_start();
         header("Cache-Control: no-cache");
         header("Pragma: no-cache");
     }
     if (isset($_SESSION['do_no_actions']) && $_SESSION['do_no_actions']) {
         return;
     }
     //v1.1.1 end
     global $wpdb, $vtprd_rules_set, $vtprd_cart, $vtprd_setup_options;
     //v1.1.0.3 moved below
     /*
     //v1.0.9.1 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon')  {   		
     	return;
     }
     //v1.0.9.1 end      
     */
     vtprd_debug_options();
     //v1.0.5
     $message = '';
     //v1.0.8.0
     $log_Id = $order_id;
     //if there's a discount history, let's find it...
     $vtprd_purchase_log = $wpdb->get_row("SELECT * FROM `" . VTPRD_PURCHASE_LOG . "` WHERE `cart_parent_purchase_log_id`='" . $log_Id . "' LIMIT 1", ARRAY_A);
     //if purchase log, use that info instead of current
     if ($vtprd_purchase_log) {
         $vtprd_cart = unserialize($vtprd_purchase_log['cart_object']);
         $vtprd_rules_set = unserialize($vtprd_purchase_log['ruleset_object']);
     } else {
         return;
     }
     //NO discount found, no msg changes
     //v1.1.0.6 begin
     //if (!($vtprd_cart->yousave_cart_total_amt > 0)) {
     if ($vtprd_cart->yousave_cart_total_amt > 0 || $vtprd_cart->cart_has_zero_price_auto_add_free_item == 'yes') {
         $carry_on = true;
     } else {
         //v1.1.0.6 end
         return;
     }
     //*****************
     //Save LIfetime data
     //*****************
     //v1.0.7.3 begin
     //  moved HERE so that abandoned carts are avoided in lifetime info
     if (defined('VTPRD_PRO_DIRNAME') && $vtprd_setup_options['use_lifetime_max_limits'] == 'yes') {
         vtprd_save_lifetime_purchase_info($log_id);
     }
     //v1.0.7.3 end
     //v1.1.0.3 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon') {
         return;
     }
     //v1.1.0.3end
     //get the Discount detail report...
     $discount_reporting = vtprd_thankyou_cart_reporting();
     //overwrite $message old message parts, new info as well...
     //    $message  =  '<br>';
     $message .= $discount_reporting;
     //    $message .=  '<br>';
     echo $message;
     return;
 }
 public function vtprd_post_purchase_maybe_before_thankyou($order_id)
 {
     //error_log( print_r(  'Function begin - vtprd_post_purchase_maybe_before_thankyou', true ) );
     //v1.1.1 begin -
     // "do_no_actions" set/unset in function  vtprd_build_product_price_array
     if (!isset($_SESSION)) {
         session_start();
         header("Cache-Control: no-cache");
         header("Pragma: no-cache");
     }
     if (isset($_SESSION['do_no_actions']) && $_SESSION['do_no_actions']) {
         return;
     }
     //v1.1.1 end
     global $wpdb, $vtprd_rules_set, $vtprd_cart, $vtprd_setup_options;
     //v1.1.0.3 moved below
     /*
     //v1.0.9.1 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon')  {   		
     	return;
     }
     //v1.0.9.1 end      
     */
     vtprd_debug_options();
     //v1.0.5
     $message = '';
     //v1.0.8.0
     $log_Id = $order_id;
     //if there's a discount history, let's find it...
     $vtprd_purchase_log = $wpdb->get_row("SELECT * FROM `" . VTPRD_PURCHASE_LOG . "` WHERE `cart_parent_purchase_log_id`='" . $log_Id . "' LIMIT 1", ARRAY_A);
     //if purchase log, use that info instead of current
     if ($vtprd_purchase_log) {
         $vtprd_cart = unserialize($vtprd_purchase_log['cart_object']);
         $vtprd_rules_set = unserialize($vtprd_purchase_log['ruleset_object']);
     } else {
         return;
     }
     //NO discount found, no msg changes
     //v1.1.0.6 begin
     //if (!($vtprd_cart->yousave_cart_total_amt > 0)) {
     if ($vtprd_cart->yousave_cart_total_amt > 0 || $vtprd_cart->cart_has_zero_price_auto_add_free_item == 'yes') {
         $carry_on = true;
     } else {
         //v1.1.0.6 end
         return;
     }
     //*****************
     //Save LIfetime data
     //*****************
     //v1.0.7.3 begin
     //  moved HERE so that abandoned carts are avoided in lifetime info
     //testtesttest
     global $vtprd_rules_set;
     //error_log( print_r(  'RULESET Just Before vtprd_save_lifetime_purchase_info, $log_id= ' .$log_id, true ) );
     //error_log( var_export($vtprd_rules_set, true ) );
     if (defined('VTPRD_PRO_DIRNAME') && $vtprd_setup_options['use_lifetime_max_limits'] == 'yes') {
         vtprd_save_lifetime_purchase_info($log_id);
     }
     //v1.0.7.3 end
     //error_log( print_r(  'vtprd_post_purchase_maybe_before_thankyou - 005 ', true ) );
     //v1.1.0.3 begin
     if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon') {
         //error_log( print_r(  'vtprd_post_purchase_maybe_before_thankyou - 006 ', true ) );
         //v1.1.1.3 begin
         // ALL DONE
         //Clear out everything Salient  (so that LIfetime discount limits are cleared...)
         //these resets allow the NEXT add to cart to launch vtprd_process_discount OUT OF vtprd_maybe_before_calculate_totals
         if (isset($_SESSION['data_chain'])) {
             $contents = $_SESSION['data_chain'];
             unset($_SESSION['data_chain'], $contents);
         }
         //clean out temp storage on RULESET!
         global $vtprd_rules_set;
         $vtprd_rules_set = get_option('vtprd_rules_set');
         $vtprd_cart = null;
         //error_log( print_r(  'CLEAN OUT AT END COMPLETED 1' , true ) );
         //v1.1.1.3 end
         //error_log( print_r(  'vtprd_post_purchase_maybe_before_thankyou - 007 ', true ) );
         return;
     }
     //v1.1.0.3end
     //error_log( print_r(  'vtprd_post_purchase_maybe_before_thankyou - 008 ', true ) );
     //get the Discount detail report...
     $discount_reporting = vtprd_thankyou_cart_reporting();
     //overwrite $message old message parts, new info as well...
     //    $message  =  '<br>';
     $message .= $discount_reporting;
     //    $message .=  '<br>';
     echo $message;
     //v1.1.1.3 begin
     // ALL DONE
     //Clear out everything Salient  (so that LIfetime discount limits are cleared...)
     //these resets allow the NEXT add to cart to launch vtprd_process_discount OUT OF vtprd_maybe_before_calculate_totals
     if (isset($_SESSION['data_chain'])) {
         $contents = $_SESSION['data_chain'];
         unset($_SESSION['data_chain'], $contents);
     }
     //clean out temp storage on RULESET!
     global $vtprd_rules_set;
     $vtprd_rules_set = get_option('vtprd_rules_set');
     $vtprd_cart = null;
     //error_log( print_r(  'CLEAN OUT AT END COMPLETED 2' , true ) );
     //v1.1.1.3 end
     return;
 }