VTMIN_Apply_Rules

The VarkTech Minimum Purchase for WooCommerce VTMIN Apply Rules class.

Defined (1)

The class is defined in the following location(s).

/core/vtmin-apply-rules.php  
  1. class VTMIN_Apply_Rules{ 
  2. /** ********************************************** ********************************************** 
  3. TAKE THIS FROM PRO AFTER ALL CHANGES HAVE BEEN DONE!!!!!!!!!!!! 
  4. *********************************************************************************************/  
  5. public function __construct() { 
  6. global $vtmin_cart, $vtmin_rules_set, $vtmin_rule; 
  7. //get pre-formatted rules from options field 
  8.  
  9. $vtmin_rules_set = get_option( 'vtmin_rules_set' ); 
  10.  
  11.  
  12. // create a new vtmin_cart intermediary area, load with parent cart values. results in global $vtmin_cart. 
  13. vtmin_load_vtmin_cart_for_processing();  
  14.  
  15. $this->vtmin_minimum_purchase_check(); 
  16.  
  17.  
  18. public function vtmin_minimum_purchase_check() {  
  19. global $post, $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info; 
  20.  
  21.  
  22. //************************************************ 
  23. //BEGIN processing to mark product as participating in the rule or not... 
  24. //************************************************ 
  25.  
  26. /** Analyze each rule, and load up any cart products found into the relevant rule 
  27. fill rule array with product cart data :: load inpop info  
  28. */  
  29. $sizeof_vtmin_rules_set = sizeof($vtmin_rules_set); 
  30. $sizeof_cart_items = sizeof($vtmin_cart->cart_items); 
  31.  
  32. for($i=0; $i < $sizeof_vtmin_rules_set; $i++) {  
  33. if ( $vtmin_rules_set[$i]->rule_status == 'publish' ) {  
  34. for($k=0; $k < $sizeof_cart_items; $k++) {  
  35. switch( $vtmin_rules_set[$i]->inpop_selection ) {  
  36. case 'groups': 
  37. //test if product belongs in rule inpop 
  38. if ( $this->vtmin_product_is_in_inpop_group($i, $k) ) { 
  39. $this->vtmin_load_inpop_found_list($i, $k);  
  40. break; 
  41. }  
  42.  
  43. }  
  44. }  
  45. } //end inpop population processing 
  46.  
  47.  
  48. //************************************************ 
  49. //BEGIN processing to mark rules as requiring action y/n 
  50. //************************************************ 
  51.  
  52. /** Analyze each Rule population, and see if they satisfy the rule 
  53. * identify and label each rule as requiring action = yes/no 
  54. */ 
  55. for($i=0; $i < $sizeof_vtmin_rules_set; $i++) {  
  56. if ( $vtmin_rules_set[$i]->rule_status == 'publish' ) {  
  57.  
  58. if ( sizeof($vtmin_rules_set[$i]->inpop_found_list) == 0 ) { 
  59. $vtmin_rules_set[$i]->rule_requires_cart_action = 'no'; // cut out unnecessary logic... 
  60. } else { 
  61.  
  62. $vtmin_rules_set[$i]->rule_requires_cart_action = 'pending'; 
  63. $sizeof_inpop_found_list = sizeof($vtmin_rules_set[$i]->inpop_found_list); 
  64. /** 
  65. AS only one product can be found with 'single', override to 'all' speeds things along 
  66. */ 
  67. if ($vtmin_rules_set[$i]->inpop_selection == 'single') { 
  68. $vtmin_rules_set[$i]->specChoice_in_selection = 'all' ;  
  69.  
  70.  
  71.  
  72. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  73. case 'all': //$specChoice_value = 'all' => total up everything in the population as a unit  
  74. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { //price total 
  75. if ($vtmin_rules_set[$i]->inpop_total_price >= $vtmin_rules_set[$i]->minimum_amt['value']) {  
  76. $vtmin_rules_set[$i]->rule_requires_cart_action = 'no'; 
  77. } else { 
  78. $vtmin_rules_set[$i]->rule_requires_cart_action = 'yes'; 
  79. } else { //qty total 
  80. if ($vtmin_rules_set[$i]->inpop_qty_total >= $vtmin_rules_set[$i]->minimum_amt['value']) { 
  81. $vtmin_rules_set[$i]->rule_requires_cart_action = 'no'; 
  82. } else { 
  83. $vtmin_rules_set[$i]->rule_requires_cart_action = 'yes'; 
  84. }  
  85.  
  86. //v1.09.7 begin 
  87. if ( ( $vtmin_rules_set[$i]->repeatingGroups > 0 ) && 
  88. ( ($vtmin_rules_set[$i]->inpop_qty_total % $vtmin_rules_set[$i]->repeatingGroups) > 0) ) { //if remainder > 0 
  89. $vtmin_rules_set[$i]->rule_requires_cart_action = 'yes'; 
  90. //v1.09.7 end 
  91.  
  92. if ($vtmin_rules_set[$i]->rule_requires_cart_action == 'yes') { 
  93. for($k=0; $k < $sizeof_inpop_found_list; $k++) { 
  94. $this->vtmin_mark_product_as_requiring_cart_action($i, $k);  
  95. }  
  96. break; 
  97. case 'each': //$specChoice_value = 'each' => apply the rule to each product individually across all products found  
  98. for($k=0; $k < $sizeof_inpop_found_list; $k++) { 
  99. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { //price total 
  100. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_total_price'] >= $vtmin_rules_set[$i]->minimum_amt['value']) { 
  101. //$vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  102.  
  103. //v1.09.7 begin 
  104. if ( ( $vtmin_rules_set[$i]->repeatingGroups > 0 ) && 
  105. ( ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] % $vtmin_rules_set[$i]->repeatingGroups) > 0) ) {  
  106. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  107. } else { 
  108. $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  109. //v1.09.7 end 
  110.  
  111. } else { 
  112. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  113. } else { 
  114. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] >= $vtmin_rules_set[$i]->minimum_amt['value']) { 
  115. // $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  116.  
  117. //v1.09.7 begin 
  118. if ( ( $vtmin_rules_set[$i]->repeatingGroups > 0 ) && 
  119. ( ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] % $vtmin_rules_set[$i]->repeatingGroups) > 0) ) {  
  120. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  121. } else { 
  122. $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  123. //v1.09.7 end 
  124.  
  125. } else { 
  126. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  127.  
  128.  
  129. break; 
  130. case 'any': //$specChoice_value = 'any' => "You must buy a minimum of $10 for each of any of 2 products from this group."  
  131. //Version 1.01 completely replaced the original case logic 
  132. $any_action_cnt = 0; 
  133. for($k=0; $k < $sizeof_inpop_found_list; $k++) { 
  134. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { //price total 
  135. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_total_price'] < $vtmin_rules_set[$i]->minimum['value']) { 
  136. //$vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  137.  
  138. //v1.09.7 begin 
  139. if ( ( $vtmin_rules_set[$i]->repeatingGroups > 0 ) && 
  140. ( ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] % $vtmin_rules_set[$i]->repeatingGroups) > 0) ) {  
  141. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  142. $any_action_cnt++; 
  143. } else { 
  144. $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  145. //v1.09.7 end 
  146.  
  147. } else { 
  148. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  149. $any_action_cnt++; 
  150. } else { 
  151. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] < $vtmin_rules_set[$i]->minimum['value']) { 
  152. //$vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  153.  
  154. //v1.09.7 begin 
  155. if ( ( $vtmin_rules_set[$i]->repeatingGroups > 0 ) && 
  156. ( ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty'] % $vtmin_rules_set[$i]->repeatingGroups) > 0) ) {  
  157. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  158. $any_action_cnt++; 
  159. } else { 
  160. $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'no'; 
  161. //v1.09.7 end 
  162.  
  163. } else { 
  164. $this->vtmin_mark_product_as_requiring_cart_action($i, $k); 
  165. $any_action_cnt++; 
  166.  
  167. //if 'any' limit reached, end the loop, don't mark any mor products as requiring cart action 
  168. if ($any_action_cnt >= $vtmin_rules_set[$i]->anyChoice_max['value']) { 
  169. $k = $sizeof_inpop_found_list;  
  170. }  
  171. break; 
  172. }  
  173. }  
  174.  
  175. //**************************************************************************** 
  176. // IF WE DON'T DO "apply multiple rules to product", rollout the multples  
  177. //**************************************************************************** 
  178. if ($vtmin_setup_options[apply_multiple_rules_to_product] == 'no' ) { 
  179. $sizeof_cart_items = sizeof($vtmin_cart->cart_items); 
  180. for($k=0; $k < $sizeof_cart_items; $k++) { //$k = 'cart item' 
  181. if ( sizeof($vtmin_cart->cart_items[$k]->product_participates_in_rule) > 1 ) {  
  182. //***************************** 
  183. //remove product from **2ND** TO NTH rule, roll quantity and price out of totals for that rule 
  184. //*****************************  
  185. for($r=1; $r < sizeof($vtmin_cart->cart_items[$k]->product_participates_in_rule); $r++) { //$r = 'in rule' 
  186. //disambiguation does not apply to products belonging to a varkgroup rule 
  187. if (!$vtmin_cart->cart_items[$k]->product_participates_in_rule[$r]['inpop_selection'] == 'vargroup') { //does not apply to vargroups!! 
  188. //use stored occurrences to establish addressability to this rule's info... 
  189. $rulesetLoc = $vtmin_cart->cart_items[$k]->product_participates_in_rule[$r]['ruleset_occurrence']; 
  190. $inpopLoc = $vtmin_cart->cart_items[$k]->product_participates_in_rule[$r]['inpop_occurrence']; 
  191. //roll the product out of the rule totals, mark as 'no action required' for that rule!  
  192. $vtmin_rules_set[$rulesetLoc]->inpop_qty_total -= $vtmin_rules_set[$rulesetLoc]->inpop_found_list[$inpopLoc]['prod_qty']; 
  193. $vtmin_rules_set[$rulesetLoc]->inpop_total_price -= $vtmin_rules_set[$rulesetLoc]->inpop_found_list[$inpopLoc]['prod_total_price']; 
  194. $vtmin_rules_set[$rulesetLoc]->inpop_found_list[$inpopLoc]['prod_requires_action'] = 'no'; 
  195. //if action amounts are 0, turn off action status for rule 
  196. if ( ($vtmin_rules_set[$rulesetLoc]->inpop_qty_total == 0) && ($vtmin_rules_set[$rulesetLoc]->inpop_total_price == 0) ) { 
  197. $vtmin_rules_set[$rulesetLoc]->rule_requires_cart_action = 'no';  
  198. unset ( $vtmin_cart->cart_items[$k]->product_participates_in_rule[$r] );//this array is used later in printing errors in table form  
  199. }  
  200. }  
  201.  
  202.  
  203.  
  204.  
  205. //************************************************ 
  206. //BEGIN processing to produce error messages 
  207. //************************************************ 
  208. /** 
  209. * For those rules whose product population has failed the rules test,  
  210. * document the rule failure in an error message 
  211. * and ***** place the error message into the vtmin cart ***** 
  212. *  
  213. * All of the inpop_found info placed into the rules array during the apply-rules process 
  214. * is only temporary. None of that info is stored on the rules array on a  
  215. * more permanent basis. Once the error messages are displayed, they too are discarded 
  216. * from the rules array (by simply not updating the array on the options table).  
  217. * The errors are available to the rules_ui on the error-display go-round because  
  218. * the info is held in the global namespace.  
  219. */ 
  220. $vtmin_info['error_message_needed'] = 'no'; 
  221. for($i=0; $i < $sizeof_vtmin_rules_set; $i++) {  
  222. if ( $vtmin_rules_set[$i]->rule_status == 'publish' ) {  
  223. switch( true ) {  
  224. case ($vtmin_rules_set[$i]->rule_requires_cart_action == 'no'): 
  225. //no error message for this rule, go to next in loop 
  226. break;  
  227.  
  228. case ( ($vtmin_rules_set[$i]->rule_requires_cart_action == 'yes') || ($vtmin_rules_set[$i]->rule_requires_cart_action == 'pending') ): 
  229.  
  230. //************************************************ 
  231. //Create Error Messages for single or group  
  232. //************************************************ 
  233.  
  234. //errmsg pre-processing 
  235. $this->vtmin_init_recursive_work_elements($i);  
  236.  
  237. switch( $vtmin_rules_set[$i]->inpop_selection ) { 
  238. case 'single':  
  239. $vtmin_rules_set[$i]->errProds_total_price = $vtmin_rules_set[$i]->inpop_total_price; 
  240. $vtmin_rules_set[$i]->errProds_qty = $vtmin_rules_set[$i]->inpop_qty_total; 
  241. $vtmin_rules_set[$i]->errProds_ids [] = $vtmin_rules_set[$i]->inpop_found_list[0]['prod_id']; 
  242. $vtmin_rules_set[$i]->errProds_names [] = $vtmin_rules_set[$i]->inpop_found_list[0]['prod_name']; 
  243. $this->vtmin_create_text_error_message($i); 
  244. break; //Error Message Processing *Complete* for this Rule 
  245.  
  246. default: // 'groups' or 'cart' or 'vargroup'  
  247.  
  248. if ( $vtmin_rules_set[$i]->inpop_selection == 'groups' ) { 
  249.  
  250. //BEGIN Get Category Names for rule (groups only) 
  251. $this->vtmin_init_cat_work_elements($i);  
  252.  
  253. if ( ( sizeof($vtmin_rules_set[$i]->prodcat_in_checked) > 0 ) && ($vtmin_setup_options['show_prodcat_names_in_errmsg'] == 'yes' ) ) {  
  254. foreach ($vtmin_rules_set[$i]->prodcat_in_checked as $cat_id) {  
  255. $cat_info = get_term_by('id', $cat_id, $vtmin_info['parent_plugin_taxonomy'] ) ; 
  256. If ($cat_info) { 
  257. $vtmin_rules_set[$i]->errProds_cat_names [] = $cat_info->name; 
  258. }  
  259. if ( ( sizeof($vtmin_rules_set[$i]->rulecat_in_checked) > 0 ) && ($vtmin_setup_options['show_rulecat_names_in_errmsg'] == 'yes' ) ) {  
  260. foreach ($vtmin_rules_set[$i]->rulecat_in_checked as $cat_id) {  
  261. $cat_info = get_term_by('id', $cat_id, $vtmin_info['rulecat_taxonomy'] ) ; 
  262. If ($cat_info) { 
  263. $vtmin_rules_set[$i]->errProds_cat_names [] = $cat_info->name; 
  264. }  
  265. //End Category Name Processing (groups only) 
  266. }  
  267.  
  268. //PROCESS all ERROR products 
  269. for($k=0; $k < sizeof($vtmin_rules_set[$i]->inpop_found_list); $k++) { 
  270. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] == 'yes') { 
  271. //aggregate totals and add name into list 
  272. $vtmin_rules_set[$i]->errProds_qty += $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_qty']; 
  273. $vtmin_rules_set[$i]->errProds_total_price += $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_total_price']; 
  274. $vtmin_rules_set[$i]->errProds_ids [] = $vtmin_rules_set[$i]->inpop_found_list[0]['prod_id']; 
  275. $vtmin_rules_set[$i]->errProds_names [] = $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_name']; 
  276.  
  277.  
  278. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  279. case 'all': 
  280. //Don't create a message now, message applies to the whole population, wait until 'for' loop completes to print 
  281. break; 
  282. default: // 'each' and 'any' 
  283. //message applies to each product as setup in previous processing 
  284. $this->vtmin_create_text_error_message($i);  
  285. //clear out errProds work elements 
  286. $this->vtmin_init_recursive_work_elements($i);  
  287. break; 
  288. }  
  289.  
  290. if ( $vtmin_rules_set[$i]->specChoice_in_selection == 'all' ) { 
  291. $this->vtmin_create_text_error_message($i); 
  292. }  
  293. break;  
  294. } //end messaging 
  295.  
  296. break;  
  297. } //end proccessing for this rule 
  298.  
  299.  
  300. }  
  301. } //end rule processing 
  302.  
  303.  
  304. //Show error messages in table format, if desired and needed. 
  305. if ( ( $vtmin_setup_options['show_error_messages_in_table_form'] == 'yes' ) && ($vtmin_info['error_message_needed'] == 'yes') ) { 
  306. $this->vtmin_create_table_error_message(); 
  307.  
  308. if ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) {  
  309. global $woocommerce;  
  310. error_log( print_r( '$vtmin_info', true ) ); 
  311. error_log( var_export($vtmin_info, true ) ); 
  312. error_log( print_r( '$vtmin_rules_set', true ) ); 
  313. error_log( var_export($vtmin_rules_set, true ) ); 
  314. error_log( print_r( '$vtmin_cart', true ) ); 
  315. error_log( var_export($vtmin_cart, true ) ); 
  316. error_log( print_r( '$vtmin_setup_options', true ) ); 
  317. error_log( var_export($vtmin_setup_options, true ) ); 
  318. error_log( print_r( '$woocommerce', true ) ); 
  319. error_log( var_export($woocommerce, true ) );  
  320. }  
  321.  
  322.  
  323. } //end vtmin_minimum_purchase_check 
  324.  
  325.  
  326.  
  327. public function vtmin_create_table_error_message () {  
  328. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info;  
  329. $vtmin_info['line_cnt']++; //line count used in producing height parameter when messages sent to js. 
  330.  
  331. $vtmin_info['cart_color_cnt'] = 0; 
  332.  
  333. $rule_id_list = ' '; 
  334.  
  335. $cart_count = sizeof($vtmin_cart->cart_items); 
  336.  
  337. $message = __('<span id="table-error-messages">', 'vtmin'); 
  338.  
  339. for($i=0; $i < sizeof($vtmin_rules_set); $i++) {  
  340. if ( $vtmin_rules_set[$i]->rule_requires_cart_action == 'yes' ) {  
  341. //v1.08 begin 
  342. if ( $vtmin_rules_set[$i]->custMsg_text > ' ') { //custom msg override  
  343. /** 
  344. ==>> text error msg function always executed, so msg already loaded there - don't load here 
  345. $vtmin_cart->error_messages[] = array ( 
  346. 'msg_from_this_rule_id' => $vtmin_rules_set[$i]->post_id,  
  347. 'msg_from_this_rule_occurrence' => $i,  
  348. 'msg_text' => $vtmin_rules_set[$i]->custMsg_text,  
  349. 'msg_is_custom' => 'yes'  
  350. ); 
  351. $this->vtmin_set_custom_msgs_status ('customMsg'); 
  352. */ 
  353. continue; 
  354. }  
  355. //v1.08 end  
  356. switch ( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  357. case 'all' : 
  358. $vtmin_info['action_cnt'] = 0; 
  359. for($k=0; $k < sizeof($vtmin_rules_set[$i]->inpop_found_list); $k++) {  
  360. if ($vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] == 'yes') { 
  361. $vtmin_info['action_cnt']++; 
  362. switch (true) { 
  363. case ( ( $vtmin_rules_set[$i]->inpop_selection == ('cart' || 'groups' || 'vargroup') ) && ( $vtmin_info['action_cnt'] > 1 ) ) :  
  364. //this rule = whole cart  
  365. $vtmin_info['bold_the_error_amt_on_detail_line'] = 'no'; 
  366. $message .= $this->vtmin_table_detail_lines_cntl($i);  
  367. $message .= $this->vtmin_table_totals_line($i); 
  368. $message .= $this->vtmin_table_text_line($i); 
  369. break; 
  370.  
  371. case $vtmin_info['action_cnt'] == 1 : 
  372. $vtmin_info['bold_the_error_amt_on_detail_line'] = 'yes'; 
  373. $message .= $this->vtmin_table_detail_lines_cntl($i); 
  374. $message .= $this->vtmin_table_text_line($i); 
  375. break; 
  376. }  
  377. break; 
  378. case 'each' : 
  379. $vtmin_info['bold_the_error_amt_on_detail_line'] = 'yes'; 
  380. $message .= $this->vtmin_table_detail_lines_cntl($i); 
  381. $message .= $this->vtmin_table_text_line($i); 
  382. break; 
  383. case 'any' : 
  384. $vtmin_info['bold_the_error_amt_on_detail_line'] = 'yes'; 
  385. $message .= $this->vtmin_table_detail_lines_cntl($i); 
  386. $message .= $this->vtmin_table_text_line($i); 
  387. break; 
  388.  
  389. }  
  390. $message .= __('<br /><br />', 'vtmin'); //empty line between groups 
  391.  
  392. //new color for next rule 
  393. $vtmin_info['cart_color_cnt']++;  
  394. }  
  395.  
  396. //close up owning span 
  397. $message .= __('</span>', 'vtmin'); //end "table-error-messages" 
  398.  
  399. $vtmin_cart->error_messages[] = array ( 
  400. 'msg_from_this_rule_id' => $rule_id_list,  
  401. 'msg_from_this_rule_occurrence' => '',  
  402. 'msg_text' => $message,  
  403. 'msg_is_custom' => 'no' //v1.08  
  404. );  
  405. $this->vtmin_set_custom_msgs_status ('standardMsg'); //v1.08  
  406. }  
  407.  
  408.  
  409. public function vtmin_table_detail_lines_cntl ($i) { 
  410. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info; 
  411.  
  412. $message_details = $this->vtmin_table_titles(); 
  413.  
  414. //Version 1.01 new IF structure replaced straight 'for' loop 
  415. if ( $vtmin_rules_set[$i]->specChoice_in_selection == 'all' ) { 
  416. for($r=0; $r < sizeof($vtmin_rules_set[$i]->inpop_found_list); $r++) {  
  417. $k = $vtmin_rules_set[$i]->inpop_found_list[$r]['prod_id_cart_occurrence']; 
  418. $message_details .= $this->vtmin_table_line ($i, $k);  
  419. } else { // each or any 
  420. for($r=0; $r < sizeof($vtmin_rules_set[$i]->inpop_found_list); $r++) {  
  421. if ($vtmin_rules_set[$i]->inpop_found_list[$r]['prod_requires_action'] == 'yes') { 
  422. $k = $vtmin_rules_set[$i]->inpop_found_list[$r]['prod_id_cart_occurrence']; 
  423. $message_details .= $this->vtmin_table_line ($i, $k); 
  424. }  
  425.  
  426. return $message_details; 
  427.  
  428. public function vtmin_table_line ($i, $k) { 
  429. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info; 
  430.  
  431.  
  432. $message_line; 
  433. $vtmin_info['line_cnt']++; 
  434.  
  435. $message_line .= __('<span class="table-msg-line">', 'vtmin'); 
  436. $message_line .= __('<span class="product-column product color-grp', 'vtmin'); 
  437. $message_line .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  438. $message_line .= __('">', 'vtmin'); 
  439. $message_line .= $vtmin_cart->cart_items[$k]->product_name; 
  440. $message_line .= __('</span>', 'vtmin'); //end "product" end "color-grp" 
  441.  
  442. if ($vtmin_rules_set[$i]->amtSelected_selection == 'quantity') { 
  443. $message_line .= __('<span class="quantity-column color-grp', 'vtmin'); 
  444. $message_line .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  445. if ( $vtmin_info['bold_the_error_amt_on_detail_line'] == 'yes') { 
  446. $message_line .= __(' bold-this', 'vtmin'); 
  447. $message_line .= __('">', 'vtmin'); 
  448. } else { 
  449. $message_line .= __('<span class="quantity-column">', 'vtmin');  
  450. $message_line .= $vtmin_cart->cart_items[$k]->quantity; 
  451. if ( ($vtmin_rules_set[$i]->amtSelected_selection == 'quantity') && ($vtmin_info['bold_the_error_amt_on_detail_line'] == 'yes') ) { 
  452. $message_line .= __('  (Error)', 'vtmin'); 
  453. $message_line .= __('</span>', 'vtmin'); //end "quantity" end "color-grp" 
  454.  
  455. $message_line .= __('<span class="price-column price">', 'vtmin'); 
  456. $message_line .= vtmin_format_money_element($vtmin_cart->cart_items[$k]->unit_price); 
  457. //$message_line .= $vtmin_cart->cart_items[$k]->unit_price; 
  458. $message_line .= __('</span>', 'vtmin'); //end "price" 
  459.  
  460. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { 
  461. $message_line .= __('<span class="total-column total color-grp', 'vtmin'); 
  462. $message_line .= $vtmin_info['cart_color_cnt']; 
  463. if ( $vtmin_info['bold_the_error_amt_on_detail_line'] == 'yes') { 
  464. $message_line .= __(' bold-this', 'vtmin'); 
  465. $message_line .= __('">', 'vtmin'); 
  466. } else { 
  467. $message_line .= __('<span class="total-column total">', 'vtmin');  
  468. //$message_line .= $vtmin_cart->cart_items[$k]->total_price; 
  469. $message_line .= vtmin_format_money_element($vtmin_cart->cart_items[$k]->total_price); 
  470. if ( ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') && ($vtmin_info['bold_the_error_amt_on_detail_line'] == 'yes') ) { 
  471. $message_line .= __('  (Error)', 'vtmin'); 
  472. }  
  473. $message_line .= __('</span>', 'vtmin'); //end "total-column" end "color-grp" 
  474. $message_line .= __('</span>', 'vtmin'); //end "table-msg-line" 
  475.  
  476. //keep a running total 
  477. $vtmin_info['cart_grp_info']['qty'] += $vtmin_cart->cart_items[$k]->quantity;  
  478. $vtmin_info['cart_grp_info']['price'] += $vtmin_cart->cart_items[$k]->total_price;  
  479.  
  480. return $message_line; 
  481.  
  482.  
  483. public function vtmin_table_totals_line ($i) { 
  484. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info; 
  485.  
  486. $message_totals; 
  487. $vtmin_info['line_cnt']++; 
  488.  
  489. $message_totals .= __('<span class="table-totals-line">', 'vtmin'); 
  490. $message_totals .= __('<span class="product-column">', 'vtmin'); 
  491. $message_totals .= __(' ', 'vtmin'); 
  492. $message_totals .= __('</span>', 'vtmin'); //end "product" 
  493.  
  494. if ($vtmin_rules_set[$i]->amtSelected_selection == 'quantity') { 
  495. $message_totals .= __('<span class="quantity-column quantity-column-total color-grp', 'vtmin'); 
  496. $message_totals .= $vtmin_info['cart_color_cnt']; 
  497. $message_totals .= __('">(', 'vtmin'); 
  498. //grp total qty 
  499. $message_totals .= $vtmin_info['cart_grp_info']['qty']; 
  500. $message_totals .= __(') Error', 'vtmin'); 
  501. } else { 
  502. $message_totals .= __('<span class="quantity-column">', 'vtmin'); 
  503. $message_totals .= __(' ', 'vtmin');  
  504. }  
  505. $message_totals .= __('</span>', 'vtmin'); //end "quantity" "color-grp" 
  506.  
  507. $message_totals .= __('<span class="price-column price">', 'vtmin'); 
  508. $message_totals .= __(' ', 'vtmin'); 
  509. $message_totals .= __('</span>', 'vtmin'); //end "price" 
  510.  
  511. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { 
  512. $message_totals .= __('<span class="quantity-column total-column-total color-grp', 'vtmin'); 
  513. $message_totals .= $vtmin_info['cart_color_cnt']; 
  514. $message_totals .= __('">(', 'vtmin'); 
  515. //grp total price 
  516. $message_totals .= vtmin_format_money_element($vtmin_info['cart_grp_info']['price']); 
  517. $message_totals .= __(') Error', 'vtmin');  
  518. } else { 
  519. $message_totals .= __('<span class="quantity-column">', 'vtmin'); 
  520. $message_totals .= __(' ', 'vtmin'); 
  521. $message_totals .= __('</span>', 'vtmin'); //end "total" "color-grp" 
  522. $message_totals .= __('</span>', 'vtmin'); //end "table-totals-line" 
  523.  
  524. return $message_totals; 
  525.  
  526. public function vtmin_table_titles() { 
  527. global $vtmin_info; 
  528. $message_title;  
  529. $message_title .= __('<span class="table-titles">', 'vtmin'); 
  530. $message_title .= __('<span class="product-column product-column-title">Product:</span>', 'vtmin'); 
  531. $message_title .= __('<span class="quantity-column quantity-column-title">Quantity:</span>', 'vtmin'); 
  532. $message_title .= __('<span class="price-column price-column-title">Price:</span>', 'vtmin'); 
  533. $message_title .= __('<span class="total-column total-column-title">Total:</span>', 'vtmin');  
  534. $message_title .= __('</span>', 'vtmin'); //end "table-titles" 
  535.  
  536. $this->vtmin_init_grp_info(); 
  537.  
  538. return $message_title; 
  539.  
  540. public function vtmin_init_grp_info() { 
  541. global $vtmin_info; 
  542. $vtmin_info['cart_grp_info'] = array( 'qty' => 0,  
  543. 'price' => 0 
  544. ); 
  545.  
  546.  
  547. public function vtmin_table_text_line ($i) { 
  548. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info; 
  549.  
  550. $message_text; 
  551. $vtmin_info['line_cnt']++; 
  552.  
  553. //SHOW TARGET MIN $/QTY AND CURRENTLY REACHED TOTAL 
  554.  
  555. $message_text .= __('<span class="table-error-msg"><span class="bold-this color-grp', 'vtmin'); 
  556. $message_text .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  557. $message_text .= __('">', 'vtmin'); 
  558. $message_text .= __('Error => ', 'vtmin'); 
  559. //v1.09.6 begin 
  560. if ($vtmin_rules_set[$i]->repeatingGroups > 0) { //v1.09.7 
  561. $message_text .= __('</span>Minimum Purchase/Repeating Groups ', 'vtmin'); //end "color-grp" 
  562. } else { 
  563. $message_text .= __('</span>Minimum Purchase ', 'vtmin'); //end "color-grp" 
  564. //v1.09.6 end 
  565.  
  566.  
  567. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { 
  568. if ( $vtmin_rules_set[$i]->specChoice_in_selection == 'all' ) { 
  569. $message_text .= __('total', 'vtmin'); 
  570. } else { 
  571. $message_text .= __(' <span class="color-grp', 'vtmin'); 
  572. $message_text .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  573. $message_text .= __('">', 'vtmin'); 
  574. $message_text .= __('quantity</span>', 'vtmin'); //end "color-grp" 
  575. $message_text .= __(' of <span class="color-grp', 'vtmin');  
  576. $message_text .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  577. $message_text .= __('">', 'vtmin'); 
  578.  
  579. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { 
  580. $message_text .= vtmin_format_money_element($vtmin_rules_set[$i]->minimum_amt['value']); 
  581. $message_text .= __('</span> required ', 'vtmin'); //if branch end "color-grp" 
  582. } else { 
  583. $message_text .= $vtmin_rules_set[$i]->minimum_amt['value'];  
  584. $message_text .= __(' </span>units required ', 'vtmin'); //if branch end "color-grp" 
  585. }  
  586.  
  587. switch( $vtmin_rules_set[$i]->inpop_selection ) {  
  588. case 'single' :  
  589. $message_text .= __('for this product.', 'vtmin'); 
  590. break; 
  591. case 'vargroup' :  
  592. $message_text .= __('for this product.', 'vtmin'); 
  593. break; 
  594. case 'groups' : 
  595. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  596. case 'all':  
  597. $message_text .= __('for this group.', 'vtmin'); 
  598. break; 
  599. case 'each': 
  600. $message_text .= __('of each product within the product group.', 'vtmin');  
  601. break; 
  602. case 'any': 
  603. $message_text .= __('for the first ', 'vtmin'); 
  604. $message_text .= __('<span class="color-grp', 'vtmin'); 
  605. $message_text .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  606. $message_text .= __('">', 'vtmin');  
  607. $message_text .= $vtmin_rules_set[$i]->anyChoice_max['value'];  
  608. $message_text .= __(' </span>product(s) found within the product group.', 'vtmin'); //end "color-grp" 
  609.  
  610. break; 
  611. break; 
  612. case 'cart' :  
  613. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  614. case 'all':  
  615. $message_text .= __('for the cart.', 'vtmin'); 
  616. break; 
  617. case 'each': 
  618. $message_text .= __('of each product the cart.', 'vtmin');  
  619. break; 
  620. case 'any': 
  621. $message_text .= __('for the first ', 'vtmin'); 
  622. $message_text .= __('<span class="color-grp', 'vtmin'); 
  623. $message_text .= $vtmin_info['cart_color_cnt']; //append the count which corresponds to a css color... 
  624. $message_text .= __('">', 'vtmin');  
  625. $message_text .= $vtmin_rules_set[$i]->anyChoice_max['value'];  
  626. $message_text .= __(' </span>product(s) found within the cart.', 'vtmin'); //end "color-grp"  
  627. break; 
  628. break; 
  629.  
  630. //show rule id in error msg  
  631. if ( ( $vtmin_setup_options['show_rule_ID_in_errmsg'] == 'yes' ) || ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) ) { 
  632. $message_text .= __('<span class="rule-id"> (Rule ID = ', 'vtmin'); 
  633. $message_text .= $vtmin_rules_set[$i]->post_id; 
  634. $message_text .= __(') </span>', 'vtmin'); 
  635.  
  636.  
  637. $message_text .= __('</span>', 'vtmin'); //end "table-error-msg"  
  638.  
  639.  
  640. //SHOW CATEGORIES TO WHICH THIS MSG APPLIES IN GENERAL, IF RELEVANT 
  641. if ( ( $vtmin_rules_set[$i]->inpop_selection <> 'single' ) && ( sizeof($vtmin_rules_set[$i]->errProds_cat_names) > 0 ) ) { 
  642. $vtmin_info['line_cnt']++; 
  643. $message_text .= __('<span class="table-text-line">', 'vtmin'); 
  644. $vtmin_rules_set[$i]->errProds_size = sizeof($vtmin_rules_set[$i]->errProds_cat_names); 
  645. $message_text .= __('<span class="table-text-cats">The minimum purchase rule applies to any products in the following categories: </span><span class="black-font-italic">', 'vtmin'); 
  646. for($k=0; $k < $vtmin_rules_set[$i]->errProds_size; $k++) { 
  647. $message_text .= __(' "', 'vtmin'); 
  648. $message_text .= $vtmin_rules_set[$i]->errProds_cat_names[$k]; 
  649. $message_text .= __('" ', 'vtmin');  
  650. }  
  651. $message_text .= __('</span>', 'vtmin'); //end "table-text-cats" 
  652. $message_text .= __('</span>', 'vtmin'); //end "table-text-line" 
  653. }  
  654.  
  655. return $message_text;  
  656.  
  657.  
  658. public function vtmin_create_text_error_message ($i) {  
  659. global $vtmin_setup_options, $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info;  
  660. $vtmin_rules_set[$i]->rule_requires_cart_action = 'yes'; 
  661.  
  662. //v1.08 begin 
  663. if ( $vtmin_rules_set[$i]->custMsg_text > ' ') { //custom msg override  
  664. $vtmin_cart->error_messages[] = array ( 
  665. 'msg_from_this_rule_id' => $vtmin_rules_set[$i]->post_id,  
  666. 'msg_from_this_rule_occurrence' => $i,  
  667. 'msg_text' => $vtmin_rules_set[$i]->custMsg_text,  
  668. 'msg_is_custom' => 'yes'  
  669. ); 
  670. $this->vtmin_set_custom_msgs_status('customMsg');  
  671. return; 
  672. }  
  673. //v1.08 end 
  674.  
  675. if ( $vtmin_setup_options['show_error_messages_in_table_form'] == 'yes' ) { 
  676. $vtmin_info['error_message_needed'] = 'yes'; 
  677. // $vtmin_cart->error_messages[] = array ('msg_from_this_rule_id' => $vtmin_rules_set[$i]->post_id, 'msg_from_this_rule_occurrence' => $i, 'msg_text' => '' );  
  678. } else {  
  679. //SHOW PRODUCT NAME(S) IN ERROR 
  680. $message; //initialize $message 
  681. switch( $vtmin_rules_set[$i]->inpop_selection ) {  
  682. case 'cart': 
  683. $message .= __('<span class="errmsg-begin">Minimum Purchase Required ::</span> For ', 'vtmin'); 
  684. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  685. case 'all':  
  686. //$message .= __('all', 'vtmin'); 
  687. break; 
  688. case 'each': 
  689. $message .= __('each of', 'vtmin');  
  690. break; 
  691. case 'any': 
  692. $message .= __('each of', 'vtmin');  
  693. break; 
  694. }  
  695. $message .= __(' the product(s) in your cart: <span class="red-font-italic">', 'vtmin'); 
  696. $message .= $this->vtmin_list_out_product_names($i); 
  697. $message .= __('</span>', 'vtmin');  
  698. break; 
  699. case 'groups':  
  700. $message .= __('<span class="errmsg-begin">Minimum Purchase Required ::</span> For ', 'vtmin'); 
  701. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  702. case 'all':  
  703. //$message .= __('all', 'vtmin'); 
  704. break; 
  705. case 'each': 
  706. $message .= __('each of', 'vtmin');  
  707. break; 
  708. case 'any': 
  709. $message .= __('each of', 'vtmin');  
  710. break; 
  711. $message .= __(' these product(s) in your cart: <span class="red-font-italic">', 'vtmin'); 
  712. $message .= $this->vtmin_list_out_product_names($i); 
  713. $message .= __('</span>', 'vtmin');  
  714. break; 
  715. case 'vargroup': 
  716. $message .= __(' these product(s) in your cart: <span class="red-font-italic">', 'vtmin'); 
  717. $message .= $this->vtmin_list_out_product_names($i); 
  718. $message .= __('</span>', 'vtmin'); 
  719. break; 
  720. case 'single': 
  721. $message .= __('For this product in your cart: <span class="red-font-italic">"', 'vtmin'); 
  722. $message .= $vtmin_rules_set[$i]->errProds_names [0]; 
  723. $message .= __('"</span> ', 'vtmin'); 
  724. break; 
  725. }  
  726.  
  727. //SHOW TARGET MIN $/QTY AND CURRENTLY REACHED TOTAL 
  728. if ($vtmin_rules_set[$i]->amtSelected_selection == 'currency') { 
  729. $message .= __('<br /><span class="errmsg-text">A minimum of::<span class="errmsg-amt-required"> ', 'vtmin'); 
  730. $message .= $vtmin_rules_set[$i]->minimum_amt['value']; 
  731. $message .= __(' total dollars</span> must be purchased. The current total ', 'vtmin'); 
  732. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  733. case 'all':  
  734. $message .= __('for the products ', 'vtmin'); 
  735. break; 
  736. case 'each': 
  737. $message .= __('for this product ', 'vtmin');  
  738. break; 
  739. case 'any': 
  740. $message .= __('for this product ', 'vtmin');  
  741. break; 
  742. $message .= __('in the cart is::<span class="errmsg-amt-current"> ', 'vtmin'); 
  743. $message .= $vtmin_rules_set[$i]->errProds_total_price; 
  744. if ($vtmin_rules_set[$i]->errProds_total_price > 1 ) { 
  745. $message .= __(' dollars.</span></span> ', 'vtmin'); 
  746. } else { 
  747. $message .= __(' dollar.</span></span> ', 'vtmin'); 
  748.  
  749. } else { 
  750. $message .= __('<br /><span class="errmsg-text">A minimum quantity of::<span class="errmsg-amt-required"> ', 'vtmin'); 
  751. $message .= $vtmin_rules_set[$i]->minimum_amt['value']; 
  752. $message .= __(' units</span> must be purchased. The current total ', 'vtmin'); 
  753. switch( $vtmin_rules_set[$i]->specChoice_in_selection ) { 
  754. case 'all':  
  755. $message .= __('for the products ', 'vtmin'); 
  756. break; 
  757. case 'each': 
  758. $message .= __('for this product ', 'vtmin');  
  759. break; 
  760. case 'any': 
  761. $message .= __('for this product ', 'vtmin');  
  762. break; 
  763. $message .= __('in the cart is::<span class="errmsg-amt-current"> ', 'vtmin'); 
  764. $message .= $vtmin_rules_set[$i]->errProds_qty; 
  765. if ($vtmin_rules_set[$i]->errProds_qty > 1) { 
  766. $message .= __(' units.</span></span> ', 'vtmin'); 
  767. } else { 
  768. $message .= __(' unit.</span></span> ', 'vtmin'); 
  769.  
  770.  
  771. //show rule id in error msg  
  772. if ( ( $vtmin_setup_options['show_rule_ID_in_errmsg'] == 'yes' ) || ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) ) { 
  773. $message .= __('<span class="rule-id"> (Rule ID = ', 'vtmin'); 
  774. $message .= $vtmin_rules_set[$i]->post_id; 
  775. $message .= __(') </span>', 'vtmin'); 
  776.  
  777. //SHOW CATEGORIES TO WHICH THIS MSG APPLIES IN GENERAL, IF RELEVANT 
  778. if ( ( $vtmin_rules_set[$i]->inpop_selection <> 'single' ) && ( sizeof($vtmin_rules_set[$i]->errProds_cat_names) > 0 ) ) { 
  779. $vtmin_rules_set[$i]->errProds_size = sizeof($vtmin_rules_set[$i]->errProds_cat_names); 
  780. $message .= __('<br />:: <span class="black-font">The minimum purchase rule applies to any products in the following categories: </span><span class="black-font-italic">', 'vtmin'); 
  781. for($k=0; $k < $vtmin_rules_set[$i]->errProds_size; $k++) { 
  782. $message .= __(' "', 'vtmin'); 
  783. $message .= $vtmin_rules_set[$i]->errProds_cat_names[$k]; 
  784. $message .= __('" ', 'vtmin'); 
  785. // if ( $k < $vtmin_rules_set[$i]->errProds_size ) { 
  786. $message .= __('</span>', 'vtmin'); 
  787. // } 
  788. //$message .= __('" ', 'vtmin'); 
  789.  
  790. //queue the message to go back to the screen  
  791. $vtmin_cart->error_messages[] = array ( 
  792. 'msg_from_this_rule_id' => $vtmin_rules_set[$i]->post_id,  
  793. 'msg_from_this_rule_occurrence' => $i,  
  794. 'msg_text' => $message,  
  795. 'msg_is_custom' => 'no' //v1.08  
  796. );  
  797. $this->vtmin_set_custom_msgs_status ('standardMsg'); //v1.08  
  798.  
  799. } //end text message formatting 
  800. /** 
  801. if ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) {  
  802. echo '$message'; echo '<pre>'.print_r($message, true).'</pre>' ; 
  803. echo '$vtmin_rules_set[$i]->errProds_qty = '; echo '<pre>'.print_r($vtmin_rules_set[$i]->errProds_qty, true).'</pre>' ; 
  804. echo '$vtmin_rules_set[$i]->errProds_total_price = ' ; echo '<pre>'.print_r($vtmin_rules_set[$i]->errProds_total_price, true).'</pre>' ; 
  805. echo '$vtmin_rules_set[$i]->errProds_names = '; echo '<pre>'.print_r($vtmin_rules_set[$i]->errProds_names, true).'</pre>' ; 
  806. echo '$vtmin_rules_set[$i]->errProds_cat_names = '; echo '<pre>'.print_r($vtmin_rules_set[$i]->errProds_cat_names, true).'</pre>' ;  
  807. }  
  808. */ 
  809.  
  810. }  
  811.  
  812. //*************************************  
  813. //v1.08 new function  
  814. //*************************************  
  815. public function vtmin_set_custom_msgs_status ($message_state) {  
  816. global $vtmin_cart; 
  817. switch( $vtmin_cart->error_messages_are_custom ) {  
  818. case 'all': 
  819. if ($message_state == 'standardMsg') { 
  820. $vtmin_cart->error_messages_are_custom = 'some'; 
  821. break; 
  822. case 'some': 
  823. break;  
  824. case 'none': 
  825. if ($message_state == 'customMsg') { 
  826. $vtmin_cart->error_messages_are_custom = 'some'; 
  827. break;  
  828. default: //no state set yet 
  829. if ($message_state == 'standardMsg') { 
  830. $vtmin_cart->error_messages_are_custom = 'none'; 
  831. } else { 
  832. $vtmin_cart->error_messages_are_custom = 'all'; 
  833. break;  
  834.  
  835. return; 
  836. }  
  837. //v1.08 end 
  838.  
  839.  
  840. public function vtmin_product_is_in_inpop_group ($i, $k) {  
  841. global $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info, $vtmin_setup_options; 
  842. /** at this point, the checked list produced at rule store time could be out of sync with the db, as the cats/roles originally selected to be 
  843. * part of this rule could have been deleted. this won't affect these loops, as the deleted cats/roles will simply not be in the  
  844. * 'get_object_terms' list. */ 
  845.  
  846. $vtmin_is_role_in_list = $this->vtmin_is_role_in_list_test ($i, $k); 
  847.  
  848. if ($vtmin_is_role_in_list) { 
  849. return true; 
  850.  
  851. return false; 
  852.  
  853.  
  854. public function vtmin_is_role_in_list_test ($i, $k) { 
  855. global $vtmin_cart, $vtmin_rules_set, $vtmin_rule, $vtmin_info, $vtmin_setup_options;  
  856. if ( sizeof($vtmin_rules_set[$i]->role_in_checked) > 0 ) { 
  857. if (in_array($this->vtmin_get_current_user_role(), $vtmin_rules_set[$i]->role_in_checked )) { //if role is in previously checked_list 
  858. /** 
  859. if ( $vtmin_setup_options['debugging_mode_on'] == 'yes' ) {  
  860. echo 'current user role= <pre>'.print_r($this->vtmin_get_current_user_role(), true).'</pre>' ; 
  861. echo 'rule id= <pre>'.print_r($vtmin_rules_set[$i]->post_id, true).'</pre>' ;  
  862. echo 'role_in_checked= <pre>'.print_r($vtmin_rules_set[$i]->role_in_checked, true).'</pre>' ;  
  863. echo 'i= '.$i . '<br>'; echo 'k= '.$k . '<br>'; 
  864. */ 
  865. return true;  
  866. }  
  867. }  
  868. return false; 
  869. }  
  870.  
  871. public function vtmin_get_current_user_role() { 
  872. global $current_user;  
  873. $user_roles = $current_user->roles; 
  874. $user_role = array_shift($user_roles); 
  875. if ($user_role <= ' ') { 
  876. $user_role = 'notLoggedIn'; 
  877. }  
  878. return $user_role; 
  879.  
  880. public function vtmin_list_out_product_names($i) { 
  881. $prodnames; 
  882. global $vtmin_rules_set;  
  883. for($p=0; $p < sizeof($vtmin_rules_set[$i]->errProds_names); $p++) { 
  884. $prodnames .= __(' "', 'vtmin'); 
  885. $prodnames .= $vtmin_rules_set[$i]->errProds_names[$p]; 
  886. $prodnames .= __('" ', 'vtmin'); 
  887. }  
  888. return $prodnames; 
  889.  
  890. public function vtmin_load_inpop_found_list($i, $k) { 
  891. global $vtmin_cart, $vtmin_rules_set; 
  892. $vtmin_rules_set[$i]->inpop_found_list[] = array('prod_id' => $vtmin_cart->cart_items[$k]->product_id,  
  893. 'prod_name' => $vtmin_cart->cart_items[$k]->product_name,  
  894. 'prod_qty' => $vtmin_cart->cart_items[$k]->quantity,  
  895. 'prod_total_price' => $vtmin_cart->cart_items[$k]->total_price,  
  896. 'prod_cat_list' => $vtmin_cart->cart_items[$k]->prod_cat_list,  
  897. 'rule_cat_list' => $vtmin_cart->cart_items[$k]->rule_cat_list,  
  898. 'prod_id_cart_occurrence' => $k, //used to mark product in cart if failed a rule 
  899. 'prod_requires_action' => ''  
  900. ); 
  901. $vtmin_rules_set[$i]->inpop_qty_total += $vtmin_cart->cart_items[$k]->quantity; 
  902. $vtmin_rules_set[$i]->inpop_total_price += $vtmin_cart->cart_items[$k]->total_price; 
  903.  
  904. public function vtmin_init_recursive_work_elements($i) {  
  905. global $vtmin_rules_set; 
  906. $vtmin_rules_set[$i]->errProds_qty = 0 ; 
  907. $vtmin_rules_set[$i]->errProds_total_price = 0 ; 
  908. $vtmin_rules_set[$i]->errProds_ids = array() ; 
  909. $vtmin_rules_set[$i]->errProds_names = array() ;  
  910. public function vtmin_init_cat_work_elements($i) {  
  911. global $vtmin_rules_set; 
  912. $vtmin_rules_set[$i]->errProds_cat_names = array() ;  
  913. }  
  914.  
  915. public function vtmin_mark_product_as_requiring_cart_action($i, $k) {  
  916. global $vtmin_rules_set, $vtmin_cart; 
  917. //mark the product in the rules_set 
  918. $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_requires_action'] = 'yes'; 
  919. $z = $vtmin_rules_set[$i]->inpop_found_list[$k]['prod_id_cart_occurrence']; 
  920. //prepare for future rollout needs if a rule population conflict ensues 
  921. $vtmin_cart->cart_items[$z]->product_participates_in_rule[] =  
  922. array( 
  923. 'post_id' => $vtmin_rules_set[$i]->post_id,  
  924. 'inpop_selection' => $vtmin_rules_set[$i]->inpop_selection, //needed to test for 'vargroup' 
  925. 'ruleset_occurrence' => $i,  
  926. 'inpop_occurrence' => $k  
  927. ) ;  
  928. }  
  929.  
  930.  
  931. } //end class