function vtprd_get_purch_hist_from_session($i) { global $vtprd_rules_set, $vtprd_cart; if (!isset($_SESSION)) { session_start(); header("Cache-Control: no-cache"); header("Pragma: no-cache"); } if (isset($_SESSION['vtprd_rule_purch_hist_' . $i])) { //get the data from the session var, put into rules_set $vtprd_rule_hist_array = unserialize($_SESSION['vtprd_rule_purch_hist_' . $i]); $vtprd_rules_set[$i]->purch_hist_rule_row_qty_total_plus_discounts = $vtprd_rule_hist_array[0]; $vtprd_rules_set[$i]->purch_hist_rule_row_price_total_plus_discounts = $vtprd_rule_hist_array[1]; } else { //get the data from the DB (which puts it into rules_set), and create the session var $vtprd_cart = new VTPRD_Cart(); $vtprd_cart->purchaser_ip_address = $vtprd_info['purchaser_ip_address']; vtprd_get_rule_purchaser_history($i); //get hist based on IP only $vtprd_rule_hist_array = array(); $vtprd_rule_hist_array[] = $vtprd_rules_set[$i]->purch_hist_rule_row_qty_total_plus_discounts; $vtprd_rule_hist_array[] = $vtprd_rules_set[$i]->purch_hist_rule_row_price_total_plus_discounts; $_SESSION['vtprd_rule_purch_hist_' . $i] = serialize($vtprd_rule_hist_array); } }
public function vtprd_manage_shared_rule_tests($i) { global $vtprd_cart, $vtprd_rules_set, $vtprd_rule, $vtprd_info, $vtprd_setup_options; //error_log( print_r( 'vtprd_manage_shared_rule_tests ', true ) ); $rule_is_date_valid = vtprd_rule_date_validity_test($i); if (!$rule_is_date_valid) { $vtprd_rules_set[$i]->rule_status = 'dateInvalid'; //temp chg of rule_status for this execution only $vtprd_rules_set[$i]->rule_processing_status = 'Cart Transaction does not fall within date boundaries set for the rule.'; } //IP is immediately available, check against Lifetime limits // check against all rules if ($vtprd_setup_options['use_lifetime_max_limits'] == 'yes') { //populate rule with purchaser history vtprd_get_rule_purchaser_history($i); $rule_has_reached_lifetime_limit = vtprd_rule_lifetime_validity_test($i); if ($rule_has_reached_lifetime_limit) { $vtprd_rules_set[$i]->rule_status = 'lifetimeMaxInvalid'; //temp chg of rule_status for this execution only $vtprd_rules_set[$i]->rule_processing_status = 'Rule has already reached lifetime max for IP purchases.'; } } //v1.1.0.9 begin - coupon_activated_discount for later use in parent-cart-validation during remove_coupon, as needed // if coupon removed, this promotes the re-run of the discount at the same time. (re-use of session var, similar situation from v1.1.0.8) //don't run if 'no' if ($vtprd_rules_set[$i]->cumulativeCouponPricing == 'no') { //cumulativeCouponNo for later use in parent-cart-validation during add/remove_coupon, as needed // if coupon removed, this promotes the re-run of the discount at the same time. // This session var set to true will cause a re-process of the cart on Cart and checkout pages ONLY if (!isset($_SESSION)) { session_start(); header("Cache-Control: no-cache"); header("Pragma: no-cache"); } $_SESSION['cumulativeCouponNo'] = true; //error_log( print_r( 'set cumulativeCouponNo= true', true ) ); // $coupon_cnt_without_deals_coupon = sizeof($vtprd_info['coupon_codes_array']); //error_log( print_r( 'only_for_this_coupon_name= ' .$vtprd_rules_set[$i]->only_for_this_coupon_name , true ) ); //error_log( print_r( '$coupon_cnt= ' .$coupon_cnt_without_deals_coupon, true ) ); //error_log( print_r( 'coupon_codes_array= ' , true ) ); //error_log( var_export($vtprd_info['coupon_codes_array'], true ) ); $sizeof_coupon_codes_array = sizeof($vtprd_info['coupon_codes_array']); if ($vtprd_rules_set[$i]->only_for_this_coupon_name > ' ' && $sizeof_coupon_codes_array == 1 && in_array($vtprd_rules_set[$i]->only_for_this_coupon_name, $vtprd_info['coupon_codes_array'])) { //activated by coupon and 1coupon found, so all ok $all_good = true; } else { //coupons array is **without** deals coupon if ($sizeof_coupon_codes_array > 0) { $vtprd_rules_set[$i]->rule_status = 'cumulativeCouponPricingNo'; //temp chg of rule_status for this execution only $vtprd_rules_set[$i]->rule_processing_status = 'Coupon presented, rule switch says do not run.'; } } } //v1.1.0.9 end }