function vtprd_pricing_deal_msgs_advanced($atts) { global $vtprd_rules_set, $vtprd_setup_options, $vtprd_info; extract(shortcode_atts(array('group1_type' => 'cart', 'group1_and_or_wholestore_msgs_only' => 'and', 'group1_wholestore_msgs_only' => 'no', 'and_or_group1_to_group2' => 'and', 'group2_rules' => '', 'group2_and_or_roles' => 'and', 'group2_roles' => '', 'and_or_group2_to_group3' => 'and', 'group3_product_category' => '', 'group3_and_or_plugin_category' => 'or', 'group3_plugin_category' => ''), $atts)); //override default value with supplied parameters... vtprd_set_selected_timezone(); $vtprd_rules_set = get_option('vtprd_rules_set'); $output = '<div class="vtprd-advanced-deal-msg-area">'; $msg_counter = 0; //echo 'incoming attributes= ' .$atts. '<br>'; //mwnt $sizeof_rules_set = sizeof($vtprd_rules_set); for ($i = 0; $i < $sizeof_rules_set; $i++) { if ($vtprd_rules_set[$i]->rule_status != 'publish') { continue; } $rule_is_date_valid = vtprd_rule_date_validity_test($i); if (!$rule_is_date_valid) { continue; } if (defined('VTPRD_PRO_DIRNAME') && $vtprd_setup_options['use_lifetime_max_limits'] == 'yes') { //IP is immediately available, check against Lifetime limits $rule_has_reached_lifetime_limit = vtprd_rule_lifetime_validity_test($i, 'shortcode'); if ($rule_has_reached_lifetime_limit) { continue; } } //v1.0.9.3 new skipt test if ($vtprd_rules_set[$i]->discount_product_full_msg == $vtprd_info['default_full_msg']) { //v1.1.0.5 continue; } $status = array('group1_type' => '', 'group1_wholestore_msgs_only' => '', 'group2_rules' => '', 'group2_roles' => '', 'group3_product_category' => '', 'group3_plugin_category' => '', 'group1' => '', 'group2' => '', 'group3' => '', 'total' => ''); //SET Status success/failed for each parameter switch ($group1_type) { case 'cart': if ($vtprd_rules_set[$i]->rule_execution_type == 'display') { $status['group1_type'] = 'failed'; } else { $status['group1_type'] = 'success'; } break; case 'catalog': if ($vtprd_rules_set[$i]->rule_execution_type == 'cart') { $status['group1_type'] = 'failed'; } else { $status['group1_type'] = 'success'; } break; case 'all': $status['group1_type'] = 'success'; break; default: $status['group1_type'] = 'failed'; break; } if ($group1_wholestore_msgs_only == 'yes') { if ($vtprd_rules_set[$i]->inPop == 'wholeStore' || $vtprd_rules_set[$i]->actionPop == 'wholeStore') { $status['group1_wholestore_msgs_only'] = 'success'; } else { $status['group1_wholestore_msgs_only'] = 'failed'; } } else { $status['group1_wholestore_msgs_only'] = 'success'; } if ($group2_roles > ' ') { $userRole = vtprd_get_current_user_role(); //mwn04142014 if ($userRole = 'notLoggedIn') { $userRole_name = 'Not logged in (just visiting)'; } else { $userRole_name = translate_user_role($userRole); } $group2_roles_array = explode(",", $group2_roles); //remove comma separator, make list an array if (in_array($userRole_name, $group2_roles_array)) { $status['group2_roles'] = 'success'; } else { $status['group2_roles'] = 'failed'; } } else { $status['group2_roles'] = 'success'; } if ($group2_rules > ' ') { $group2_rules_array = explode(",", $group2_rules); //remove comma separator, make list an array if (in_array($vtprd_rules_set[$i]->post_id, $group2_rules_array)) { $status['group2_rules'] = 'success'; } else { $status['group2_rules'] = 'failed'; } } else { $status['group2_rules'] = 'success'; } if ($group3_product_category > ' ') { $group3_product_category_array = explode(",", $group3_product_category); //remove comma separator, make list an array if (array_intersect($vtprd_rules_set[$i]->prodcat_in_checked, $group3_product_category_array) || array_intersect($vtprd_rules_set[$i]->prodcat_out_checked, $group3_product_category_array)) { $status['group3_product_category'] = 'success'; } else { $status['group3_product_category'] = 'failed'; } } else { $status['group3_product_category'] = 'success'; } if ($group3_plugin_category > ' ') { $group3_plugin_category_array = explode(",", $group3_plugin_category); //remove comma separator, make list an array if (array_intersect($vtprd_rules_set[$i]->rulecat_in_checked, $group3_plugin_category_array) || array_intersect($vtprd_rules_set[$i]->rulecat_out_checked, $group3_plugin_category_array)) { $status['group3_plugin_category'] = 'success'; } else { $status['group3_plugin_category'] = 'failed'; } } else { $status['group3_plugin_category'] = 'success'; } //Evaluate status settings //evaluate group1 switch ($group1_and_or_wholestore_msgs_only) { case 'and': if ($status['group1_type'] == 'success' && $status['group1_wholestore_msgs_only'] == 'success') { $status['group1'] = 'success'; } else { $status['group1'] = 'failed'; } break; case 'or': if ($status['group1_type'] == 'success' || $status['group1_wholestore_msgs_only'] == 'success') { $status['group1'] = 'success'; } else { $status['group1'] = 'failed'; } break; default: $status['group1'] = 'failed'; break; } //evaluate group2 switch ($group2_and_or_roles) { case 'and': if ($status['group2_rules'] == 'success' && $status['group2_roles'] == 'success') { $status['group2'] = 'success'; } else { $status['group2'] = 'failed'; } break; case 'or': if ($status['group2_rules'] == 'success' || $status['group2_roles'] == 'success') { $status['group2'] = 'success'; } else { $status['group2'] = 'failed'; } break; default: $status['group2'] = 'failed'; break; } //evaluate group3 switch ($group3_and_or_plugin_category) { case 'and': if ($status['group3_product_category'] == 'success' && $status['group3_plugin_category'] == 'success') { $status['group3'] = 'success'; } else { $status['group3'] = 'failed'; } break; case 'or': if ($status['group3_product_category'] == 'success' || $status['group3_plugin_category'] == 'success') { $status['group3'] = 'success'; } else { $status['group3'] = 'failed'; } break; default: $status['group3'] = 'failed'; break; } //evaluate all 3 groups together switch (true) { case $and_or_group1_to_group2 == 'and' && $and_or_group2_to_group3 == 'and': if ($status['group1'] == 'success' && $status['group2'] == 'success' && $status['group3'] == 'success') { $status['total'] = 'success'; } else { $status['total'] = 'failed'; } break; case $and_or_group1_to_group2 == 'and' && $and_or_group2_to_group3 == 'or': if ($status['group1'] == 'success' && $status['group2'] == 'success' || $status['group3'] == 'success') { $status['total'] = 'success'; } else { $status['total'] = 'failed'; } break; case $and_or_group1_to_group2 == 'or' && $and_or_group2_to_group3 == 'and': if (($status['group1'] == 'success' || $status['group2'] == 'success') && $status['group3'] == 'success') { $status['total'] = 'success'; } else { $status['total'] = 'failed'; } break; case $and_or_group1_to_group2 == 'or' && $and_or_group2_to_group3 == 'or': if ($status['group1'] == 'success' || $status['group2'] == 'success' || $status['group3'] == 'success') { $status['total'] = 'success'; } else { $status['total'] = 'failed'; } break; } if ($status['total'] == 'success') { $msg_counter++; $output .= '<span class="vtprd-advanced-deal-msg" id="vtprd-advanced-deal-msg-' . $vtprd_rules_set[$i]->post_id . '">'; $output .= stripslashes($vtprd_rules_set[$i]->discount_product_full_msg); $output .= '</span>'; $output .= '<span class="vtprd-line-skip-with-display-block"></span>'; } } //end 'for' loop if ($msg_counter == 0) { return; } //close owning div $output .= '</div>'; // vtprd_enqueue_front_end_css(); return $output; }
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 }