public function vtprd_maybe_print_widget_discount() { //and print discount info... //error_log( print_r( 'Function begin - vtprd_maybe_print_widget_discount', 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 $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_rules_set, $vtprd_rule, $wpsc_coupons, $vtprd_setup_options; vtprd_debug_options(); //v1.0.5 //error_log( print_r( '$vtprd_cart at maybe_print_widget begin', true ) ); //error_log( var_export($vtprd_cart, true ) ); //v1.0.9.3 begin // NO widget print for inline pricing if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon') { return; } //Open Session Variable, get rules_set and cart if not there.... $data_chain = $this->vtprd_get_data_chain(); //**************** //v1.1.1.2 begin - 1st discountCoupon mini cart display can loose its data chain on auto add - check and rerun discount /* if ( ( ($vtprd_cart == null) || (!isset ($vtprd_cart->cart_items)) ) && ($vtprd_info['ruleset_contains_auto_add_free_product'] == 'yes') ) { */ if ($vtprd_cart == null || !isset($vtprd_cart->cart_items) || sizeof($vtprd_cart->cart_items) == 0) { //re-run the apply_discount $woocommerce_cart_contents = $woocommerce->cart->get_cart(); if (sizeof($woocommerce_cart_contents) > 0) { $this->vtprd_process_discount(); } } //v1.1.1.2 end //**************** //set one-time switch for use in function vtprd_post_purchase_maybe_save_log_info $_SESSION['do_log_function'] = true; /* ************************************************* At this point the global variable contents are gone. session variables are destroyed in parent plugin before post-update processing... load the globals with the session variable contents, so that the data will be available in the globals during post-update processing!!! DATA CHAIN - global to session back to global global to session - in vtprd_process_discount session to global - in vtprd_woo_validate_order + vtprd_post_purchase_maybe_purchase_log access global - in vtprd_post_purchase_maybe_save_log_info ************************************************* */ //************************************************** //Add discount totals into coupon_totals (a positive #) for payment gateway processing and checkout totals processing // $wpsc_cart->coupons_amount has ALREADY been re-computed in apply-rules.php at add to cart time //************************************************** //error_log( print_r( '$vtprd_cart at maybe_print_widget AFTER DATa-chain get', true ) ); //error_log( var_export($vtprd_cart, true ) ); if ($vtprd_cart->yousave_cart_total_amt > 0) { // vtprd_enqueue_front_end_css(); vtprd_print_widget_discount(); } return; }
public function vtprd_maybe_print_widget_discount() { //and print discount info... global $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_rules_set, $vtprd_rule, $wpsc_coupons, $vtprd_setup_options; vtprd_debug_options(); //v1.0.5 //v1.0.9.3 begin // NO widget print for inline pricing if ($vtprd_setup_options['discount_taken_where'] != 'discountCoupon') { return; } //Open Session Variable, get rules_set and cart if not there.... $data_chain = $this->vtprd_get_data_chain(); //set one-time switch for use in function vtprd_post_purchase_maybe_save_log_info $_SESSION['do_log_function'] = true; /* ************************************************* At this point the global variable contents are gone. session variables are destroyed in parent plugin before post-update processing... load the globals with the session variable contents, so that the data will be available in the globals during post-update processing!!! DATA CHAIN - global to session back to global global to session - in vtprd_process_discount session to global - in vtprd_woo_validate_order + vtprd_post_purchase_maybe_purchase_log access global - in vtprd_post_purchase_maybe_save_log_info ************************************************* */ //************************************************** //Add discount totals into coupon_totals (a positive #) for payment gateway processing and checkout totals processing // $wpsc_cart->coupons_amount has ALREADY been re-computed in apply-rules.php at add to cart time //************************************************** /* echo '$woocommerce= <pre>'.print_r($woocommerce, true).'</pre>' ; echo '$vtprd_cart= <pre>'.print_r($vtprd_cart, true).'</pre>' ; echo '$vtprd_rules_set= <pre>'.print_r($vtprd_rules_set, true).'</pre>' ; */ if ($vtprd_cart->yousave_cart_total_amt > 0) { // vtprd_enqueue_front_end_css(); vtprd_print_widget_discount(); } return; }