VTMIN_Rule

Rules are stored on the WP database as custom posts with custom field attributes.

Defined (1)

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

/core/vtmin-rules-classes.php  
  1. class VTMIN_Rule { 
  2. public $post_id; 
  3.  
  4. /** RULE STATUS 
  5. * rule status = pending or publish =>  
  6. * if status is 'pending', the rule will not be executed during cart processing 
  7. * rule status will be set to 'pending'  
  8. * => when errors have been detected during update process 
  9. * => when the custom post type status has been changed to 'trash'  
  10. */ 
  11. public $rule_status;  
  12.  
  13. //candidate population, checked arrays 
  14. public $inpop; 
  15. public $inpop_selection; 
  16.  
  17. //single with variations 
  18. public $inpop_varProdID; 
  19. public $inpop_varProdID_name; 
  20. public $var_in_checked; 
  21.  
  22. //single product 
  23. public $inpop_singleProdID; 
  24. public $inpop_singleProdID_name; 
  25.  
  26. //group choices  
  27. public $prodcat_in_checked;  
  28. public $rulecat_in_checked;  
  29. public $role_in_checked; 
  30. public $role_and_or_in; 
  31. public $role_and_or_in_selection;  
  32. // public $inpop_group_is_based_on; //prodcat / rulecat / role / multi / null 
  33.  
  34. //candidate population handling 
  35. public $specChoice_in; 
  36. public $specChoice_in_selection; 
  37. public $anyChoice_max; 
  38.  
  39. //minimum amount 
  40. public $amtSelected; 
  41. public $amtSelected_selection; 
  42. public $minimum_amt; 
  43.  
  44. //v1.08 begin 
  45. //custom messaging  
  46. public $custMsg_text; 
  47. //v1.08 end  
  48. public $repeatingGroups; //v1.09.6  
  49.  
  50. /********************* 
  51. * error messages during admin rule creation - if error message,  
  52. * overall rule status is pending,  
  53. * ie inactive relative to ecommerce purchases 
  54. ********************* */ 
  55. public $rule_error_message; 
  56. //********************* 
  57.  
  58. //****************************************** 
  59. //temp data loaded only at rule processing time, not retained in storage 
  60. //****************************************** 
  61. public $inpop_found_list; 
  62. public $inpop_qty_total; 
  63. public $inpop_total_price; 
  64. public $rule_requires_cart_action; // yes=apply rule, no=skip 
  65. public $errProds_qty; 
  66. public $errProds_total_price; 
  67. public $errProds_ids; 
  68. public $errProds_names; 
  69. public $errProds_cat_names; 
  70. //****************************************** 
  71.  
  72. public function __construct() { 
  73.  
  74. $this->post_id = ' '; //id of custom post rule 
  75. $this->rule_status = ' '; //pending or publish 
  76. $this->inpop = array ( 
  77. array(  
  78. 'id' => 'cartChoice',  
  79. 'class' => '',  
  80. 'type' => 'radio',  
  81. 'name' => 'popChoice',  
  82. 'value' => 'cart', //checked, selected, contents, etc  
  83. 'label' => __(' Apply to all Products in the Cart', 'vtmin'),  
  84. 'user_input' => '' //checked, selected, contents, etc  
  85. ) ,  
  86. array(  
  87. 'id' => 'groupChoice',  
  88. 'class' => '',  
  89. 'type' => 'radio',  
  90. 'name' => 'popChoice',  
  91. 'value' => 'groups', //checked, selected, contents, etc  
  92. 'label' => __( ' Use Selection Groups', 'vtmin'),  
  93. 'user_input' => '' //checked, selected, contents, etc  
  94. ) ,  
  95. array(  
  96. 'id' => 'varChoice',  
  97. 'class' => '',  
  98. 'type' => 'radio',  
  99. 'name' => 'popChoice',  
  100. 'value' => 'vargroup', //checked, selected, contents, etc  
  101. 'label' => __(' Single Product with Variations', 'vtmin'),  
  102. 'user_input' => '' //checked, selected, contents, etc  
  103. ),  
  104. array(  
  105. 'id' => 'singleChoice',  
  106. 'class' => '',  
  107. 'type' => 'radio',  
  108. 'name' => 'popChoice',  
  109. 'value' => 'single', //checked, selected, contents, etc  
  110. 'label' => __(' Single Product Only', 'vtmin'),  
  111. 'user_input' => '' //checked, selected, contents, etc  
  112. )  
  113. ); 
  114. $this->inpop_selection; // cart or single or groups 
  115.  
  116. $this->inpop_varProdID = array (  
  117. 'id' => 'inVarProdID',  
  118. 'class' => 'text',  
  119. 'type' => 'text',  
  120. 'name' => 'inVarProdID',  
  121. 'value' => ''  
  122. ); 
  123. $this->inpop_varProdID_name; 
  124. $this->var_in_checked; 
  125.  
  126. $this->inpop_singleProdID = array (  
  127. 'id' => 'singleProdID',  
  128. 'class' => 'text',  
  129. 'type' => 'text',  
  130. 'name' => 'singleProdID',  
  131. 'value' => ''  
  132. ); 
  133. $this->inpop_singleProdID_name; 
  134.  
  135. $this->prodcat_in_checked; 
  136. $this->rulecat_in_checked; 
  137. $this->role_in_checked;  
  138. $this->role_and_or_in = array ( //role and/or as combined with cats 
  139. array(  
  140. 'id' => 'andChoice',  
  141. 'class' => '',  
  142. 'type' => 'radio',  
  143. 'name' => 'andorChoice',  
  144. 'value' => 'and', //checked, selected, contents, etc  
  145. 'label' => __(' And', 'vtmin'),  
  146. 'user_input' => '' //checked, selected, contents, etc  
  147. ) ,  
  148. array(  
  149. 'id' => 'orChoice',  
  150. 'class' => '',  
  151. 'type' => 'radio',  
  152. 'name' => 'andorChoice',  
  153. 'value' => 'or', //checked, selected, contents, etc  
  154. 'label' => __(' Or', 'vtmin'),  
  155. 'user_input' => '' //checked, selected, contents, etc  
  156. )  
  157. ); 
  158. $this->role_and_or_in_selection; //and/or 
  159.  
  160.  
  161. // $this->inpop_group_is_based_on; 
  162. //don't need a 'role_in_checked_name' array, as there can only ever be 1 per user, and the user role name will not be used in the error message.  
  163. $this->specChoice_in = array (  
  164. array(  
  165. 'id' => 'allChoice',  
  166. 'class' => 'allChosen',  
  167. 'type' => 'radio',  
  168. 'name' => 'specChoice',  
  169. 'value' => 'all',  
  170. 'label' => __(' *All* in the Population', 'vtmin'),  
  171. 'user_input' => '' //checked, selected, contents, etc  
  172. ) ,  
  173. array(  
  174. 'id' => 'eachChoice',  
  175. 'class' => 'eachChosen',  
  176. 'type' => 'radio',  
  177. 'name' => 'specChoice',  
  178. 'value' => 'each',  
  179. 'label' => __(' *Each* in the Population', 'vtmin'),  
  180. 'user_input' => '' //checked, selected, contents, etc  
  181. ) ,  
  182. array(  
  183. 'id' => 'anyChoice',  
  184. 'class' => 'anyChosen',  
  185. 'type' => 'radio',  
  186. 'name' => 'specChoice',  
  187. 'value' => 'any',  
  188. 'label' => __(' *Any* in the Population with limits', 'vtmin'),  
  189. 'user_input' => '' //checked, selected, contents, etc  
  190. )  
  191. ); 
  192. $this->specChoice_in_selection; // all or each or any  
  193. $this->anyChoice_max = array (  
  194. 'id' => 'anyChoice-max',  
  195. 'class' => 'text',  
  196. 'type' => 'text',  
  197. 'name' => 'anyChoice-max',  
  198. 'value' => '1'  
  199. ); 
  200. $this->amtSelected = array ( 
  201. array(  
  202. 'id' => 'qtySelected',  
  203. 'class' => 'qtySelectedClass',  
  204. 'type' => 'radio',  
  205. 'name' => 'amtSelected',  
  206. 'value' => 'quantity',  
  207. 'label' => __(' Apply to Quantity Total', 'vtmin'),  
  208. 'user_input' => '' //checked, selected, contents, etc  
  209. ) ,  
  210. array(  
  211. 'id' => 'amtSelected',  
  212. 'class' => 'amtSelectedClass',  
  213. 'type' => 'radio',  
  214. 'name' => 'amtSelected',  
  215. 'value' => 'currency',  
  216. 'label' => __(' Apply to Price', 'vtmin'),  
  217. 'user_input' => '' //checked, selected, contents, etc  
  218. )  
  219. ); 
  220. $this->amtSelected_selection; //quantity or currency  
  221. $this->minimum_amt = array (  
  222. 'id' => 'amtChoice-count',  
  223. 'class' => 'text',  
  224. 'type' => 'text',  
  225. 'name' => 'amtChoice-count',  
  226. 'value' => '1'  
  227. ); 
  228.  
  229. $this->custMsg_text; //v1.08  
  230. $this->repeatingGroups; //v1.09.6 
  231.  
  232. $this->rule_error_message = array(); 
  233.  
  234. /** ************************************************* */ 
  235. /** Rule Processing at Purchase 
  236. * data is loaded here only at purchase processing time 
  237. * category info covers both product cats and rule cats 
  238. */ 
  239. /** ************************************************* */ 
  240. $this->inpop_found_list = array( 
  241. /** **The following array structure is created on-the-fly during the apply process** 
  242. array( 
  243. 'prod_id' => '',  
  244. 'prod_name' => '',  
  245. 'prod_qty' => '',  
  246. 'prod_total_price' => '',  
  247. 'prod_cat_list' => array(),  
  248. 'rule_cat_list' => array(),  
  249. 'prod_id_cart_occurrence' => '', //used to mark product in cart if failed a rule 
  250. 'prod_requires_action' => '' //rule may require cart action, but some of the pop may not....  
  251. */ 
  252. );  
  253. $this->inpop_qty_total = 0.00; 
  254. $this->inpop_total_price = 0.00; 
  255. $this->rule_requires_cart_action; 
  256. $this->errProds_qty = 0.00 ; 
  257. $this->errProds_total_price = 0.00 ; 
  258. $this->errProds_ids = array() ; 
  259. $this->errProds_names = array() ; 
  260. $this->errProds_cat_names = array() ; 
  261.  
  262. } //end function  
  263.  
  264. } //end class