Discount Rules for WooCommerce - Version 1.9.8

Version Description

  • 13/05/20 =
  • Feature - Included v2 beta with new UI
  • Fix - PHP warning fix
  • Improvement - Event: apply_filters('woo_discount_rules_discounted_suffix_price', $discountPrice, $product);
  • Improvement - Event: woo_discount_rule_generate_discount_table_information, woo_discount_rule_discount_table_information
  • Improvement - Don't add free product when haveToApplyTheRules method return false
Download this release

Release Info

Developer flycart
Plugin Icon 128x128 Discount Rules for WooCommerce
Version 1.9.8
Comparing to
See all releases

Code changes from version 1.9.7 to 1.9.8

Files changed (220) hide show
  1. common.php +210 -0
  2. i18n/languages/woo-discount-rules.pot +2436 -632
  3. readme.txt +8 -1
  4. {assets → v1/assets}/css/bootstrap-datetimepicker.min.css +0 -0
  5. {assets → v1/assets}/css/bootstrap.min.css +0 -0
  6. {assets → v1/assets}/css/bootstrap.select.min.css +0 -0
  7. {assets → v1/assets}/css/custom.css +0 -0
  8. {assets → v1/assets}/css/jquery-ui.css +0 -0
  9. {assets → v1/assets}/css/select2.min.css +0 -0
  10. {assets → v1/assets}/css/style.css +77 -0
  11. {assets → v1/assets}/css/tabbablePanel.css +0 -0
  12. {assets → v1/assets}/css/woo_discount_rules.css +0 -0
  13. {assets → v1/assets}/fonts/glyphicons-halflings-regular.eot +0 -0
  14. {assets → v1/assets}/fonts/glyphicons-halflings-regular.svg +0 -0
  15. {assets → v1/assets}/fonts/glyphicons-halflings-regular.ttf +0 -0
  16. {assets → v1/assets}/fonts/glyphicons-halflings-regular.woff +0 -0
  17. {assets → v1/assets}/fonts/glyphicons-halflings-regular.woff2 +0 -0
  18. {assets → v1/assets}/js/app.js +65 -19
  19. {assets → v1/assets}/js/bootstrap-datetimepicker.min.js +0 -0
  20. {assets → v1/assets}/js/bootstrap.min.js +0 -0
  21. {assets → v1/assets}/js/bootstrap.select.min.js +0 -0
  22. {assets → v1/assets}/js/select2.min.js +0 -0
  23. {assets → v1/assets}/js/woo_discount_rules.js +0 -0
  24. {helper → v1/helper}/activation-helper.php +0 -0
  25. {helper → v1/helper}/general-helper.php +0 -0
  26. {helper → v1/helper}/purchase.php +0 -0
  27. {helper → v1/helper}/woo-function.php +0 -0
  28. {includes → v1/includes}/cart-rules.php +6 -3
  29. {includes → v1/includes}/compatibility.php +2 -2
  30. {includes → v1/includes}/discount-base.php +11 -5
  31. {includes → v1/includes}/pricing-productbased.php +0 -0
  32. {includes → v1/includes}/pricing-rules.php +25 -16
  33. {includes → v1/includes}/survey.php +0 -0
  34. loader.php → v1/loader.php +8 -5
  35. {vendor → v1/vendor}/askupa-software/wp-admin-notification/LICENSE +0 -0
  36. {vendor → v1/vendor}/askupa-software/wp-admin-notification/README.md +0 -0
  37. {vendor → v1/vendor}/askupa-software/wp-admin-notification/bootstrap.php +0 -0
  38. {vendor → v1/vendor}/askupa-software/wp-admin-notification/composer.json +0 -0
  39. {vendor → v1/vendor}/askupa-software/wp-admin-notification/handler.php +0 -0
  40. {vendor → v1/vendor}/autoload.php +0 -0
  41. {vendor → v1/vendor}/composer/ClassLoader.php +0 -0
  42. {vendor → v1/vendor}/composer/LICENSE +0 -0
  43. {vendor → v1/vendor}/composer/autoload_classmap.php +0 -0
  44. {vendor → v1/vendor}/composer/autoload_files.php +0 -0
  45. {vendor → v1/vendor}/composer/autoload_namespaces.php +0 -0
  46. {vendor → v1/vendor}/composer/autoload_psr4.php +0 -0
  47. {vendor → v1/vendor}/composer/autoload_real.php +0 -0
  48. {vendor → v1/vendor}/composer/autoload_static.php +0 -0
  49. {vendor → v1/vendor}/composer/installed.json +0 -0
  50. {vendor → v1/vendor}/flycartinc/inputhelper/composer.json +0 -0
  51. {vendor → v1/vendor}/flycartinc/inputhelper/src/FFilterInput.php +0 -0
  52. {vendor → v1/vendor}/flycartinc/inputhelper/src/FInput.php +0 -0
  53. {vendor → v1/vendor}/flycartinc/inputhelper/src/InputFilter.php +0 -0
  54. {vendor → v1/vendor}/flycartinc/inputhelper/src/ReadMe.md +0 -0
  55. {vendor → v1/vendor}/flycartinc/inputhelper/src/StringHelper.php +0 -0
  56. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/.editorconfig +0 -0
  57. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php +0 -0
  58. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Autoloader.php +0 -0
  59. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Extension.php +0 -0
  60. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Panel.php +0 -0
  61. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginExtension.php +0 -0
  62. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginPanel.php +0 -0
  63. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/ThemePanel.php +0 -0
  64. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Factory.php +0 -0
  65. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/InstalledPackage.php +0 -0
  66. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Metadata.php +4 -1
  67. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/OAuthSignature.php +0 -0
  68. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Info.php +0 -0
  69. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Package.php +0 -0
  70. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php +0 -0
  71. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Update.php +0 -0
  72. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/UpdateChecker.php +0 -0
  73. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Scheduler.php +0 -0
  74. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/StateStore.php +0 -0
  75. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Package.php +0 -0
  76. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Update.php +0 -0
  77. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/UpdateChecker.php +0 -0
  78. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Update.php +0 -0
  79. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpdateChecker.php +0 -0
  80. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpgraderStatus.php +0 -0
  81. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Utils.php +0 -0
  82. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Api.php +0 -0
  83. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BaseChecker.php +0 -0
  84. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BitBucketApi.php +0 -0
  85. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitHubApi.php +0 -0
  86. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitLabApi.php +0 -0
  87. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/PluginUpdateChecker.php +0 -0
  88. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Reference.php +0 -0
  89. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/ThemeUpdateChecker.php +0 -0
  90. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/README.md +0 -0
  91. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/composer.json +0 -0
  92. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css +0 -0
  93. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/examples/plugin.json +51 -51
  94. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/examples/theme.json +4 -4
  95. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/js/debug-bar.js +0 -0
  96. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo +0 -0
  97. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po +0 -0
  98. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.mo +0 -0
  99. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.po +0 -0
  100. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-de_DE.mo +0 -0
  101. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-de_DE.po +0 -0
  102. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fa_IR.mo +0 -0
  103. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fa_IR.po +0 -0
  104. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo +0 -0
  105. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.po +0 -0
  106. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo +0 -0
  107. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.po +0 -0
  108. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo +0 -0
  109. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-hu_HU.po +0 -0
  110. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-it_IT.mo +0 -0
  111. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-it_IT.po +0 -0
  112. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.mo +0 -0
  113. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.po +0 -0
  114. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo +0 -0
  115. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.po +0 -0
  116. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo +0 -0
  117. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.po +0 -0
  118. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo +0 -0
  119. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.po +0 -0
  120. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo +0 -0
  121. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.po +0 -0
  122. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo +0 -0
  123. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.po +0 -0
  124. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot +0 -0
  125. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/license.txt +0 -0
  126. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/plugin-update-checker.php +0 -0
  127. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/Parsedown.php +0 -0
  128. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/ParsedownLegacy.php +0 -0
  129. {vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/readme-parser.php +0 -0
  130. {view → v1/view}/cart-rules.php +0 -0
  131. {view → v1/view}/documentation.php +0 -0
  132. {view → v1/view}/includes/cart-menu.php +0 -0
  133. {view → v1/view}/includes/footer.php +0 -0
  134. {view → v1/view}/includes/header.php +0 -0
  135. {view → v1/view}/includes/menu.php +5 -0
  136. {view → v1/view}/includes/sub-menu.php +0 -0
  137. {view → v1/view}/pricing-rules.php +0 -0
  138. {view → v1/view}/settings.php +0 -0
  139. {view → v1/view}/settings_cart_rules.php +0 -0
  140. {view → v1/view}/settings_general.php +0 -0
  141. {view → v1/view}/settings_performance.php +0 -0
  142. {view → v1/view}/settings_price_rules.php +0 -0
  143. {view → v1/view}/settings_promotion.php +0 -0
  144. {view → v1/view}/settings_taxonomy.php +0 -0
  145. {view → v1/view}/template/discount-table-advance.php +0 -0
  146. {view → v1/view}/template/discount-table.php +0 -0
  147. {view → v1/view}/template/loop/sale-flash.php +0 -0
  148. {view → v1/view}/template/sidebar.php +0 -0
  149. {view → v1/view}/template/single-product/sale-flash.php +0 -0
  150. {view → v1/view}/template/total-savings-cart.php +0 -0
  151. {view → v1/view}/template/total-savings-order.php +0 -0
  152. {view → v1/view}/view-cart-rules.php +0 -0
  153. {view → v1/view}/view-pricing-rules.php +0 -0
  154. v2/App/Compatibility/Base.php +15 -0
  155. v2/App/Compatibility/CompositeProductsBySomewhereWarm.php +52 -0
  156. v2/App/Compatibility/CurrencySwitcherByRealmag777.php +64 -0
  157. v2/App/Compatibility/CurrencySwitcherByVillatheme.php +62 -0
  158. v2/App/Compatibility/CurrencySwitcherByWPWham.php +50 -0
  159. v2/App/Compatibility/ExtraProductOptionsProByThemeHigh.php +60 -0
  160. v2/App/Compatibility/ProductAddOnsByWooCommerce.php +103 -0
  161. v2/App/Compatibility/WholesalePricesByRymeraWebCo.php +57 -0
  162. v2/App/Conditions/Base.php +231 -0
  163. v2/App/Conditions/CartLineItemsCount.php +37 -0
  164. v2/App/Conditions/CartSubTotal.php +53 -0
  165. v2/App/Controllers/Admin/Settings.php +461 -0
  166. v2/App/Controllers/Admin/Tabs/Base.php +42 -0
  167. v2/App/Controllers/Admin/Tabs/Compatible.php +150 -0
  168. v2/App/Controllers/Admin/Tabs/DiscountRules.php +119 -0
  169. v2/App/Controllers/Admin/Tabs/GeneralSettings.php +61 -0
  170. v2/App/Controllers/Admin/Tabs/Help.php +29 -0
  171. v2/App/Controllers/Admin/Tabs/ImportExport.php +35 -0
  172. v2/App/Controllers/Admin/Tabs/Reports/Base.php +40 -0
  173. v2/App/Controllers/Admin/Tabs/Reports/RuleAmount.php +101 -0
  174. v2/App/Controllers/Admin/Tabs/Reports/RuleAmountWithCartDiscount.php +22 -0
  175. v2/App/Controllers/Admin/Tabs/Statistics.php +77 -0
  176. v2/App/Controllers/Admin/WDRAjax.php +529 -0
  177. v2/App/Controllers/Base.php +242 -0
  178. v2/App/Controllers/Configuration.php +117 -0
  179. v2/App/Controllers/DiscountCalculator.php +842 -0
  180. v2/App/Controllers/ManageDiscount.php +1553 -0
  181. v2/App/Controllers/OnSaleShortCode.php +567 -0
  182. v2/App/Controllers/ShortCodeManager.php +680 -0
  183. v2/App/Helpers/Filter.php +325 -0
  184. v2/App/Helpers/Helper.php +111 -0
  185. v2/App/Helpers/Input.php +1000 -0
  186. v2/App/Helpers/Language.php +84 -0
  187. v2/App/Helpers/Migration.php +1034 -0
  188. v2/App/Helpers/ProOptions.php +346 -0
  189. v2/App/Helpers/Rule.php +1507 -0
  190. v2/App/Helpers/RuleForm.php +223 -0
  191. v2/App/Helpers/SurveyForm.php +399 -0
  192. v2/App/Helpers/Template.php +77 -0
  193. v2/App/Helpers/Woocommerce.php +1525 -0
  194. v2/App/Models/DBTable.php +375 -0
  195. v2/App/Router.php +155 -0
  196. v2/App/Views/Admin/Menu.php +56 -0
  197. v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php +33 -0
  198. v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php +36 -0
  199. v2/App/Views/Admin/Rules/Conditions/Main.php +196 -0
  200. v2/App/Views/Admin/Rules/DiscountBatch/Main.php +140 -0
  201. v2/App/Views/Admin/Rules/Discounts/Bulk.php +82 -0
  202. v2/App/Views/Admin/Rules/Discounts/Cart.php +47 -0
  203. v2/App/Views/Admin/Rules/Discounts/Main.php +70 -0
  204. v2/App/Views/Admin/Rules/Discounts/simple.php +52 -0
  205. v2/App/Views/Admin/Rules/Filters/AllProducts.php +22 -0
  206. v2/App/Views/Admin/Rules/Filters/Main.php +176 -0
  207. v2/App/Views/Admin/Rules/Filters/Products.php +24 -0
  208. v2/App/Views/Admin/Rules/Manage.php +233 -0
  209. v2/App/Views/Admin/Rules/Others/CommonTemplates.php +96 -0
  210. v2/App/Views/Admin/Tabs/DiscountRule.php +328 -0
  211. v2/App/Views/Admin/Tabs/ImportExport.php +104 -0
  212. v2/App/Views/Admin/Tabs/Statistics.php +86 -0
  213. v2/App/Views/Admin/Tabs/compatible.php +44 -0
  214. v2/App/Views/Admin/Tabs/help.php +87 -0
  215. v2/App/Views/Admin/Tabs/settings.php +849 -0
  216. v2/App/Views/Admin/welcome-text.php +22 -0
  217. v2/App/Views/Templates/discount_table.php +175 -0
  218. v2/App/Views/Templates/loop/sale-flash.php +27 -0
  219. v2/App/Views/Templates/single-product/sale-flash.php +27 -0
  220. v2/Assets/Css/admin_style.css +1269 -0
common.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+
4
+ add_action('wp_ajax_awdr_auto_install_pro_plugin', function (){
5
+ FlycartWooDiscountRulesExistingPROUpdater::installProPlugin();
6
+ exit;
7
+ });
8
+ add_action('wp_ajax_awdr_switch_version', function (){
9
+ $version = isset($_REQUEST['version'])? $_REQUEST['version']: '';
10
+ $page = isset($_REQUEST['page'])? $_REQUEST['page']: '';
11
+ $return['status'] = false;
12
+ $return['message'] = esc_html__('Invalid request', WDR_TEXT_DOMAIN);
13
+ if($version !== '' && $page !== ''){
14
+ $url = admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version);
15
+ $do_switch = true;
16
+ if (!isAWDREnvironmentCompatible()) {
17
+ $return['message'] = __('Discount Rules 2.0 requires minimum PHP version of ', WDR_TEXT_DOMAIN) . ' ' . WDR_REQUIRED_PHP_VERSION;
18
+ wp_send_json_success($return);
19
+ }
20
+ if (!isAWDRWooCompatible()) {
21
+ $return['message'] = __('Discount Rules 2.0 requires at least Woocommerce', WDR_TEXT_DOMAIN) . ' ' . WDR_WC_REQUIRED_VERSION;
22
+ wp_send_json_success($return);
23
+ }
24
+ if (defined('WDR_BACKWARD_COMPATIBLE')) {
25
+ if(WDR_BACKWARD_COMPATIBLE == true){
26
+ if ($version == "v2") {
27
+ if (!defined('WDR_PRO')) {
28
+ $do_switch = false;
29
+ }
30
+ }
31
+ }
32
+ }
33
+ if($do_switch){
34
+ $return['status'] = true;
35
+ $return['message'] = '';
36
+ $return['url'] = $url;
37
+ } else {
38
+ $has_auto_update = false;
39
+ if (!is_multisite()) {
40
+ if(class_exists('FlycartWooDiscountRulesExistingPROUpdater')){
41
+ if(FlycartWooDiscountRulesExistingPROUpdater::availableAutoInstall()){
42
+ $has_auto_update = true;
43
+ }
44
+ }
45
+ }
46
+ if($has_auto_update){
47
+ $return['type'] = 'auto_install';
48
+ $message = __('<p>Since 2.0, you need BOTH Core and Pro (2.0) packages installed and activated.</p>', WDR_TEXT_DOMAIN);
49
+ $message .= __('<p><b>Why we made this change?</b></p>', WDR_TEXT_DOMAIN);
50
+ $message .= __('<p>This arrangement is to avoid the confusion in the installation and upgrade process. Many users first install the core free version. Then purchase the PRO version and try to install it over the free version. Since both free and pro packages have same names, wordpress asks them to uninstall free and then install pro. As you can see, this is quite confusing for the end users.</p>', WDR_TEXT_DOMAIN);
51
+ $message .= __('<p>As a result, starting from 2.0, we now have two packs: 1. Core 2. PRO.</p>', WDR_TEXT_DOMAIN);
52
+ $message .= '<p><button type="button" class="awdr_auto_install_pro_plugin btn btn-info">'.__('Download and Install', WDR_TEXT_DOMAIN).'</button></p>';
53
+ $return['message'] = $message;
54
+ } else {
55
+ $return['message'] = __('Since 2.0, you need BOTH Core and Pro (2.0) packages installed and activated. Please download the Pro 2.0 pack from My Downloads page in our site, install and activate it. <a href="https://docs.flycart.org/en/articles/4006520-switching-to-2-0-from-v1-x-versions?utm_source=woo-discount-rules-v2&utm_campaign=doc&utm_medium=text-click&utm_content=switch_to_v2" target="_blank">Here is a guide and video tutorial</a>', WDR_TEXT_DOMAIN);
56
+ $return['type'] = 'manual_install';
57
+ }
58
+ }
59
+ }
60
+
61
+ wp_send_json_success($return);
62
+ });
63
+
64
+
65
+ /**
66
+ * Action sto show the toggle button
67
+ */
68
+ add_action('advanced_woo_discount_rules_on_settings_head', function () {
69
+ $has_switch = true;
70
+ $page = NULL;
71
+ if (isset($_GET['page'])) {
72
+ $page = sanitize_text_field($_GET['page']);
73
+ }
74
+ global $awdr_load_version;
75
+ $version = ($awdr_load_version == "v1") ? "v2" : "v1";
76
+ $url = admin_url('admin.php?page=' . $page . '&awdr_switch_plugin_to=' . $version);
77
+ $message = __('Switch to Discount Rules 2.0 which comes with a better UI and advanced rules. (You can switch back any time. Your settings and rules in V1 are kept as is)', WDR_TEXT_DOMAIN);
78
+ $button_text = __("Switch to 2.0 <span style='background-color: #FF8C00 ; padding: 3px; border-radius: 4px'>Public beta</span>", WDR_TEXT_DOMAIN);
79
+ if($version == "v1"){
80
+ $has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption();
81
+ $message = __('Would you like to switch to older Woo Discount Rules?', WDR_TEXT_DOMAIN);
82
+ $button_text = __("Click here to Switch back", WDR_TEXT_DOMAIN);
83
+ }
84
+ if($has_switch){
85
+ echo '<div style="background: #fff;padding: 20px;font-size: 13px;font-weight: bold;">' . $message . ' <button class="btn btn-info awdr-switch-version-button" data-version="' . $version . '" data-page="'.$page.'">' . $button_text . '</button></div>';
86
+ echo "<div class='wdr_switch_message' style='color:#a00;font-weight: bold;'></div>";
87
+ echo '<div class="modal" id="wdr_switch_popup">
88
+ <div class="modal-sandbox"></div>
89
+ <div class="modal-box">
90
+ <div class="modal-header">
91
+ <div class="close-modal"><span class="wdr-close-modal-box">&#10006;</span></div>
92
+ <h1 class="wdr-modal-header-title">'.__("Install 2.0 Pro package", WDR_TEXT_DOMAIN).'</h1>
93
+ </div>
94
+ <div class="modal-body">
95
+ <div class=\'wdr_pro_install_message\'></div>
96
+ </div>
97
+ </div>
98
+ </div>';
99
+ }
100
+ });
101
+
102
+ add_action('advanced_woo_discount_rules_content_next_to_tabs', function () {
103
+ $has_switch = true;
104
+ $page = NULL;
105
+ if (isset($_GET['page'])) {
106
+ $page = sanitize_text_field($_GET['page']);
107
+ }
108
+ global $awdr_load_version;
109
+ $version = ($awdr_load_version == "v1") ? "v2" : "v1";
110
+ if($version == "v1"){
111
+ $has_switch = \Wdr\App\Helpers\Migration::hasSwitchBackOption();
112
+ }
113
+ if($has_switch){
114
+ $button_text = __("Switch back to Discount Rules 1.x", WDR_TEXT_DOMAIN);
115
+ echo '<button class="btn btn-info awdr-switch-version-button awdr-switch-version-button-on-tab" data-version="' . $version . '" data-page="'.$page.'">' . $button_text . '</button>';
116
+ }
117
+ });
118
+
119
+ /**
120
+ * Determines if the server environment is compatible with this plugin.
121
+ *
122
+ * @return bool
123
+ * @since 1.0.0
124
+ *
125
+ */
126
+ if(!function_exists('isAWDREnvironmentCompatible')){
127
+ function isAWDREnvironmentCompatible()
128
+ {
129
+ return version_compare(PHP_VERSION, WDR_REQUIRED_PHP_VERSION, '>=');
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Check the woocommerce is active or not
135
+ * @return bool
136
+ */
137
+ if(!function_exists('isAWDRWooActive')){
138
+ function isAWDRWooActive()
139
+ {
140
+ $active_plugins = apply_filters('active_plugins', get_option('active_plugins', array()));
141
+ if (is_multisite()) {
142
+ $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
143
+ }
144
+ return in_array('woocommerce/woocommerce.php', $active_plugins, false) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Check woocommerce version is compatibility
150
+ * @return bool
151
+ */
152
+ if(!function_exists('isAWDRWooCompatible')){
153
+ function isAWDRWooCompatible()
154
+ {
155
+ $current_wc_version = getAWDRWooVersion();
156
+ return version_compare($current_wc_version, WDR_WC_REQUIRED_VERSION, '>=');
157
+ }
158
+ }
159
+
160
+ /**
161
+ * get the version of woocommerce
162
+ * @return mixed|null
163
+ */
164
+ if(!function_exists('getAWDRWooVersion')){
165
+ function getAWDRWooVersion()
166
+ {
167
+ if (defined('WC_VERSION')) {
168
+ return WC_VERSION;
169
+ }
170
+ if (!function_exists('get_plugins')) {
171
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
172
+ }
173
+ $plugin_folder = get_plugins('/woocommerce');
174
+ $plugin_file = 'woocommerce.php';
175
+ $wc_installed_version = NULL;
176
+ if (isset($plugin_folder[$plugin_file]['Version'])) {
177
+ $wc_installed_version = $plugin_folder[$plugin_file]['Version'];
178
+ }
179
+ return $wc_installed_version;
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Determines if the WordPress compatible.
185
+ *
186
+ * @return bool
187
+ * @since 1.0.0
188
+ *
189
+ */
190
+ if(!function_exists('isAWDRWpCompatible')){
191
+ function isAWDRWpCompatible()
192
+ {
193
+ $required_wp_version = 4.9;
194
+ return version_compare(get_bloginfo('version'), $required_wp_version, '>=');
195
+ }
196
+ }
197
+
198
+ if(!function_exists('awdr_check_compatible')){
199
+ function awdr_check_compatible(){
200
+ if (!isAWDREnvironmentCompatible()) {
201
+ exit(__('This plugin can not be activated because it requires minimum PHP version of ', WDR_TEXT_DOMAIN) . ' ' . WDR_REQUIRED_PHP_VERSION);
202
+ }
203
+ if (!isAWDRWooActive()) {
204
+ exit(__('Woocommerce must installed and activated in-order to use Advanced woo discount rules!', WDR_TEXT_DOMAIN));
205
+ }
206
+ if (!isAWDRWooCompatible()) {
207
+ exit(__(' Advanced woo discount rules requires at least Woocommerce', WDR_TEXT_DOMAIN) . ' ' . WDR_WC_REQUIRED_VERSION);
208
+ }
209
+ }
210
+ }
i18n/languages/woo-discount-rules.pot CHANGED
@@ -13,665 +13,747 @@ msgstr ""
13
  "X-Generator: Loco https://localise.biz/\n"
14
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;"
15
 
16
- #: helper/general-helper.php:48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  msgid "Guest"
18
  msgstr ""
19
 
20
- #: helper/general-helper.php:617
21
  msgid "Start date and time is set in the future date"
22
  msgstr ""
23
 
24
- #: helper/general-helper.php:620
25
  msgid "Validity expired"
26
  msgstr ""
27
 
28
- #: helper/general-helper.php:637
29
  msgid "Will run in future"
30
  msgstr ""
31
 
32
- #: helper/general-helper.php:640
33
  msgid "Not running - validity expired"
34
  msgstr ""
35
 
36
- #: helper/general-helper.php:657
37
  msgid "Running"
38
  msgstr ""
39
 
40
- #: helper/general-helper.php:662
41
  msgid "Your server current date and time: "
42
  msgstr ""
43
 
44
- #: helper/general-helper.php:797
45
  msgid "Read Docs"
46
  msgstr ""
47
 
48
- #: helper/general-helper.php:1034 view/view-cart-rules.php:697
49
- #: view/view-pricing-rules.php:433
50
  msgid "Coupon already exists in WooCommerce. Please select another name"
51
  msgstr ""
52
 
53
- #: helper/purchase.php:25 view/includes/cart-menu.php:5
54
- #: view/includes/menu.php:6 view/includes/sub-menu.php:5
 
 
55
  msgid "Woo Discount Rules"
56
  msgstr ""
57
 
58
- #: helper/purchase.php:62 helper/purchase.php:134
59
  msgid "The license key for "
60
  msgstr ""
61
 
62
- #: helper/purchase.php:62 helper/purchase.php:134
63
  msgid "seems invalid."
64
  msgstr ""
65
 
66
- #: helper/purchase.php:62 helper/purchase.php:66 helper/purchase.php:134
67
- #: helper/purchase.php:137 helper/purchase.php:173
68
- msgid "Please enter a valid license key"
69
- msgstr ""
70
-
71
- #: helper/purchase.php:62 helper/purchase.php:66 helper/purchase.php:134
72
- #: helper/purchase.php:137
73
  msgid "You can get it from"
74
  msgstr ""
75
 
76
- #: helper/purchase.php:62 helper/purchase.php:66 helper/purchase.php:134
77
- #: helper/purchase.php:137
78
- msgid "our website"
79
- msgstr ""
80
-
81
- #: helper/purchase.php:66 helper/purchase.php:137
82
  msgid "License key for the "
83
  msgstr ""
84
 
85
- #: helper/purchase.php:66 helper/purchase.php:137
86
  msgid "is not entered."
87
  msgstr ""
88
 
89
- #: helper/purchase.php:73
90
  msgid ": You are using CORE version. Please Update to PRO version."
91
  msgstr ""
92
 
93
- #: helper/purchase.php:97
94
  msgid "-PRO-"
95
  msgstr ""
96
 
97
- #: helper/purchase.php:106
98
  msgid "Pro"
99
  msgstr ""
100
 
101
- #: helper/purchase.php:108
102
  msgid "Core"
103
  msgstr ""
104
 
105
- #: helper/purchase.php:182
106
- msgid "License key check : Passed."
107
- msgstr ""
108
-
109
- #: helper/purchase.php:186 view/settings_general.php:32
110
- msgid "License key seems to be Invalid. Please enter a valid license key"
111
- msgstr ""
112
-
113
- #: helper/woo-function.php:485 helper/woo-function.php:495
114
  msgid "Search for a product&hellip;"
115
  msgstr ""
116
 
117
- #: helper/woo-function.php:528 helper/woo-function.php:540
118
  msgid "Search for a user&hellip;"
119
  msgstr ""
120
 
121
- #: includes/advanced/free_shipping_method.php:16
122
  msgid "WooDiscount Free Shipping"
123
  msgstr ""
124
 
125
- #: includes/advanced/free_shipping_method.php:17
126
  msgid "Custom Shipping Method for Woocommerce Discount Rules"
127
  msgstr ""
128
 
129
- #: includes/advanced/free_shipping_method.php:68 view/documentation.php:63
130
- #: view/settings_cart_rules.php:126
131
  msgid "Free Shipping"
132
  msgstr ""
133
 
134
- #: includes/advanced/free_shipping_method.php:73
135
- #: includes/discount-base.php:1057 view/cart-rules.php:133
136
- #: view/pricing-rules.php:163 view/settings_promotion.php:65
137
- #: view/settings_promotion.php:100
 
138
  msgid "Enable"
139
  msgstr ""
140
 
141
- #: includes/advanced/free_shipping_method.php:75
142
  msgid "Enable this shipping."
143
  msgstr ""
144
 
145
- #: includes/advanced/free_shipping_method.php:80
 
 
146
  msgid "Title"
147
  msgstr ""
148
 
149
- #: includes/advanced/free_shipping_method.php:82
150
  msgid "Title to be display on site"
151
  msgstr ""
152
 
153
- #: includes/cart-rules.php:116 includes/pricing-rules.php:120
154
  msgid "Saved successfully"
155
  msgstr ""
156
 
157
- #: includes/cart-rules.php:187 includes/pricing-rules.php:153
158
  msgid "Failed to save"
159
  msgstr ""
160
 
161
- #: includes/discount-base.php:197 view/cart-rules.php:162
162
- #: view/pricing-rules.php:192
163
  msgid "Active"
164
  msgstr ""
165
 
166
- #: includes/discount-base.php:199 view/cart-rules.php:164
167
- #: view/pricing-rules.php:194 view/settings_cart_rules.php:95
168
- #: view/settings_cart_rules.php:102 view/settings_price_rules.php:169
169
- #: view/settings_promotion.php:22 view/settings_promotion.php:62
170
- #: view/settings_promotion.php:97 view/settings_promotion.php:132
 
 
171
  msgid "Disabled"
172
  msgstr ""
173
 
174
- #: includes/discount-base.php:516
175
  msgid "Cache cleared successfully"
176
  msgstr ""
177
 
178
- #: includes/discount-base.php:518
179
  msgid "Failed to clear cache"
180
  msgstr ""
181
 
182
- #: includes/discount-base.php:629 includes/discount-base.php:664
183
  msgid "Failed to do action"
184
  msgstr ""
185
 
186
- #: includes/discount-base.php:668
187
  msgid "Disabled successfully"
188
  msgstr ""
189
 
190
- #: includes/discount-base.php:671
191
  msgid "Deleted successfully"
192
  msgstr ""
193
 
194
- #: includes/discount-base.php:674
195
  msgid "Enabled successfully"
196
  msgstr ""
197
 
198
- #: includes/discount-base.php:694 includes/discount-base.php:695
199
- #: includes/discount-base.php:712
200
  msgid "copy"
201
  msgstr ""
202
 
203
- #: includes/discount-base.php:720
204
  msgid "Duplicate rule created successfully"
205
  msgstr ""
206
 
207
- #: includes/discount-base.php:724
208
  msgid "Failed to create duplicate rule"
209
  msgstr ""
210
 
211
- #: includes/discount-base.php:1011
212
  msgid "Please fill this field"
213
  msgstr ""
214
 
215
- #: includes/discount-base.php:1012
216
  msgid "Please Enter the Rule Name to Create / Save."
217
  msgstr ""
218
 
219
- #: includes/discount-base.php:1013
220
  msgid "Saving..."
221
  msgstr ""
222
 
223
- #: includes/discount-base.php:1014 view/view-cart-rules.php:55
224
- #: view/view-pricing-rules.php:37
225
  msgid "Save Rule"
226
  msgstr ""
227
 
228
- #: includes/discount-base.php:1015
229
  msgid "Please enter a Key"
230
  msgstr ""
231
 
232
- #: includes/discount-base.php:1016 view/view-pricing-rules.php:739
233
  msgid "Min Quantity"
234
  msgstr ""
235
 
236
- #: includes/discount-base.php:1017 view/view-pricing-rules.php:746
237
  msgid "Max Quantity"
238
  msgstr ""
239
 
240
- #: includes/discount-base.php:1018 view/view-pricing-rules.php:654
241
- #: view/view-pricing-rules.php:657 view/view-pricing-rules.php:677
 
242
  msgid "Quantity"
243
  msgstr ""
244
 
245
- #: includes/discount-base.php:1019 view/view-cart-rules.php:92
246
- #: view/view-pricing-rules.php:74 view/view-pricing-rules.php:744
247
- #: view/view-pricing-rules.php:897 view/view-pricing-rules.php:920
248
- #: view/view-pricing-rules.php:927
249
  msgid "ex. 1"
250
  msgstr ""
251
 
252
- #: includes/discount-base.php:1020 view/view-pricing-rules.php:965
253
  msgid "ex. 10"
254
  msgstr ""
255
 
256
- #: includes/discount-base.php:1021 view/view-pricing-rules.php:751
257
- #: view/view-pricing-rules.php:879
258
  msgid "ex. 50"
259
  msgstr ""
260
 
261
- #: includes/discount-base.php:1022
262
  msgid "Search for a user"
263
  msgstr ""
264
 
265
- #: includes/discount-base.php:1023 view/view-pricing-rules.php:752
266
  msgid "Adjustment Type"
267
  msgstr ""
268
 
269
- #: includes/discount-base.php:1024 view/view-pricing-rules.php:954
 
270
  msgid "Discount percentage"
271
  msgstr ""
272
 
273
- #: includes/discount-base.php:1025 view/view-cart-rules.php:776
274
- #: view/view-pricing-rules.php:786
275
  msgid "Percentage Discount"
276
  msgstr ""
277
 
278
- #: includes/discount-base.php:1026 view/view-cart-rules.php:782
279
- #: view/view-cart-rules.php:784 view/view-pricing-rules.php:794
280
- #: view/view-pricing-rules.php:796
281
  msgid "Price Discount"
282
  msgstr ""
283
 
284
- #: includes/discount-base.php:1027
285
  msgid "BOGO Product Discount"
286
  msgstr ""
287
 
288
- #: includes/discount-base.php:1028
289
  msgid "Product Discount - Not support for subtotal based rule"
290
  msgstr ""
291
 
292
- #: includes/discount-base.php:1029 view/view-cart-rules.php:462
293
- #: view/view-pricing-rules.php:874 view/view-pricing-rules.php:1014
 
 
294
  msgid "Value"
295
  msgstr ""
296
 
297
- #: includes/discount-base.php:1030 view/view-pricing-rules.php:882
298
  msgid "receive discount for"
299
  msgstr ""
300
 
301
- #: includes/discount-base.php:1031 view/view-pricing-rules.php:884
302
  msgid "Auto add all selected products"
303
  msgstr ""
304
 
305
- #: includes/discount-base.php:1032 view/view-pricing-rules.php:885
306
  msgid "Same product"
307
  msgstr ""
308
 
309
- #: includes/discount-base.php:1033
310
  msgid "Any one cheapest from selected"
311
  msgstr ""
312
 
313
- #: includes/discount-base.php:1034
314
  msgid "Any one cheapest from all products"
315
  msgstr ""
316
 
317
- #: includes/discount-base.php:1035 view/view-pricing-rules.php:854
318
- #: view/view-pricing-rules.php:856
319
  msgid "Buy X Get Y - Selected Categories (Cheapest in cart)"
320
  msgstr ""
321
 
322
- #: includes/discount-base.php:1036 view/view-pricing-rules.php:844
323
- #: view/view-pricing-rules.php:846
324
  msgid "Buy X Get Y - Selected item(s) (Cheapest in cart)"
325
  msgstr ""
326
 
327
- #: includes/discount-base.php:1037 view/view-pricing-rules.php:864
328
- #: view/view-pricing-rules.php:866
329
  msgid "Buy X get Y - Cheapest among all items in cart"
330
  msgstr ""
331
 
332
- #: includes/discount-base.php:1038 view/view-pricing-rules.php:892
333
  msgid "Free quantity"
334
  msgstr ""
335
 
336
- #: includes/discount-base.php:1039 view/view-pricing-rules.php:892
337
  msgid "Number of quantity(ies) in each selected product(s)"
338
  msgstr ""
339
 
340
- #: includes/discount-base.php:1040 view/view-pricing-rules.php:912
341
  msgid "Fixed item count (not recommended)"
342
  msgstr ""
343
 
344
- #: includes/discount-base.php:1041 view/view-pricing-rules.php:911
345
  msgid "Dynamic item count"
346
  msgstr ""
347
 
348
- #: includes/discount-base.php:1042 view/view-pricing-rules.php:914
349
  msgid ""
350
  "Fixed item count - You need to provide item count manually. Dynamic item "
351
  "count - System will choose dynamically based on cart"
352
  msgstr ""
353
 
354
- #: includes/discount-base.php:1043 view/view-pricing-rules.php:915
355
  msgid "Item count"
356
  msgstr ""
357
 
358
- #: includes/discount-base.php:1044 view/view-pricing-rules.php:915
359
  msgid "Discount for number of item(s) in cart"
360
  msgstr ""
361
 
362
- #: includes/discount-base.php:1045 view/view-pricing-rules.php:922
363
  msgid "Discount for number of quantity(ies)"
364
  msgstr ""
365
 
366
- #: includes/discount-base.php:1046 view/view-pricing-rules.php:922
367
  msgid "Item quantity"
368
  msgstr ""
369
 
370
- #: includes/discount-base.php:1047
371
  msgid "Search for a products"
372
  msgstr ""
373
 
374
- #: includes/discount-base.php:1048
375
  msgid "and"
376
  msgstr ""
377
 
378
- #: includes/discount-base.php:1049 view/view-pricing-rules.php:956
379
  msgid "100% percent"
380
  msgstr ""
381
 
382
- #: includes/discount-base.php:1050 view/view-pricing-rules.php:957
383
  msgid "Limited percent"
384
  msgstr ""
385
 
386
- #: includes/discount-base.php:1051
387
  msgid "Percentage"
388
  msgstr ""
389
 
390
- #: includes/discount-base.php:1052
391
  msgid "as discount"
392
  msgstr ""
393
 
394
- #: includes/discount-base.php:1053 view/view-cart-rules.php:701
395
- #: view/view-pricing-rules.php:974
396
  msgid "Remove"
397
  msgstr ""
398
 
399
- #: includes/discount-base.php:1054 view/cart-rules.php:185
400
- #: view/pricing-rules.php:215 view/view-pricing-rules.php:971
 
401
  msgid "Duplicate"
402
  msgstr ""
403
 
404
- #: includes/discount-base.php:1055
405
  msgid "none"
406
  msgstr ""
407
 
408
- #: includes/discount-base.php:1056
409
  msgid "Are you sure to remove this ?"
410
  msgstr ""
411
 
412
- #: includes/discount-base.php:1058 view/cart-rules.php:130
413
- #: view/pricing-rules.php:160
 
414
  msgid "Disable"
415
  msgstr ""
416
 
417
- #: includes/discount-base.php:1059
418
  msgid "Are you sure to remove ?"
419
  msgstr ""
420
 
421
- #: includes/discount-base.php:1060 view/view-cart-rules.php:172
422
  msgid "Type"
423
  msgstr ""
424
 
425
- #: includes/discount-base.php:1061 view/view-cart-rules.php:176
426
  msgid "Cart Subtotal"
427
  msgstr ""
428
 
429
- #: includes/discount-base.php:1062 view/view-cart-rules.php:179
430
  msgid "Subtotal at least"
431
  msgstr ""
432
 
433
- #: includes/discount-base.php:1063 view/view-cart-rules.php:183
434
  msgid "Subtotal less than"
435
  msgstr ""
436
 
437
- #: includes/discount-base.php:1064 view/view-cart-rules.php:186
438
  msgid "Cart Item Count"
439
  msgstr ""
440
 
441
- #: includes/discount-base.php:1065 view/view-cart-rules.php:189
442
  msgid "Number of line items in the cart (not quantity) at least"
443
  msgstr ""
444
 
445
- #: includes/discount-base.php:1066 view/view-cart-rules.php:193
446
  msgid "Number of line items in the cart (not quantity) less than"
447
  msgstr ""
448
 
449
- #: includes/discount-base.php:1067 view/view-cart-rules.php:196
450
  msgid "Quantity Sum"
451
  msgstr ""
452
 
453
- #: includes/discount-base.php:1068 view/view-cart-rules.php:202
454
- #: view/view-cart-rules.php:205
455
  msgid "Total number of quantities in the cart at least"
456
  msgstr ""
457
 
458
- #: includes/discount-base.php:1069 view/view-cart-rules.php:214
459
- #: view/view-cart-rules.php:217
460
  msgid "Total number of quantities in the cart less than"
461
  msgstr ""
462
 
463
- #: includes/discount-base.php:1070 view/view-cart-rules.php:246
464
  msgid "Categories in cart"
465
  msgstr ""
466
 
467
- #: includes/discount-base.php:1071 view/view-cart-rules.php:252
468
  msgid "Including sub-categories in cart"
469
  msgstr ""
470
 
471
- #: includes/discount-base.php:1072 view/view-cart-rules.php:267
472
  msgid "Customer Details (must be logged in)"
473
  msgstr ""
474
 
475
- #: includes/discount-base.php:1073 view/view-cart-rules.php:273
476
- #: view/view-cart-rules.php:275
477
  msgid "User in list"
478
  msgstr ""
479
 
480
- #: includes/discount-base.php:1074 view/view-cart-rules.php:283
481
- #: view/view-cart-rules.php:285
482
  msgid "User role in list"
483
  msgstr ""
484
 
485
- #: includes/discount-base.php:1075 view/view-cart-rules.php:349
486
- #: view/view-cart-rules.php:351
487
  msgid "Shipping country in list"
488
  msgstr ""
489
 
490
- #: includes/discount-base.php:1076 view/view-cart-rules.php:289
491
  msgid "Customer Email"
492
  msgstr ""
493
 
494
- #: includes/discount-base.php:1077
495
  msgid "Email with TLD (Ege: edu)"
496
  msgstr ""
497
 
498
- #: includes/discount-base.php:1078 view/view-cart-rules.php:305
499
- #: view/view-cart-rules.php:307
500
  msgid "Email with Domain (Eg: gmail.com)"
501
  msgstr ""
502
 
503
- #: includes/discount-base.php:1079 view/view-cart-rules.php:311
504
  msgid "Customer Billing Details"
505
  msgstr ""
506
 
507
- #: includes/discount-base.php:1080 view/view-cart-rules.php:317
508
- #: view/view-cart-rules.php:319
509
  msgid "Billing city"
510
  msgstr ""
511
 
512
- #: includes/discount-base.php:1081 view/view-cart-rules.php:323
513
  msgid "Customer Shipping Details"
514
  msgstr ""
515
 
516
- #: includes/discount-base.php:1082 view/view-cart-rules.php:339
517
- #: view/view-cart-rules.php:341
518
  msgid "Shipping state"
519
  msgstr ""
520
 
521
- #: includes/discount-base.php:1083 view/view-cart-rules.php:329
522
- #: view/view-cart-rules.php:331
523
  msgid "Shipping city"
524
  msgstr ""
525
 
526
- #: includes/discount-base.php:1084 view/view-cart-rules.php:359
527
- #: view/view-cart-rules.php:361
528
  msgid "Shipping zip code"
529
  msgstr ""
530
 
531
- #: includes/discount-base.php:1085 view/view-cart-rules.php:365
532
- #: view/view-pricing-rules.php:536
 
 
 
533
  msgid "Purchase History"
534
  msgstr ""
535
 
536
- #: includes/discount-base.php:1086 view/view-cart-rules.php:381
537
- #: view/view-cart-rules.php:383 view/view-pricing-rules.php:551
538
  msgid "Purchased amount"
539
  msgstr ""
540
 
541
- #: includes/discount-base.php:1087 view/view-cart-rules.php:391
542
- #: view/view-cart-rules.php:393 view/view-pricing-rules.php:552
543
  msgid "Number of previous orders made"
544
  msgstr ""
545
 
546
- #: includes/discount-base.php:1088 view/view-cart-rules.php:401
547
- #: view/view-cart-rules.php:403 view/view-pricing-rules.php:553
548
  msgid "Number of previous orders made with following products"
549
  msgstr ""
550
 
551
- #: includes/discount-base.php:1089 view/view-cart-rules.php:411
552
- #: view/view-cart-rules.php:413 view/view-pricing-rules.php:554
553
  msgid "Number of quantity(s) in previous orders made with following products"
554
  msgstr ""
555
 
556
- #: includes/discount-base.php:1090 view/view-cart-rules.php:417
557
  msgid "Coupon applied"
558
  msgstr ""
559
 
560
- #: includes/discount-base.php:1091 view/view-cart-rules.php:423
561
- #: view/view-cart-rules.php:425 view/view-pricing-rules.php:410
562
  msgid "Create your own coupon"
563
  msgstr ""
564
 
565
- #: includes/discount-base.php:1092 view/view-cart-rules.php:433
566
- #: view/view-cart-rules.php:435
567
  msgid "Atleast any one (Select from WooCommerce)"
568
  msgstr ""
569
 
570
- #: includes/discount-base.php:1093 view/view-cart-rules.php:443
571
- #: view/view-cart-rules.php:445
572
  msgid "All selected (Select from WooCommerce)"
573
  msgstr ""
574
 
575
- #: includes/discount-base.php:1094 view/view-cart-rules.php:647
576
- #: view/view-pricing-rules.php:590
577
  msgid "Greater than or equal to"
578
  msgstr ""
579
 
580
- #: includes/discount-base.php:1095 view/view-cart-rules.php:648
581
- #: view/view-pricing-rules.php:591 view/view-pricing-rules.php:650
582
  msgid "Less than or equal to"
583
  msgstr ""
584
 
585
- #: includes/discount-base.php:1096 view/view-cart-rules.php:650
586
- #: view/view-pricing-rules.php:594
587
  msgid "and the order status should be"
588
  msgstr ""
589
 
590
- #: includes/discount-base.php:1097 view/cart-rules.php:114
591
- #: view/cart-rules.php:224 view/pricing-rules.php:144
592
- #: view/pricing-rules.php:254 view/view-cart-rules.php:700
 
 
593
  msgid "Action"
594
  msgstr ""
595
 
596
- #: includes/discount-base.php:1098 view/settings.php:33
597
- #: view/settings_taxonomy.php:21
598
  msgid "Save"
599
  msgstr ""
600
 
601
- #: includes/discount-base.php:1099
602
  msgid "Saved Successfully!"
603
  msgstr ""
604
 
605
- #: includes/discount-base.php:1100 view/view-cart-rules.php:491
606
- #: view/view-cart-rules.php:559 view/view-cart-rules.php:579
607
- #: view/view-cart-rules.php:600 view/view-cart-rules.php:655
608
- #: view/view-pricing-rules.php:238 view/view-pricing-rules.php:254
609
- #: view/view-pricing-rules.php:602 view/view-pricing-rules.php:686
610
- #: view/view-pricing-rules.php:942
611
  msgid "None selected"
612
  msgstr ""
613
 
614
- #: includes/discount-base.php:1101 view/view-cart-rules.php:258
615
  msgid "In each category"
616
  msgstr ""
617
 
618
- #: includes/discount-base.php:1102 view/settings_price_rules.php:208
619
- #: view/settings_price_rules.php:226 view/settings_price_rules.php:244
620
- #: view/settings_price_rules.php:262
 
621
  msgid "Show"
622
  msgstr ""
623
 
624
- #: includes/discount-base.php:1103 view/template/sidebar.php:12
625
  msgid "Hide"
626
  msgstr ""
627
 
628
- #: includes/discount-base.php:1104
629
  msgid "Please select at least one rule"
630
  msgstr ""
631
 
632
- #: includes/discount-base.php:1105
633
  msgid "Please select an action to apply"
634
  msgstr ""
635
 
636
- #: includes/discount-base.php:1106
637
  msgid "Are you sure to remove the selected rules"
638
  msgstr ""
639
 
640
- #: includes/discount-base.php:1107 view/view-pricing-rules.php:931
641
  msgid "Choose product(s)"
642
  msgstr ""
643
 
644
- #: includes/discount-base.php:1108 view/view-pricing-rules.php:941
645
  msgid "Choose category(ies)"
646
  msgstr ""
647
 
648
- #: includes/discount-base.php:1109
649
  msgid "Search for a coupon"
650
  msgstr ""
651
 
652
- #: includes/discount-base.php:1110 view/view-pricing-rules.php:965
653
  #, php-format
654
  msgid "Enter only numeric values. Eg: <b>50</b> for 50% discount"
655
  msgstr ""
656
 
657
- #: includes/discount-base.php:1111
658
  #, php-format
659
  msgid "Enter the discount price. Eg: <b>10</b> for %s discount"
660
  msgstr ""
661
 
662
- #: includes/discount-base.php:1112
663
  #, php-format
664
  msgid "Enter the discounted price per unit. Eg: <b>10</b> for %s as unit price"
665
  msgstr ""
666
 
667
- #: includes/discount-base.php:1113
668
  #, php-format
669
  msgid ""
670
  "Enter the price for selected quantity. Eg: <b>10</b> then %s as total price "
671
  "for selected quantity"
672
  msgstr ""
673
 
674
- #: includes/discount-base.php:1114 view/view-pricing-rules.php:890
675
  msgid ""
676
  "Auto add all selected products - Automatically added to the cart <br> Same "
677
  "product - get discount in same product <br> Any one cheapest from selected - "
@@ -682,121 +764,122 @@ msgid ""
682
  "no.of quantities"
683
  msgstr ""
684
 
685
- #: includes/discount-base.php:1115 view/view-cart-rules.php:221
 
686
  msgid "Products"
687
  msgstr ""
688
 
689
- #: includes/discount-base.php:1116 view/view-cart-rules.php:226
690
  msgid "Products in cart"
691
  msgstr ""
692
 
693
- #: includes/discount-base.php:1117 view/view-cart-rules.php:232
694
- #: view/view-pricing-rules.php:273
695
  msgid "Exclude products"
696
  msgstr ""
697
 
698
- #: includes/discount-base.php:1118 view/view-cart-rules.php:238
699
  msgid "Exclude on sale products"
700
  msgstr ""
701
 
702
- #: includes/discount-base.php:1119 view/view-cart-rules.php:529
703
  msgid "This will exclude the on sale products from discount"
704
  msgstr ""
705
 
706
- #: includes/discount-base.php:1120 view/view-cart-rules.php:663
707
- #: view/view-pricing-rules.php:609
708
  msgid "From all previous orders"
709
  msgstr ""
710
 
711
- #: includes/discount-base.php:1121 view/view-cart-rules.php:664
712
- #: view/view-pricing-rules.php:610
713
  msgid "Last 7 days"
714
  msgstr ""
715
 
716
- #: includes/discount-base.php:1122 view/view-cart-rules.php:665
717
- #: view/view-pricing-rules.php:611
718
  msgid "Last 14 days"
719
  msgstr ""
720
 
721
- #: includes/discount-base.php:1123 view/view-cart-rules.php:666
722
- #: view/view-pricing-rules.php:612
723
  msgid "Last 30 days"
724
  msgstr ""
725
 
726
- #: includes/discount-base.php:1124 view/view-cart-rules.php:667
727
- #: view/view-pricing-rules.php:613
728
  msgid "Last 60 days"
729
  msgstr ""
730
 
731
- #: includes/discount-base.php:1125 view/view-cart-rules.php:668
732
- #: view/view-pricing-rules.php:614
733
  msgid "Last 90 days"
734
  msgstr ""
735
 
736
- #: includes/discount-base.php:1126 view/view-cart-rules.php:669
737
- #: view/view-pricing-rules.php:615
738
  msgid "Last 180 days"
739
  msgstr ""
740
 
741
- #: includes/discount-base.php:1127 view/view-cart-rules.php:670
742
- #: view/view-pricing-rules.php:616
743
  msgid "Last 1 year"
744
  msgstr ""
745
 
746
- #: includes/discount-base.php:1128 view/view-cart-rules.php:671
747
- #: view/view-pricing-rules.php:617
748
  msgid "Custom"
749
  msgstr ""
750
 
751
- #: includes/discount-base.php:1129 view/view-cart-rules.php:674
752
- #: view/view-pricing-rules.php:621
753
  msgid "in days"
754
  msgstr ""
755
 
756
- #: includes/discount-base.php:1130 view/view-pricing-rules.php:804
757
- #: view/view-pricing-rules.php:806
758
  msgid "Fixed Price Per Unit"
759
  msgstr ""
760
 
761
- #: includes/discount-base.php:1131 view/view-pricing-rules.php:814
762
- #: view/view-pricing-rules.php:816
763
  msgid "Bundle (Set) Discount"
764
  msgstr ""
765
 
766
- #: includes/discount-base.php:1132 view/view-cart-rules.php:371
767
- #: view/view-cart-rules.php:373 view/view-pricing-rules.php:550
768
  msgid "First Order discount"
769
  msgstr ""
770
 
771
- #: includes/discount-base.php:1133 view/view-cart-rules.php:264
772
  msgid "Exclude categories in cart"
773
  msgstr ""
774
 
775
- #: includes/discount-base.php:1135 view/view-pricing-rules.php:824
776
- #: view/view-pricing-rules.php:826
777
  msgid "Buy X get X (Same product)"
778
  msgstr ""
779
 
780
- #: includes/discount-base.php:1136 view/view-pricing-rules.php:834
781
- #: view/view-pricing-rules.php:836
782
  msgid "Buy X get Y (Auto add all selected products)"
783
  msgstr ""
784
 
785
- #: includes/discount-base.php:1137
786
  #, php-format
787
  msgid ""
788
  "The customer gets the same product free (Buy 2 get 1 free) or a limited "
789
  "percentage (Buy 2 and get 1 at 50% discount)"
790
  msgstr ""
791
 
792
- #: includes/discount-base.php:1138
793
  msgid ""
794
  "Provide a specific product free when purchasing another product."
795
  "<br><br>Example: Buy Product A and get Product B free. Product B will be "
796
  "automatically added to cart."
797
  msgstr ""
798
 
799
- #: includes/discount-base.php:1139
800
  msgid ""
801
  "Provide a specific product free when purchasing another product."
802
  "<br><br>Instead of automatically adding, if you wish to choose the free "
@@ -804,7 +887,7 @@ msgid ""
804
  "discounted only when the user manually adds the product to cart."
805
  msgstr ""
806
 
807
- #: includes/discount-base.php:1140
808
  msgid ""
809
  "Used to provide BOGO discount within categories.<br><br>Example 1: Buy 2 "
810
  "from Category A and get 1 free from the same Category A.<br>Example 2: Buy "
@@ -812,13 +895,13 @@ msgid ""
812
  "B."
813
  msgstr ""
814
 
815
- #: includes/discount-base.php:1141
816
  msgid ""
817
  "This allows you to offer the cheapest product in cart for free (or at a "
818
  "limited percentage like 50%)"
819
  msgstr ""
820
 
821
- #: includes/discount-base.php:1142
822
  #, php-format
823
  msgid ""
824
  "<span class=\"wdr_desc_text\">Useful for providing a discount on store wide "
@@ -826,7 +909,7 @@ msgid ""
826
  "\">Read docs</a>.</span>"
827
  msgstr ""
828
 
829
- #: includes/discount-base.php:1143
830
  #, php-format
831
  msgid ""
832
  "<span class=\"wdr_desc_text\">Useful for providing a discount on selected "
@@ -836,7 +919,7 @@ msgid ""
836
  "\">Read docs</a>.</span>"
837
  msgstr ""
838
 
839
- #: includes/discount-base.php:1144
840
  #, php-format
841
  msgid ""
842
  "<span class=\"wdr_desc_text\">Useful for providing a discount on a specific "
@@ -845,7 +928,7 @@ msgid ""
845
  "<a href=\"%s\">Read docs</a>.</span>"
846
  msgstr ""
847
 
848
- #: includes/discount-base.php:1145
849
  #, php-format
850
  msgid ""
851
  "<span class=\"wdr_desc_text\">Useful to offer discount based on attributes. "
@@ -854,886 +937,930 @@ msgid ""
854
  "defined in WooCommerce -> Attributes. <a href=\"%s\">Read docs</a>.</span>"
855
  msgstr ""
856
 
857
- #: includes/discount-base.php:1231
858
  #, php-format
859
  msgid ""
860
  "Sorry, it is not possible to apply coupon <b>\"%s\"</b> as you already have "
861
  "a discount applied in cart."
862
  msgstr ""
863
 
864
- #: includes/discount-base.php:1286 view/includes/menu.php:13
 
 
865
  msgid "Settings"
866
  msgstr ""
867
 
868
- #: includes/pricing-rules.php:3204 view/view-pricing-rules.php:642
869
  msgid "Buy"
870
  msgstr ""
871
 
872
- #: includes/pricing-rules.php:3208
873
  msgid " less than or equal to "
874
  msgstr ""
875
 
876
- #: includes/pricing-rules.php:3208 includes/pricing-rules.php:3214
877
  msgid " Quantity"
878
  msgstr ""
879
 
880
- #: includes/pricing-rules.php:3211
881
  msgid " Quantity "
882
  msgstr ""
883
 
884
- #: includes/pricing-rules.php:3218
885
  msgid " or more Quantity"
886
  msgstr ""
887
 
888
- #: includes/pricing-rules.php:3227
889
  msgid " any "
890
  msgstr ""
891
 
892
- #: includes/pricing-rules.php:3227
893
  msgid " products from "
894
  msgstr ""
895
 
896
- #: includes/pricing-rules.php:3234
897
  msgid " in each products"
898
  msgstr ""
899
 
900
- #: includes/pricing-rules.php:3246
901
  msgid " and get discount on "
902
  msgstr ""
903
 
904
- #: includes/pricing-rules.php:3249
905
  msgid " first "
906
  msgstr ""
907
 
908
- #: includes/pricing-rules.php:3251 includes/pricing-rules.php:3255
909
  msgid " quantity of product(s) - "
910
  msgstr ""
911
 
912
- #: includes/pricing-rules.php:3253
913
  msgid " after first "
914
  msgstr ""
915
 
916
- #: includes/pricing-rules.php:3271
917
  msgid "Category(ies) "
918
  msgstr ""
919
 
920
- #: includes/pricing-rules.php:3342
921
  msgid "Get "
922
  msgstr ""
923
 
924
- #: includes/pricing-rules.php:3344
925
  #, php-format
926
  msgid "% discount in "
927
  msgstr ""
928
 
929
- #: includes/pricing-rules.php:3347
930
  msgid "same product"
931
  msgstr ""
932
 
933
- #: includes/pricing-rules.php:3349
934
  msgid "any cheapest one from cart"
935
  msgstr ""
936
 
937
- #: includes/pricing-rules.php:3352
938
  msgid "any cheapest one of "
939
  msgstr ""
940
 
941
- #: includes/pricing-rules.php:3357
942
  msgid " quantity of any "
943
  msgstr ""
944
 
945
- #: includes/pricing-rules.php:3359
946
  msgid " cheapest item "
947
  msgstr ""
948
 
949
- #: includes/pricing-rules.php:3362
950
  msgid " quantity of cheapest item "
951
  msgstr ""
952
 
953
- #: includes/pricing-rules.php:3366
954
  msgid "from the category "
955
  msgstr ""
956
 
957
- #: includes/pricing-rules.php:3388
958
  #, php-format
959
  msgid "%s for %s Quantity(s)"
960
  msgstr ""
961
 
962
- #: includes/pricing-rules.php:3390
963
  #, php-format
964
  msgid "%s as price per unit"
965
  msgstr ""
966
 
967
- #: includes/survey.php:82
968
  msgid "Please select an option"
969
  msgstr ""
970
 
971
- #: includes/survey.php:85
972
  msgid "Sending Feedback"
973
  msgstr ""
974
 
975
- #: includes/survey.php:239
976
  msgid "Upgrading to PRO."
977
  msgstr ""
978
 
979
- #: includes/survey.php:243
980
  msgid "I am switching to a different discount plugin."
981
  msgstr ""
982
 
983
- #: includes/survey.php:247
984
  msgid "I could not get my discount rule to work."
985
  msgstr ""
986
 
987
- #: includes/survey.php:251
988
  msgid "It does not meet my discount requirements."
989
  msgstr ""
990
 
991
- #: includes/survey.php:255
992
  msgid "Plugin is complex."
993
  msgstr ""
994
 
995
- #: includes/survey.php:259
996
  msgid "I'm trying to troubleshoot the plugin."
997
  msgstr ""
998
 
999
- #: includes/survey.php:263
1000
  msgid "I was instructed to deactivate by Flycart Support."
1001
  msgstr ""
1002
 
1003
- #: includes/survey.php:267
1004
  msgid "I no longer use this plugin."
1005
  msgstr ""
1006
 
1007
- #: includes/survey.php:271
1008
  msgid "It's a temporary deactivation."
1009
  msgstr ""
1010
 
1011
- #: includes/survey.php:275
1012
  msgid "Other"
1013
  msgstr ""
1014
 
1015
- #: includes/survey.php:277
1016
  msgid "Please share the reason"
1017
  msgstr ""
1018
 
1019
- #: includes/survey.php:287
1020
  msgid "Quick Feedback"
1021
  msgstr ""
1022
 
1023
- #: includes/survey.php:288
1024
  msgid "Close"
1025
  msgstr ""
1026
 
1027
- #: includes/survey.php:296
1028
  #, php-format
1029
  msgid "If you have a moment, please share why you are deactivating %s:"
1030
  msgstr ""
1031
 
1032
- #: includes/survey.php:297
1033
  msgid "Discount Rules for WooCommerce"
1034
  msgstr ""
1035
 
1036
- #: includes/survey.php:325
1037
  msgid "Submit & Deactivate"
1038
  msgstr ""
1039
 
1040
- #: includes/survey.php:327
1041
  msgid "Skip & Deactivate"
1042
  msgstr ""
1043
 
1044
- #: view/cart-rules.php:48
1045
  msgid "Cart Rules"
1046
  msgstr ""
1047
 
1048
- #: view/cart-rules.php:52 view/pricing-rules.php:84
 
1049
  msgid "View Examples"
1050
  msgstr ""
1051
 
1052
- #: view/cart-rules.php:53 view/documentation.php:21 view/pricing-rules.php:85
 
 
1053
  msgid "Documentation"
1054
  msgstr ""
1055
 
1056
- #: view/cart-rules.php:63 view/pricing-rules.php:95
1057
  msgid "You Reach Max. Rule Limit"
1058
  msgstr ""
1059
 
1060
- #: view/cart-rules.php:68 view/pricing-rules.php:99
 
1061
  msgid "Add New Rule"
1062
  msgstr ""
1063
 
1064
- #: view/cart-rules.php:79 view/pricing-rules.php:109
 
1065
  msgid "Bulk Actions"
1066
  msgstr ""
1067
 
1068
- #: view/cart-rules.php:80 view/pricing-rules.php:110
1069
  msgid "Enable rules"
1070
  msgstr ""
1071
 
1072
- #: view/cart-rules.php:81 view/pricing-rules.php:111
1073
  msgid "Disable rules"
1074
  msgstr ""
1075
 
1076
- #: view/cart-rules.php:82 view/pricing-rules.php:112
1077
  msgid "Delete rules"
1078
  msgstr ""
1079
 
1080
- #: view/cart-rules.php:84 view/pricing-rules.php:114
 
1081
  msgid "Apply"
1082
  msgstr ""
1083
 
1084
- #: view/cart-rules.php:98 view/cart-rules.php:208 view/pricing-rules.php:128
1085
- #: view/pricing-rules.php:238 view/template/discount-table.php:36
 
1086
  msgid "Name"
1087
  msgstr ""
1088
 
1089
- #: view/cart-rules.php:99 view/cart-rules.php:209 view/pricing-rules.php:129
1090
- #: view/pricing-rules.php:239
 
 
1091
  msgid "Start Date"
1092
  msgstr ""
1093
 
1094
- #: view/cart-rules.php:100 view/cart-rules.php:210 view/pricing-rules.php:130
1095
- #: view/pricing-rules.php:240
 
 
1096
  msgid "Expired On"
1097
  msgstr ""
1098
 
1099
- #: view/cart-rules.php:101 view/cart-rules.php:211 view/pricing-rules.php:131
1100
- #: view/pricing-rules.php:241
 
 
1101
  msgid "Status"
1102
  msgstr ""
1103
 
1104
- #: view/cart-rules.php:104 view/cart-rules.php:214 view/pricing-rules.php:134
1105
- #: view/pricing-rules.php:244
 
1106
  msgid "Language"
1107
  msgstr ""
1108
 
1109
- #: view/cart-rules.php:109 view/cart-rules.php:219 view/pricing-rules.php:139
1110
- #: view/pricing-rules.php:249
1111
  msgid "Order"
1112
  msgstr ""
1113
 
1114
- #: view/cart-rules.php:181 view/pricing-rules.php:211
 
1115
  msgid "Edit"
1116
  msgstr ""
1117
 
1118
- #: view/cart-rules.php:192 view/pricing-rules.php:222
 
 
1119
  msgid "Delete"
1120
  msgstr ""
1121
 
1122
- #: view/documentation.php:28
1123
  msgid "Installation and Intro:"
1124
  msgstr ""
1125
 
1126
- #: view/documentation.php:30
1127
  msgid "Getting started"
1128
  msgstr ""
1129
 
1130
- #: view/documentation.php:30
1131
  msgid "Welcome onboard"
1132
  msgstr ""
1133
 
1134
- #: view/documentation.php:33
1135
  msgid "License Key activation"
1136
  msgstr ""
1137
 
1138
- #: view/documentation.php:33
1139
  msgid "Learn how to obtain the license key and activate it"
1140
  msgstr ""
1141
 
1142
- #: view/documentation.php:36
1143
  msgid "Version Updates!"
1144
  msgstr ""
1145
 
1146
- #: view/documentation.php:36
1147
  msgid "Learn how to update to latest versions"
1148
  msgstr ""
1149
 
1150
- #: view/documentation.php:39
1151
  msgid "Popular Discount Rules"
1152
  msgstr ""
1153
 
1154
- #: view/documentation.php:39
1155
  msgid "What type of discount scenarios are most commonly used"
1156
  msgstr ""
1157
 
1158
- #: view/documentation.php:43
1159
  msgid "Price rules/BOGO discounts:"
1160
  msgstr ""
1161
 
1162
- #: view/documentation.php:45
1163
  msgid "Bulk/Tiered pricing discounts"
1164
  msgstr ""
1165
 
1166
- #: view/documentation.php:45
1167
  msgid "Learn how to create bulk/tiered quantity discounts in WooCommerce"
1168
  msgstr ""
1169
 
1170
- #: view/documentation.php:48
1171
  msgid "How to create a perfect BOGO discount rule in WooCommerce"
1172
  msgstr ""
1173
 
1174
- #: view/documentation.php:48
1175
  msgid ""
1176
  "Buy One Get One deals can be simple to complex. Learn how to get them "
1177
  "working correct in your online store"
1178
  msgstr ""
1179
 
1180
- #: view/documentation.php:51
1181
  msgid "User Role based discount rules"
1182
  msgstr ""
1183
 
1184
- #: view/documentation.php:51
1185
  msgid ""
1186
  "Learn how to create user role based / customer group based discount in "
1187
  "WooCommerce"
1188
  msgstr ""
1189
 
1190
- #: view/documentation.php:54
1191
  msgid "Purchase History Based Discount"
1192
  msgstr ""
1193
 
1194
- #: view/documentation.php:54
1195
  msgid ""
1196
  "Price Rule and Cart Rule which gives discount based on the purchase history"
1197
  msgstr ""
1198
 
1199
- #: view/documentation.php:57
1200
  msgid "Coupon code based discounts"
1201
  msgstr ""
1202
 
1203
- #: view/documentation.php:57
1204
  msgid ""
1205
  "Apply the dynamic discount rules after the customer enters a valid coupon "
1206
  "code"
1207
  msgstr ""
1208
 
1209
- #: view/documentation.php:61
1210
  msgid "Cart Based Rules:"
1211
  msgstr ""
1212
 
1213
- #: view/documentation.php:63
1214
  msgid "Learn how to create a free shipping cart based rule"
1215
  msgstr ""
1216
 
1217
- #: view/documentation.php:66
1218
  msgid "Subtotal based - Tiered discounts"
1219
  msgstr ""
1220
 
1221
- #: view/documentation.php:66
1222
  msgid "Learn how to create tiered discount based on the subtotal value"
1223
  msgstr ""
1224
 
1225
- #: view/documentation.php:69
1226
  msgid "Free product discount"
1227
  msgstr ""
1228
 
1229
- #: view/documentation.php:69
1230
  msgid ""
1231
  "How to provide a automatic adding free product in cart under certain "
1232
  "conditions"
1233
  msgstr ""
1234
 
1235
- #: view/documentation.php:72
1236
  msgid "Category Combination"
1237
  msgstr ""
1238
 
1239
- #: view/documentation.php:72
1240
  msgid ""
1241
  "Category Combination (get discount only when Category A+ B + C are in the "
1242
  "cart)"
1243
  msgstr ""
1244
 
1245
- #: view/includes/cart-menu.php:9 view/includes/sub-menu.php:9
1246
- #: view/settings.php:38 view/view-cart-rules.php:65
1247
- #: view/view-pricing-rules.php:47
1248
  msgid "General"
1249
  msgstr ""
1250
 
1251
- #: view/includes/cart-menu.php:11
1252
  msgid "Conditions"
1253
  msgstr ""
1254
 
1255
- #: view/includes/cart-menu.php:13 view/includes/sub-menu.php:13
1256
- #: view/template/discount-table.php:42 view/view-cart-rules.php:756
1257
- #: view/view-pricing-rules.php:708
 
 
1258
  msgid "Discount"
1259
  msgstr ""
1260
 
1261
- #: view/includes/footer.php:7
1262
  msgid ""
1263
  "Having trouble in setting up the discount? Let us set up the rules for you "
1264
  "(for free)!"
1265
  msgstr ""
1266
 
1267
- #: view/includes/footer.php:7
1268
  msgid "Please contact our support team"
1269
  msgstr ""
1270
 
1271
- #: view/includes/header.php:14
1272
  #, php-format
1273
  msgid ""
1274
  "An another discount plugin %s is active. Please disable this plugin, Woo "
1275
  "Discount Rules might get conflict."
1276
  msgstr ""
1277
 
1278
- #: view/includes/menu.php:9
1279
  msgid "Price Discount Rules"
1280
  msgstr ""
1281
 
1282
- #: view/includes/menu.php:11
1283
  msgid "Cart Discount Rules"
1284
  msgstr ""
1285
 
1286
- #: view/includes/menu.php:17
1287
  msgid "Taxonomy Settings"
1288
  msgstr ""
1289
 
1290
- #: view/includes/menu.php:19
1291
  msgid "Read documentation"
1292
  msgstr ""
1293
 
1294
- #: view/includes/sub-menu.php:11
1295
  msgid "Condition"
1296
  msgstr ""
1297
 
1298
- #: view/pricing-rules.php:80
1299
  msgid "Price Rules"
1300
  msgstr ""
1301
 
1302
- #: view/settings.php:39
1303
  msgid "Price rules"
1304
  msgstr ""
1305
 
1306
- #: view/settings.php:40
1307
  msgid "Cart rules"
1308
  msgstr ""
1309
 
1310
- #: view/settings.php:41
1311
  msgid "Performance"
1312
  msgstr ""
1313
 
1314
- #: view/settings.php:42
1315
  msgid "Promotion"
1316
  msgstr ""
1317
 
1318
- #: view/settings_cart_rules.php:8
1319
  msgid "Cart rules settings"
1320
  msgstr ""
1321
 
1322
- #: view/settings_cart_rules.php:15
1323
  msgid "Discount identifier in the backend"
1324
  msgstr ""
1325
 
1326
- #: view/settings_cart_rules.php:21
1327
  msgid "Discount Coupon Name"
1328
  msgstr ""
1329
 
1330
- #: view/settings_cart_rules.php:31
1331
  msgid "Coupon name to be used in the cart/checkout in the storefront"
1332
  msgstr ""
1333
 
1334
- #: view/settings_cart_rules.php:35
1335
  msgid "Discounts applied: {rule_name}"
1336
  msgstr ""
1337
 
1338
- #: view/settings_cart_rules.php:38
1339
  msgid ""
1340
  "- Rule name. If more than one rule applies in cart, then the rule names will "
1341
  "be shown separated by comma(,)"
1342
  msgstr ""
1343
 
1344
- #: view/settings_cart_rules.php:42
1345
  msgid "Eg: "
1346
  msgstr ""
1347
 
1348
- #: view/settings_cart_rules.php:53
1349
  msgid "Rule Setup for Cart:"
1350
  msgstr ""
1351
 
1352
- #: view/settings_cart_rules.php:59 view/settings_price_rules.php:32
1353
  msgid "Apply first matched rule"
1354
  msgstr ""
1355
 
1356
- #: view/settings_cart_rules.php:65 view/settings_cart_rules.php:67
1357
- #: view/settings_price_rules.php:38 view/settings_price_rules.php:40
1358
  msgid "Apply all matched rules"
1359
  msgstr ""
1360
 
1361
- #: view/settings_cart_rules.php:74 view/settings_cart_rules.php:76
1362
- #: view/settings_price_rules.php:47 view/settings_price_rules.php:49
1363
  msgid "Apply biggest discount"
1364
  msgstr ""
1365
 
1366
- #: view/settings_cart_rules.php:85
1367
  msgid "Enable free shipping option"
1368
  msgstr ""
1369
 
1370
- #: view/settings_cart_rules.php:92 view/settings_price_rules.php:313
1371
- #: view/view-pricing-rules.php:315 view/view-pricing-rules.php:383
1372
- #: view/view-pricing-rules.php:473 view/view-pricing-rules.php:525
1373
- #: view/view-pricing-rules.php:561
1374
  msgid "Supported in PRO version"
1375
  msgstr ""
1376
 
1377
- #: view/settings_cart_rules.php:105
1378
  msgid "Use Woocommerce free shipping"
1379
  msgstr ""
1380
 
1381
- #: view/settings_cart_rules.php:108
1382
  msgid "Use Woo-Discount free shipping"
1383
  msgstr ""
1384
 
1385
- #: view/settings_cart_rules.php:122
1386
  msgid "Free shipping text to be displayed"
1387
  msgstr ""
1388
 
1389
- #: view/settings_cart_rules.php:129
1390
  msgid "Free Shipping title"
1391
  msgstr ""
1392
 
1393
- #: view/settings_cart_rules.php:136
1394
  msgid "Draft"
1395
  msgstr ""
1396
 
1397
- #: view/settings_cart_rules.php:146
1398
  msgid "Exclude Draft products in product select box."
1399
  msgstr ""
1400
 
1401
- #: view/settings_general.php:6
1402
  msgid "General Settings"
1403
  msgstr ""
1404
 
1405
- #: view/settings_general.php:13
1406
  msgid "License Key :"
1407
  msgstr ""
1408
 
1409
- #: view/settings_general.php:20
1410
  msgid "Your Unique License Key"
1411
  msgstr ""
1412
 
1413
- #: view/settings_general.php:21
1414
  msgid "Validate Key"
1415
  msgstr ""
1416
 
1417
- #: view/settings_general.php:45
1418
  msgid "Tip: Install pro package before validating the licence"
1419
  msgstr ""
1420
 
1421
- #: view/settings_general.php:49
1422
  msgid "Install pro package for validating the licence"
1423
  msgstr ""
1424
 
1425
- #: view/settings_general.php:57
1426
  msgid "Enable dropdowns (applies only for the rule engine in the backend.)"
1427
  msgstr ""
1428
 
1429
- #: view/settings_general.php:62 view/settings_general.php:79
1430
- #: view/settings_general.php:113 view/settings_performance.php:21
1431
- #: view/settings_price_rules.php:86 view/settings_price_rules.php:98
1432
- #: view/settings_price_rules.php:110 view/settings_price_rules.php:151
 
 
 
 
 
 
 
1433
  msgid "Yes"
1434
  msgstr ""
1435
 
1436
- #: view/settings_general.php:63 view/settings_general.php:80
1437
- #: view/settings_general.php:114 view/settings_performance.php:22
1438
- #: view/settings_price_rules.php:87 view/settings_price_rules.php:99
1439
- #: view/settings_price_rules.php:111 view/settings_price_rules.php:152
 
 
 
 
 
 
 
1440
  msgid "No"
1441
  msgstr ""
1442
 
1443
- #: view/settings_general.php:66
1444
  msgid ""
1445
  "Disabling this setting may affect dropdowns in rule engine (Disabling this "
1446
  "setting is not recommended). Change this only if you know what you are doing."
1447
  msgstr ""
1448
 
1449
- #: view/settings_general.php:74
1450
  msgid "Force refresh the cart widget while add and remove item to cart"
1451
  msgstr ""
1452
 
1453
- #: view/settings_general.php:86
1454
  msgid ""
1455
  "Choose how discount rules should work when WooCommerce coupons (or third "
1456
  "party) coupons are used?"
1457
  msgstr ""
1458
 
1459
- #: view/settings_general.php:93
1460
  msgid "Let both coupons and discount rules run together"
1461
  msgstr ""
1462
 
1463
- #: view/settings_general.php:96
1464
  msgid "Disable the discount rules (coupons will work)"
1465
  msgstr ""
1466
 
1467
- #: view/settings_general.php:99
1468
  msgid "Disable the coupons (discount rules will work)"
1469
  msgstr ""
1470
 
1471
- #: view/settings_general.php:108
1472
  msgid ""
1473
  "Hide $0.00 (zero value) of coupon codes in the totals column. Useful when a "
1474
  "coupon used with discount rule conditions"
1475
  msgstr ""
1476
 
1477
- #: view/settings_performance.php:8
1478
  msgid "Performance settings"
1479
  msgstr ""
1480
 
1481
- #: view/settings_performance.php:16
1482
  msgid "Enable cache for variable products table content"
1483
  msgstr ""
1484
 
1485
- #: view/settings_performance.php:28 view/settings_performance.php:32
1486
  msgid "Clear cache"
1487
  msgstr ""
1488
 
1489
- #: view/settings_price_rules.php:8
1490
  msgid "Price rules settings"
1491
  msgstr ""
1492
 
1493
- #: view/settings_price_rules.php:14
1494
  msgid "Rule setup"
1495
  msgstr ""
1496
 
1497
- #: view/settings_price_rules.php:15
1498
  msgid "Display"
1499
  msgstr ""
1500
 
1501
- #: view/settings_price_rules.php:16
1502
  msgid "Offer table"
1503
  msgstr ""
1504
 
1505
- #: view/settings_price_rules.php:17
1506
  msgid "Sale badge"
1507
  msgstr ""
1508
 
1509
- #: view/settings_price_rules.php:26
1510
  msgid "Rule Setup"
1511
  msgstr ""
1512
 
1513
- #: view/settings_price_rules.php:58
1514
  msgid "Apply discount based on"
1515
  msgstr ""
1516
 
1517
- #: view/settings_price_rules.php:65
1518
  msgid "Sale price"
1519
  msgstr ""
1520
 
1521
- #: view/settings_price_rules.php:68
1522
  msgid "Regular price"
1523
  msgstr ""
1524
 
1525
- #: view/settings_price_rules.php:73
1526
  msgid ""
1527
  "If sale price is not entered in your products, the regular price will be "
1528
  "taken"
1529
  msgstr ""
1530
 
1531
- #: view/settings_price_rules.php:81
1532
  msgid ""
1533
  "Auto add free product when coupon is applied (For coupon-activated rules)"
1534
  msgstr ""
1535
 
1536
- #: view/settings_price_rules.php:93
1537
  msgid ""
1538
  "Auto add free product when checkout fields changed (For purchase history "
1539
  "rules)"
1540
  msgstr ""
1541
 
1542
- #: view/settings_price_rules.php:105
1543
  msgid "Include variants when just parent products are chosen in the rules"
1544
  msgstr ""
1545
 
1546
- #: view/settings_price_rules.php:122
1547
  msgid "Show Price discount on product pages :"
1548
  msgstr ""
1549
 
1550
- #: view/settings_price_rules.php:128
 
1551
  msgid "Show when a rule condition is matched"
1552
  msgstr ""
1553
 
1554
- #: view/settings_price_rules.php:131
 
1555
  msgid "Show after a rule condition is matched"
1556
  msgstr ""
1557
 
1558
- #: view/settings_price_rules.php:134
 
1559
  msgid "Shown on quantity update (dynamic)"
1560
  msgstr ""
1561
 
1562
- #: view/settings_price_rules.php:137 view/settings_price_rules.php:211
1563
- #: view/settings_price_rules.php:229 view/settings_price_rules.php:247
1564
- #: view/settings_price_rules.php:265
 
1565
  msgid "Don't Show"
1566
  msgstr ""
1567
 
1568
- #: view/settings_price_rules.php:146
1569
  msgid ""
1570
  "Show a crossed-out original price along with discounted price at line items "
1571
  "in cart"
1572
  msgstr ""
1573
 
1574
- #: view/settings_price_rules.php:163
1575
  msgid "Discount Table :"
1576
  msgstr ""
1577
 
1578
- #: view/settings_price_rules.php:172
1579
  msgid "Default layout"
1580
  msgstr ""
1581
 
1582
- #: view/settings_price_rules.php:175
1583
  msgid "Advance layout"
1584
  msgstr ""
1585
 
1586
- #: view/settings_price_rules.php:184
1587
  msgid "Table placement:"
1588
  msgstr ""
1589
 
1590
- #: view/settings_price_rules.php:190
1591
  msgid "Before cart form"
1592
  msgstr ""
1593
 
1594
- #: view/settings_price_rules.php:193
1595
  msgid "After cart form"
1596
  msgstr ""
1597
 
1598
- #: view/settings_price_rules.php:202
1599
  msgid "Table header :"
1600
  msgstr ""
1601
 
1602
- #: view/settings_price_rules.php:220
1603
  msgid "Title column on table :"
1604
  msgstr ""
1605
 
1606
- #: view/settings_price_rules.php:238
1607
  msgid "Range column on table :"
1608
  msgstr ""
1609
 
1610
- #: view/settings_price_rules.php:256
1611
  msgid "Discount column on table :"
1612
  msgstr ""
1613
 
1614
- #: view/settings_price_rules.php:278
1615
  msgid "Show a Sale badge on product pages :"
1616
  msgstr ""
1617
 
1618
- #: view/settings_price_rules.php:284
 
1619
  msgid "Do not show"
1620
  msgstr ""
1621
 
1622
- #: view/settings_price_rules.php:287
 
1623
  msgid "Show only after a rule condition is matched exactly"
1624
  msgstr ""
1625
 
1626
- #: view/settings_price_rules.php:290
1627
  msgid ""
1628
  "Show on products that are covered under any price based discount rule in the "
1629
  "plugin"
1630
  msgstr ""
1631
 
1632
- #: view/settings_price_rules.php:301
 
1633
  msgid "Do you want to customize the sale badge?"
1634
  msgstr ""
1635
 
1636
- #: view/settings_price_rules.php:308
 
1637
  msgid "Yes, I would like to customize the sale badge"
1638
  msgstr ""
1639
 
1640
- #: view/settings_price_rules.php:310
 
1641
  msgid ""
1642
  "Force override the label for sale badge (useful when your theme has override "
1643
  "for sale badge)."
1644
  msgstr ""
1645
 
1646
- #: view/settings_price_rules.php:325
1647
  msgid "Sale badge content (TIP: You can use HTML inside)"
1648
  msgstr ""
1649
 
1650
- #: view/settings_price_rules.php:332
1651
  msgid ""
1652
  "IMPORTANT NOTE: This customized sale badge will be applicable only for "
1653
  "products that are part of the discount rules configured in this plugin"
1654
  msgstr ""
1655
 
1656
- #: view/settings_price_rules.php:336
1657
  msgid "Eg:"
1658
  msgstr ""
1659
 
1660
- #: view/settings_promotion.php:8
1661
  msgid "Promotion settings"
1662
  msgstr ""
1663
 
1664
- #: view/settings_promotion.php:16
1665
  msgid "Display savings text (for price rules)"
1666
  msgstr ""
1667
 
1668
- #: view/settings_promotion.php:25
1669
  msgid "On each line item"
1670
  msgstr ""
1671
 
1672
- #: view/settings_promotion.php:28
1673
  msgid "On after total"
1674
  msgstr ""
1675
 
1676
- #: view/settings_promotion.php:31
1677
  msgid "Both in line item and after total"
1678
  msgstr ""
1679
 
1680
- #: view/settings_promotion.php:39
1681
  msgid "Savings text to show"
1682
  msgstr ""
1683
 
1684
- #: view/settings_promotion.php:47
1685
  msgid "{{total_discount_price}} -> Total discount applied"
1686
  msgstr ""
1687
 
1688
- #: view/settings_promotion.php:55
1689
  msgid "Show a message on applying price rules in cart"
1690
  msgstr ""
1691
 
1692
- #: view/settings_promotion.php:73 view/settings_promotion.php:108
1693
- #: view/view-cart-rules.php:730
1694
  msgid "Message"
1695
  msgstr ""
1696
 
1697
- #: view/settings_promotion.php:81 view/settings_promotion.php:116
1698
  msgid "{{title}} -> Rule title"
1699
  msgstr ""
1700
 
1701
- #: view/settings_promotion.php:82 view/settings_promotion.php:117
1702
  msgid "{{description}} -> Rule description"
1703
  msgstr ""
1704
 
1705
- #: view/settings_promotion.php:90
1706
  msgid "Show a message on applying cart rules in cart"
1707
  msgstr ""
1708
 
1709
- #: view/settings_promotion.php:125
1710
  msgid ""
1711
  "Subtotal based promo text (available only in cart rules -> subtotal based "
1712
  "discounts)"
1713
  msgstr ""
1714
 
1715
- #: view/settings_promotion.php:134
1716
  msgid "Shop page"
1717
  msgstr ""
1718
 
1719
- #: view/settings_promotion.php:137
1720
  msgid "Product page"
1721
  msgstr ""
1722
 
1723
- #: view/settings_promotion.php:140
1724
  msgid "Cart page"
1725
  msgstr ""
1726
 
1727
- #: view/settings_promotion.php:143
1728
  msgid "Checkout page"
1729
  msgstr ""
1730
 
1731
- #: view/settings_taxonomy.php:32
1732
  msgid ""
1733
  "Choose taxonomies that can be supported in the discount rules (as categories)"
1734
  msgstr ""
1735
 
1736
- #: view/settings_taxonomy.php:36
1737
  msgid ""
1738
  "Useful when you want to provide a taxonomy based discount. The selected "
1739
  "taxonomies here will be available as categories. So you can use the category "
@@ -1741,183 +1868,188 @@ msgid ""
1741
  "More examples can be found in the documentation"
1742
  msgstr ""
1743
 
1744
- #: view/template/discount-table.php:23
1745
  msgid "Hide table"
1746
  msgstr ""
1747
 
1748
- #: view/template/discount-table.php:25
1749
  msgid "This effect displays only for you (Admin)"
1750
  msgstr ""
1751
 
1752
- #: view/template/discount-table.php:39
1753
  msgid "Range"
1754
  msgstr ""
1755
 
1756
- #: view/template/discount-table.php:74
1757
  msgid "No Active Discounts."
1758
  msgstr ""
1759
 
1760
- #: view/template/loop/sale-flash.php:23
1761
- #: view/template/single-product/sale-flash.php:23
 
 
1762
  msgid "Sale!"
1763
  msgstr ""
1764
 
1765
- #: view/template/sidebar.php:7
1766
  msgid "Looking for more features? Upgrade to PRO"
1767
  msgstr ""
1768
 
1769
- #: view/template/sidebar.php:19
1770
  msgid "With PRO version, you can create:"
1771
  msgstr ""
1772
 
1773
- #: view/template/sidebar.php:20
1774
  msgid "- Categories based discounts"
1775
  msgstr ""
1776
 
1777
- #: view/template/sidebar.php:21
1778
  msgid "- User roles based discounts"
1779
  msgstr ""
1780
 
1781
- #: view/template/sidebar.php:22
1782
  msgid "- Buy One Get One Free deals"
1783
  msgstr ""
1784
 
1785
- #: view/template/sidebar.php:23
1786
  msgid "- Buy X Get Y deals"
1787
  msgstr ""
1788
 
1789
- #: view/template/sidebar.php:24
1790
  #, php-format
1791
  msgid "- Buy 2, get 1 at 50% discount"
1792
  msgstr ""
1793
 
1794
- #: view/template/sidebar.php:25
1795
  msgid "- Buy 3 for $10 (Package / Bundle [Set] Discount)"
1796
  msgstr ""
1797
 
1798
- #: view/template/sidebar.php:26
1799
  msgid "- Different discounts with one coupon code"
1800
  msgstr ""
1801
 
1802
- #: view/template/sidebar.php:27
1803
  msgid "- Purchase history based discounts"
1804
  msgstr ""
1805
 
1806
- #: view/template/sidebar.php:28
1807
  msgid "- Free product / gift"
1808
  msgstr ""
1809
 
1810
- #: view/template/sidebar.php:29
1811
  msgid "- Discount for variants"
1812
  msgstr ""
1813
 
1814
- #: view/template/sidebar.php:30
1815
  msgid "- Conditional discounts"
1816
  msgstr ""
1817
 
1818
- #: view/template/sidebar.php:31
1819
  msgid "- Fixed cost discounts"
1820
  msgstr ""
1821
 
1822
- #: view/template/sidebar.php:32
1823
  msgid "- Offer fixed price on certain conditions"
1824
  msgstr ""
1825
 
1826
- #: view/view-cart-rules.php:56 view/view-pricing-rules.php:38
1827
  msgid "Close and go back to list"
1828
  msgstr ""
1829
 
1830
- #: view/view-cart-rules.php:60
1831
  msgid "New Cart Rule"
1832
  msgstr ""
1833
 
1834
- #: view/view-cart-rules.php:62
1835
  msgid "Edit Cart Rule"
1836
  msgstr ""
1837
 
1838
- #: view/view-cart-rules.php:75 view/view-pricing-rules.php:57
 
 
1839
  msgid "This rule is not running currently: "
1840
  msgstr ""
1841
 
1842
- #: view/view-cart-rules.php:84 view/view-pricing-rules.php:66
1843
  msgid "Priority :"
1844
  msgstr ""
1845
 
1846
- #: view/view-cart-rules.php:86
1847
  msgid ""
1848
  "The Simple Ranking concept to said, which one is going to execute first and "
1849
  "so on."
1850
  msgstr ""
1851
 
1852
- #: view/view-cart-rules.php:98 view/view-pricing-rules.php:81
1853
  msgid "Rule Name"
1854
  msgstr ""
1855
 
1856
- #: view/view-cart-rules.php:100 view/view-cart-rules.php:112
1857
- #: view/view-pricing-rules.php:95
1858
  msgid "Rule Descriptions."
1859
  msgstr ""
1860
 
1861
- #: view/view-cart-rules.php:105 view/view-pricing-rules.php:89
1862
  msgid "ex. Standard Rule."
1863
  msgstr ""
1864
 
1865
- #: view/view-cart-rules.php:110 view/view-pricing-rules.php:94
1866
  msgid "Rule Description"
1867
  msgstr ""
1868
 
1869
- #: view/view-cart-rules.php:121 view/view-pricing-rules.php:130
1870
  msgid "Validity"
1871
  msgstr ""
1872
 
1873
- #: view/view-cart-rules.php:122 view/view-pricing-rules.php:131
1874
  msgid "Period of Rule Active. Format: month/day/Year Hour:Min"
1875
  msgstr ""
1876
 
1877
- #: view/view-cart-rules.php:135 view/view-pricing-rules.php:144
1878
- #: view/view-pricing-rules.php:652
1879
  msgid "From"
1880
  msgstr ""
1881
 
1882
- #: view/view-cart-rules.php:139
1883
  msgid "To"
1884
  msgstr ""
1885
 
1886
- #: view/view-cart-rules.php:140 view/view-pricing-rules.php:149
 
1887
  #, php-format
1888
  msgid "Current date and time: %s"
1889
  msgstr ""
1890
 
1891
- #: view/view-cart-rules.php:145 view/view-cart-rules.php:750
1892
- #: view/view-pricing-rules.php:183 view/view-pricing-rules.php:701
1893
  msgid "Next"
1894
  msgstr ""
1895
 
1896
- #: view/view-cart-rules.php:149
1897
  msgid "Cart Conditions"
1898
  msgstr ""
1899
 
1900
- #: view/view-cart-rules.php:152
1901
  msgid "Add Condition"
1902
  msgstr ""
1903
 
1904
- #: view/view-cart-rules.php:241
1905
  msgid "Categories In Cart"
1906
  msgstr ""
1907
 
1908
- #: view/view-cart-rules.php:295 view/view-cart-rules.php:297
1909
  msgid "Email with TLD (Eg: edu)"
1910
  msgstr ""
1911
 
1912
- #: view/view-cart-rules.php:713
1913
  msgid "Promotion message"
1914
  msgstr ""
1915
 
1916
- #: view/view-cart-rules.php:718
1917
  msgid "Subtotal from"
1918
  msgstr ""
1919
 
1920
- #: view/view-cart-rules.php:724
1921
  #, php-format
1922
  msgid ""
1923
  "Set a threshold from which you want to start showing the promotion "
@@ -1926,233 +2058,233 @@ msgid ""
1926
  "text when his cart subtotal reaches 900"
1927
  msgstr ""
1928
 
1929
- #: view/view-cart-rules.php:735
1930
  #, php-format
1931
  msgid "Spend {{difference_amount}} more and get 10% discount"
1932
  msgstr ""
1933
 
1934
- #: view/view-cart-rules.php:737
1935
  msgid "{{difference_amount}} -> Difference amount to get discount"
1936
  msgstr ""
1937
 
1938
- #: view/view-cart-rules.php:738
1939
  #, php-format
1940
  msgid "<b>Eg:</b> Spend {{difference_amount}} more and get 10% discount"
1941
  msgstr ""
1942
 
1943
- #: view/view-cart-rules.php:749 view/view-cart-rules.php:846
1944
- #: view/view-pricing-rules.php:700 view/view-pricing-rules.php:1019
1945
  msgid "Previous"
1946
  msgstr ""
1947
 
1948
- #: view/view-cart-rules.php:752
1949
  msgid "Guide to create cart rules"
1950
  msgstr ""
1951
 
1952
- #: view/view-cart-rules.php:772
1953
  msgid "Discount Type :"
1954
  msgstr ""
1955
 
1956
- #: view/view-cart-rules.php:791 view/view-cart-rules.php:793
1957
  msgid "Product Discount"
1958
  msgstr ""
1959
 
1960
- #: view/view-cart-rules.php:800 view/view-cart-rules.php:802
1961
  msgid "Free shipping"
1962
  msgstr ""
1963
 
1964
- #: view/view-cart-rules.php:811
1965
  msgid "value :"
1966
  msgstr ""
1967
 
1968
- #: view/view-cart-rules.php:819
1969
  msgid "Select products :"
1970
  msgstr ""
1971
 
1972
- #: view/view-cart-rules.php:833
1973
  msgid "Quantity :"
1974
  msgstr ""
1975
 
1976
- #: view/view-pricing-rules.php:42
1977
  msgid "New Price Rule"
1978
  msgstr ""
1979
 
1980
- #: view/view-pricing-rules.php:44
1981
  msgid "Edit Price Rule"
1982
  msgstr ""
1983
 
1984
- #: view/view-pricing-rules.php:67
1985
  msgid ""
1986
  "The Simple Ranking concept, which one is going to execute first and so on."
1987
  msgstr ""
1988
 
1989
- #: view/view-pricing-rules.php:82
1990
  msgid "Rule name / title."
1991
  msgstr ""
1992
 
1993
- #: view/view-pricing-rules.php:105
1994
  msgid "Method"
1995
  msgstr ""
1996
 
1997
- #: view/view-pricing-rules.php:106
1998
  msgid "Method to Apply."
1999
  msgstr ""
2000
 
2001
- #: view/view-pricing-rules.php:113
2002
  msgid ""
2003
  "Quantity / category / product / user role based discounts and BOGO deals "
2004
  msgstr ""
2005
 
2006
- #: view/view-pricing-rules.php:120 view/view-pricing-rules.php:122
2007
  msgid "Dependent / conditional based discount (by individual product)"
2008
  msgstr ""
2009
 
2010
- #: view/view-pricing-rules.php:148
2011
  msgid "To - Leave Empty if No Expiry"
2012
  msgstr ""
2013
 
2014
- #: view/view-pricing-rules.php:159
2015
  msgid "Format for advanced table display option (see plugin settings)"
2016
  msgstr ""
2017
 
2018
- #: view/view-pricing-rules.php:161
2019
  msgid "Used when advanced table display option is set in the plugin settings"
2020
  msgstr ""
2021
 
2022
- #: view/view-pricing-rules.php:164
2023
  msgid "Buy {{min_quantity}} or more quantity and get {{discount}} as discount"
2024
  msgstr ""
2025
 
2026
- #: view/view-pricing-rules.php:167
2027
  msgid "{{title}} -> Title"
2028
  msgstr ""
2029
 
2030
- #: view/view-pricing-rules.php:168
2031
  msgid "{{description}} -> Description"
2032
  msgstr ""
2033
 
2034
- #: view/view-pricing-rules.php:169
2035
  msgid "{{min_quantity}} -> Minimum quantity"
2036
  msgstr ""
2037
 
2038
- #: view/view-pricing-rules.php:170
2039
  msgid "{{max_quantity}} -> Maximum quantity"
2040
  msgstr ""
2041
 
2042
- #: view/view-pricing-rules.php:171
2043
  msgid "{{discount}} -> Discount"
2044
  msgstr ""
2045
 
2046
- #: view/view-pricing-rules.php:172
2047
  msgid "{{discounted_price}} -> Discounted price"
2048
  msgstr ""
2049
 
2050
- #: view/view-pricing-rules.php:173
2051
  msgid "{{condition}} -> Rule condition text"
2052
  msgstr ""
2053
 
2054
- #: view/view-pricing-rules.php:188
2055
  msgid "Discount Conditions"
2056
  msgstr ""
2057
 
2058
- #: view/view-pricing-rules.php:193
2059
  msgid "Apply To"
2060
  msgstr ""
2061
 
2062
- #: view/view-pricing-rules.php:202
2063
  msgid "All products"
2064
  msgstr ""
2065
 
2066
- #: view/view-pricing-rules.php:206
2067
  msgid "Specific products"
2068
  msgstr ""
2069
 
2070
- #: view/view-pricing-rules.php:212 view/view-pricing-rules.php:214
2071
  msgid "Specific categories"
2072
  msgstr ""
2073
 
2074
- #: view/view-pricing-rules.php:221 view/view-pricing-rules.php:223
2075
  msgid "Specific attributes"
2076
  msgstr ""
2077
 
2078
- #: view/view-pricing-rules.php:234
2079
  msgid ""
2080
  "Check this box to count item quantities in cart cumulatively across products"
2081
  msgstr ""
2082
 
2083
- #: view/view-pricing-rules.php:246
2084
  msgid "Check this box to count quantities cumulatively across category(ies)"
2085
  msgstr ""
2086
 
2087
- #: view/view-pricing-rules.php:249
2088
  msgid "Check this box to apply child category(ies)"
2089
  msgstr ""
2090
 
2091
- #: view/view-pricing-rules.php:263
2092
  msgid "Check this box to count quantities cumulatively across attribute"
2093
  msgstr ""
2094
 
2095
- #: view/view-pricing-rules.php:276
2096
  #, php-format
2097
  msgid ""
2098
  "Use this option to exclude selected products from getting a discount. <a "
2099
  "href=\"%s\">Read docs</a>."
2100
  msgstr ""
2101
 
2102
- #: view/view-pricing-rules.php:298
2103
  msgid "Exclude sale items"
2104
  msgstr ""
2105
 
2106
- #: view/view-pricing-rules.php:301
2107
  msgid ""
2108
  "Tick this checkbox if you wish to exclude products that already have a sale "
2109
  "price set via WooCommerce."
2110
  msgstr ""
2111
 
2112
- #: view/view-pricing-rules.php:309
2113
  msgid "Check this box if the rule should not apply to items on sale."
2114
  msgstr ""
2115
 
2116
- #: view/view-pricing-rules.php:328
2117
  msgid "Customers"
2118
  msgstr ""
2119
 
2120
- #: view/view-pricing-rules.php:331
2121
  #, php-format
2122
  msgid ""
2123
  "Use this option to apply the rule for specific customers. <a href=\"%s"
2124
  "\">Read docs</a>."
2125
  msgstr ""
2126
 
2127
- #: view/view-pricing-rules.php:339 view/view-pricing-rules.php:673
2128
  msgid "All"
2129
  msgstr ""
2130
 
2131
- #: view/view-pricing-rules.php:346 view/view-pricing-rules.php:348
2132
  msgid "Only Given"
2133
  msgstr ""
2134
 
2135
- #: view/view-pricing-rules.php:362
2136
  msgid "User roles"
2137
  msgstr ""
2138
 
2139
- #: view/view-pricing-rules.php:365
2140
  #, php-format
2141
  msgid ""
2142
  "Use this option to set a discount based on user roles. <a href=\"%s\">Read "
2143
  "docs</a>."
2144
  msgstr ""
2145
 
2146
- #: view/view-pricing-rules.php:373 view/view-pricing-rules.php:409
2147
- #: view/view-pricing-rules.php:500 view/view-pricing-rules.php:549
2148
  msgid "Do not use"
2149
  msgstr ""
2150
 
2151
- #: view/view-pricing-rules.php:394
2152
  msgid "Coupon"
2153
  msgstr ""
2154
 
2155
- #: view/view-pricing-rules.php:397
2156
  #, php-format
2157
  msgid ""
2158
  "Useful if you wish to activate this discount rule via coupon code.<br>You "
@@ -2160,23 +2292,23 @@ msgid ""
2160
  "WooCommerce -> Coupons. <a href=\"%s\">Read docs</a>."
2161
  msgstr ""
2162
 
2163
- #: view/view-pricing-rules.php:411
2164
  msgid "Apply if any one coupon applied (Select from WooCommerce)"
2165
  msgstr ""
2166
 
2167
- #: view/view-pricing-rules.php:412
2168
  msgid "Apply if all coupon applied (Select from WooCommerce)"
2169
  msgstr ""
2170
 
2171
- #: view/view-pricing-rules.php:463
2172
  msgid "Make sure you have created the coupon already"
2173
  msgstr ""
2174
 
2175
- #: view/view-pricing-rules.php:484
2176
  msgid "Subtotal"
2177
  msgstr ""
2178
 
2179
- #: view/view-pricing-rules.php:487
2180
  #, php-format
2181
  msgid ""
2182
  "Useful when you want to limit the rule based on subtotal. (Use this only "
@@ -2185,19 +2317,19 @@ msgid ""
2185
  "discount rules."
2186
  msgstr ""
2187
 
2188
- #: view/view-pricing-rules.php:501
2189
  msgid "Subtotal atleast"
2190
  msgstr ""
2191
 
2192
- #: view/view-pricing-rules.php:506
2193
  msgid "Enter the amount"
2194
  msgstr ""
2195
 
2196
- #: view/view-pricing-rules.php:516
2197
  msgid "Supported in WooCommerce 3.x"
2198
  msgstr ""
2199
 
2200
- #: view/view-pricing-rules.php:539
2201
  #, php-format
2202
  msgid ""
2203
  "Useful for providing discounts based on previous purchase history."
@@ -2205,90 +2337,90 @@ msgid ""
2205
  "spent so far. <a href=\"%s\">Read docs</a>."
2206
  msgstr ""
2207
 
2208
- #: view/view-pricing-rules.php:644
2209
  msgid "Any"
2210
  msgstr ""
2211
 
2212
- #: view/view-pricing-rules.php:645
2213
  msgid "Each"
2214
  msgstr ""
2215
 
2216
- #: view/view-pricing-rules.php:646
2217
  msgid "Combine"
2218
  msgstr ""
2219
 
2220
- #: view/view-pricing-rules.php:649
2221
  msgid "More than or equal to"
2222
  msgstr ""
2223
 
2224
- #: view/view-pricing-rules.php:651
2225
  msgid "Equal"
2226
  msgstr ""
2227
 
2228
- #: view/view-pricing-rules.php:656
2229
  msgid "to"
2230
  msgstr ""
2231
 
2232
- #: view/view-pricing-rules.php:660
2233
  msgid "Product(s) from"
2234
  msgstr ""
2235
 
2236
- #: view/view-pricing-rules.php:666
2237
  msgid "Apply discount in product(s)"
2238
  msgstr ""
2239
 
2240
- #: view/view-pricing-rules.php:667
2241
  msgid "Apply discount in category(ies)"
2242
  msgstr ""
2243
 
2244
- #: view/view-pricing-rules.php:671
2245
  msgid "and get discount on "
2246
  msgstr ""
2247
 
2248
- #: view/view-pricing-rules.php:674
2249
  msgid "First quantity(s)"
2250
  msgstr ""
2251
 
2252
- #: view/view-pricing-rules.php:675
2253
  msgid "Skip first quantity(s)"
2254
  msgstr ""
2255
 
2256
- #: view/view-pricing-rules.php:680
2257
  msgid " Product(s) "
2258
  msgstr ""
2259
 
2260
- #: view/view-pricing-rules.php:684
2261
  msgid "Category(ies)"
2262
  msgstr ""
2263
 
2264
- #: view/view-pricing-rules.php:695
2265
  msgid "Guide for product dependent rules"
2266
  msgstr ""
2267
 
2268
- #: view/view-pricing-rules.php:711
2269
  msgid "Add quantity ranges"
2270
  msgstr ""
2271
 
2272
- #: view/view-pricing-rules.php:716
2273
  msgid ""
2274
  "Bundle (Set) Discount should NOT be mixed with any other adjustment types "
2275
  "when adding ranges. Example: If your first range's adjustment type is Bundle "
2276
  "(Set) Discount, other ranges should also be same type."
2277
  msgstr ""
2278
 
2279
- #: view/view-pricing-rules.php:886
2280
  msgid "Cheapest in cart - selected category(ies)"
2281
  msgstr ""
2282
 
2283
- #: view/view-pricing-rules.php:887
2284
  msgid "Cheapest in cart - selected item(s)"
2285
  msgstr ""
2286
 
2287
- #: view/view-pricing-rules.php:888
2288
  msgid "Cheapest among all items in cart"
2289
  msgstr ""
2290
 
2291
- #: view/view-pricing-rules.php:985
2292
  msgid ""
2293
  "<b>Example for Bundle (Set) Discount:</b> 3 for $10, 6 for $20<br>So "
2294
  "customer can add 3 products / quantities and get them for $10<br><b>NOTE:</"
@@ -2296,11 +2428,11 @@ msgid ""
2296
  "the 3 for $10 deal)"
2297
  msgstr ""
2298
 
2299
- #: view/view-pricing-rules.php:987 view/view-pricing-rules.php:997
2300
  msgid "Read docs"
2301
  msgstr ""
2302
 
2303
- #: view/view-pricing-rules.php:995
2304
  msgid ""
2305
  "<b>Example for Fixed Price Per Unit:</b> Product A cost is $20. If customers "
2306
  "buy 5 to 10, they can get at $15 each (per unit).<br>Customer adds 6 "
@@ -2308,14 +2440,1686 @@ msgid ""
2308
  "b> Enter the Unit price like 15"
2309
  msgstr ""
2310
 
2311
- #: view/view-pricing-rules.php:1002
2312
  msgid "Guide to create perfect BOGO rules"
2313
  msgstr ""
2314
 
2315
- #: view/view-pricing-rules.php:1012
2316
  msgid "Percent"
2317
  msgstr ""
2318
 
2319
- #: view/view-pricing-rules.php:1013
2320
  msgid "Fixed"
2321
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  "X-Generator: Loco https://localise.biz/\n"
14
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;"
15
 
16
+ #: common.php:8
17
+ msgid "Invalid request"
18
+ msgstr ""
19
+
20
+ #: common.php:26
21
+ msgid ""
22
+ "Please download and install the PRO package with advanced rules for V2 and "
23
+ "then switch it. <a href=\"https://docs.flycart.org/en/collections/2195266?"
24
+ "utm_source=woo-discount-rules-v2&utm_campaign=doc&utm_medium=text-"
25
+ "click&utm_content=documentation\" target=\"_blank\">Here</a> is a guide for "
26
+ "Switching to Advanced V2 Interface"
27
+ msgstr ""
28
+
29
+ #: common.php:46
30
+ msgid ""
31
+ "Switch to Discount Rules 2.0 with Advanced Rules (you can switch back any "
32
+ "time)"
33
+ msgstr ""
34
+
35
+ #: common.php:47
36
+ msgid ""
37
+ "Switch to 2.0 <span style='background-color: #FF8C00 ; padding: 3px; border-"
38
+ "radius: 4px'>Public beta</span>"
39
+ msgstr ""
40
+
41
+ #: common.php:50
42
+ msgid "Would you like to switch to older Woo Discount Rules?"
43
+ msgstr ""
44
+
45
+ #: common.php:51
46
+ msgid "Click here to Switch back"
47
+ msgstr ""
48
+
49
+ #: common.php:71
50
+ msgid "Switch back to Discount Rules 1.x"
51
+ msgstr ""
52
+
53
+ #: common.php:158
54
+ msgid ""
55
+ "This plugin can not be activated because it requires minimum PHP version of "
56
+ msgstr ""
57
+
58
+ #: common.php:161
59
+ msgid ""
60
+ "Woocommerce must installed and activated in-order to use Advanced woo "
61
+ "discount rules!"
62
+ msgstr ""
63
+
64
+ #: common.php:164
65
+ msgid " Advanced woo discount rules requires at least Woocommerce"
66
+ msgstr ""
67
+
68
+ #: updater.php:68 updater.php:217 v1/helper/purchase.php:62
69
+ #: v1/helper/purchase.php:66 v1/helper/purchase.php:134
70
+ #: v1/helper/purchase.php:137 v1/helper/purchase.php:173
71
+ msgid "Please enter a valid license key"
72
+ msgstr ""
73
+
74
+ #: updater.php:71 v1/helper/purchase.php:182
75
+ msgid "License key check : Passed."
76
+ msgstr ""
77
+
78
+ #: updater.php:73 v1/helper/purchase.php:186 v1/view/settings_general.php:32
79
+ msgid "License key seems to be Invalid. Please enter a valid license key"
80
+ msgstr ""
81
+
82
+ #: updater.php:218 v1/helper/purchase.php:62 v1/helper/purchase.php:66
83
+ #: v1/helper/purchase.php:134 v1/helper/purchase.php:137
84
+ msgid "our website"
85
+ msgstr ""
86
+
87
+ #: updater.php:222
88
+ #, php-format
89
+ msgid "License key for the %s seems invalid. %s, you can get it from %s"
90
+ msgstr ""
91
+
92
+ #: updater.php:226
93
+ #, php-format
94
+ msgid "License key for the %s is not entered. %s, you can get it from %s"
95
+ msgstr ""
96
+
97
+ #: v1/helper/general-helper.php:48 v2/App/Controllers/Admin/Settings.php:293
98
  msgid "Guest"
99
  msgstr ""
100
 
101
+ #: v1/helper/general-helper.php:617
102
  msgid "Start date and time is set in the future date"
103
  msgstr ""
104
 
105
+ #: v1/helper/general-helper.php:620
106
  msgid "Validity expired"
107
  msgstr ""
108
 
109
+ #: v1/helper/general-helper.php:637
110
  msgid "Will run in future"
111
  msgstr ""
112
 
113
+ #: v1/helper/general-helper.php:640
114
  msgid "Not running - validity expired"
115
  msgstr ""
116
 
117
+ #: v1/helper/general-helper.php:657
118
  msgid "Running"
119
  msgstr ""
120
 
121
+ #: v1/helper/general-helper.php:662
122
  msgid "Your server current date and time: "
123
  msgstr ""
124
 
125
+ #: v1/helper/general-helper.php:797
126
  msgid "Read Docs"
127
  msgstr ""
128
 
129
+ #: v1/helper/general-helper.php:1034 v1/view/view-cart-rules.php:697
130
+ #: v1/view/view-pricing-rules.php:433 v2/App/Helpers/Woocommerce.php:1448
131
  msgid "Coupon already exists in WooCommerce. Please select another name"
132
  msgstr ""
133
 
134
+ #: v1/helper/purchase.php:25 v1/view/includes/cart-menu.php:5
135
+ #: v1/view/includes/menu.php:6 v1/view/includes/sub-menu.php:5
136
+ #: v2/App/Controllers/Admin/Settings.php:36
137
+ #: v2/App/Controllers/Admin/Settings.php:37
138
  msgid "Woo Discount Rules"
139
  msgstr ""
140
 
141
+ #: v1/helper/purchase.php:62 v1/helper/purchase.php:134
142
  msgid "The license key for "
143
  msgstr ""
144
 
145
+ #: v1/helper/purchase.php:62 v1/helper/purchase.php:134
146
  msgid "seems invalid."
147
  msgstr ""
148
 
149
+ #: v1/helper/purchase.php:62 v1/helper/purchase.php:66
150
+ #: v1/helper/purchase.php:134 v1/helper/purchase.php:137
 
 
 
 
 
151
  msgid "You can get it from"
152
  msgstr ""
153
 
154
+ #: v1/helper/purchase.php:66 v1/helper/purchase.php:137
 
 
 
 
 
155
  msgid "License key for the "
156
  msgstr ""
157
 
158
+ #: v1/helper/purchase.php:66 v1/helper/purchase.php:137
159
  msgid "is not entered."
160
  msgstr ""
161
 
162
+ #: v1/helper/purchase.php:73
163
  msgid ": You are using CORE version. Please Update to PRO version."
164
  msgstr ""
165
 
166
+ #: v1/helper/purchase.php:97
167
  msgid "-PRO-"
168
  msgstr ""
169
 
170
+ #: v1/helper/purchase.php:106
171
  msgid "Pro"
172
  msgstr ""
173
 
174
+ #: v1/helper/purchase.php:108
175
  msgid "Core"
176
  msgstr ""
177
 
178
+ #: v1/helper/woo-function.php:485 v1/helper/woo-function.php:495
 
 
 
 
 
 
 
 
179
  msgid "Search for a product&hellip;"
180
  msgstr ""
181
 
182
+ #: v1/helper/woo-function.php:528 v1/helper/woo-function.php:540
183
  msgid "Search for a user&hellip;"
184
  msgstr ""
185
 
186
+ #: v1/includes/advanced/free_shipping_method.php:16
187
  msgid "WooDiscount Free Shipping"
188
  msgstr ""
189
 
190
+ #: v1/includes/advanced/free_shipping_method.php:17
191
  msgid "Custom Shipping Method for Woocommerce Discount Rules"
192
  msgstr ""
193
 
194
+ #: v1/includes/advanced/free_shipping_method.php:68
195
+ #: v1/view/documentation.php:63 v1/view/settings_cart_rules.php:126
196
  msgid "Free Shipping"
197
  msgstr ""
198
 
199
+ #: v1/includes/advanced/free_shipping_method.php:73
200
+ #: v1/includes/discount-base.php:1063 v1/view/cart-rules.php:133
201
+ #: v1/view/pricing-rules.php:163 v1/view/settings_promotion.php:65
202
+ #: v1/view/settings_promotion.php:100 v2/App/Controllers/Admin/Settings.php:403
203
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:75
204
  msgid "Enable"
205
  msgstr ""
206
 
207
+ #: v1/includes/advanced/free_shipping_method.php:75
208
  msgid "Enable this shipping."
209
  msgstr ""
210
 
211
+ #: v1/includes/advanced/free_shipping_method.php:80
212
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:102
213
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:247
214
  msgid "Title"
215
  msgstr ""
216
 
217
+ #: v1/includes/advanced/free_shipping_method.php:82
218
  msgid "Title to be display on site"
219
  msgstr ""
220
 
221
+ #: v1/includes/cart-rules.php:116 v1/includes/pricing-rules.php:120
222
  msgid "Saved successfully"
223
  msgstr ""
224
 
225
+ #: v1/includes/cart-rules.php:187 v1/includes/pricing-rules.php:153
226
  msgid "Failed to save"
227
  msgstr ""
228
 
229
+ #: v1/includes/discount-base.php:203 v1/view/cart-rules.php:162
230
+ #: v1/view/pricing-rules.php:192 v2/App/Controllers/Admin/Settings.php:402
231
  msgid "Active"
232
  msgstr ""
233
 
234
+ #: v1/includes/discount-base.php:205 v1/view/cart-rules.php:164
235
+ #: v1/view/pricing-rules.php:194 v1/view/settings_cart_rules.php:95
236
+ #: v1/view/settings_cart_rules.php:102 v1/view/settings_price_rules.php:169
237
+ #: v1/view/settings_promotion.php:22 v1/view/settings_promotion.php:62
238
+ #: v1/view/settings_promotion.php:97 v1/view/settings_promotion.php:132
239
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:187
240
+ #: v2/App/Views/Admin/Tabs/settings.php:305
241
  msgid "Disabled"
242
  msgstr ""
243
 
244
+ #: v1/includes/discount-base.php:522
245
  msgid "Cache cleared successfully"
246
  msgstr ""
247
 
248
+ #: v1/includes/discount-base.php:524
249
  msgid "Failed to clear cache"
250
  msgstr ""
251
 
252
+ #: v1/includes/discount-base.php:635 v1/includes/discount-base.php:670
253
  msgid "Failed to do action"
254
  msgstr ""
255
 
256
+ #: v1/includes/discount-base.php:674
257
  msgid "Disabled successfully"
258
  msgstr ""
259
 
260
+ #: v1/includes/discount-base.php:677
261
  msgid "Deleted successfully"
262
  msgstr ""
263
 
264
+ #: v1/includes/discount-base.php:680
265
  msgid "Enabled successfully"
266
  msgstr ""
267
 
268
+ #: v1/includes/discount-base.php:700 v1/includes/discount-base.php:701
269
+ #: v1/includes/discount-base.php:718
270
  msgid "copy"
271
  msgstr ""
272
 
273
+ #: v1/includes/discount-base.php:726
274
  msgid "Duplicate rule created successfully"
275
  msgstr ""
276
 
277
+ #: v1/includes/discount-base.php:730
278
  msgid "Failed to create duplicate rule"
279
  msgstr ""
280
 
281
+ #: v1/includes/discount-base.php:1017
282
  msgid "Please fill this field"
283
  msgstr ""
284
 
285
+ #: v1/includes/discount-base.php:1018
286
  msgid "Please Enter the Rule Name to Create / Save."
287
  msgstr ""
288
 
289
+ #: v1/includes/discount-base.php:1019
290
  msgid "Saving..."
291
  msgstr ""
292
 
293
+ #: v1/includes/discount-base.php:1020 v1/view/view-cart-rules.php:55
294
+ #: v1/view/view-pricing-rules.php:37
295
  msgid "Save Rule"
296
  msgstr ""
297
 
298
+ #: v1/includes/discount-base.php:1021
299
  msgid "Please enter a Key"
300
  msgstr ""
301
 
302
+ #: v1/includes/discount-base.php:1022 v1/view/view-pricing-rules.php:739
303
  msgid "Min Quantity"
304
  msgstr ""
305
 
306
+ #: v1/includes/discount-base.php:1023 v1/view/view-pricing-rules.php:746
307
  msgid "Max Quantity"
308
  msgstr ""
309
 
310
+ #: v1/includes/discount-base.php:1024 v1/view/view-pricing-rules.php:654
311
+ #: v1/view/view-pricing-rules.php:657 v1/view/view-pricing-rules.php:677
312
+ #: v2/App/Controllers/Admin/Settings.php:420
313
  msgid "Quantity"
314
  msgstr ""
315
 
316
+ #: v1/includes/discount-base.php:1025 v1/view/view-cart-rules.php:92
317
+ #: v1/view/view-pricing-rules.php:74 v1/view/view-pricing-rules.php:744
318
+ #: v1/view/view-pricing-rules.php:897 v1/view/view-pricing-rules.php:920
319
+ #: v1/view/view-pricing-rules.php:927
320
  msgid "ex. 1"
321
  msgstr ""
322
 
323
+ #: v1/includes/discount-base.php:1026 v1/view/view-pricing-rules.php:965
324
  msgid "ex. 10"
325
  msgstr ""
326
 
327
+ #: v1/includes/discount-base.php:1027 v1/view/view-pricing-rules.php:751
328
+ #: v1/view/view-pricing-rules.php:879
329
  msgid "ex. 50"
330
  msgstr ""
331
 
332
+ #: v1/includes/discount-base.php:1028
333
  msgid "Search for a user"
334
  msgstr ""
335
 
336
+ #: v1/includes/discount-base.php:1029 v1/view/view-pricing-rules.php:752
337
  msgid "Adjustment Type"
338
  msgstr ""
339
 
340
+ #: v1/includes/discount-base.php:1030 v1/view/view-pricing-rules.php:954
341
+ #: v2/App/Controllers/Admin/Settings.php:423
342
  msgid "Discount percentage"
343
  msgstr ""
344
 
345
+ #: v1/includes/discount-base.php:1031 v1/view/view-cart-rules.php:776
346
+ #: v1/view/view-pricing-rules.php:786
347
  msgid "Percentage Discount"
348
  msgstr ""
349
 
350
+ #: v1/includes/discount-base.php:1032 v1/view/view-cart-rules.php:782
351
+ #: v1/view/view-cart-rules.php:784 v1/view/view-pricing-rules.php:794
352
+ #: v1/view/view-pricing-rules.php:796
353
  msgid "Price Discount"
354
  msgstr ""
355
 
356
+ #: v1/includes/discount-base.php:1033
357
  msgid "BOGO Product Discount"
358
  msgstr ""
359
 
360
+ #: v1/includes/discount-base.php:1034
361
  msgid "Product Discount - Not support for subtotal based rule"
362
  msgstr ""
363
 
364
+ #: v1/includes/discount-base.php:1035 v1/view/view-cart-rules.php:462
365
+ #: v1/view/view-pricing-rules.php:874 v1/view/view-pricing-rules.php:1014
366
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:33
367
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:31
368
  msgid "Value"
369
  msgstr ""
370
 
371
+ #: v1/includes/discount-base.php:1036 v1/view/view-pricing-rules.php:882
372
  msgid "receive discount for"
373
  msgstr ""
374
 
375
+ #: v1/includes/discount-base.php:1037 v1/view/view-pricing-rules.php:884
376
  msgid "Auto add all selected products"
377
  msgstr ""
378
 
379
+ #: v1/includes/discount-base.php:1038 v1/view/view-pricing-rules.php:885
380
  msgid "Same product"
381
  msgstr ""
382
 
383
+ #: v1/includes/discount-base.php:1039
384
  msgid "Any one cheapest from selected"
385
  msgstr ""
386
 
387
+ #: v1/includes/discount-base.php:1040
388
  msgid "Any one cheapest from all products"
389
  msgstr ""
390
 
391
+ #: v1/includes/discount-base.php:1041 v1/view/view-pricing-rules.php:854
392
+ #: v1/view/view-pricing-rules.php:856
393
  msgid "Buy X Get Y - Selected Categories (Cheapest in cart)"
394
  msgstr ""
395
 
396
+ #: v1/includes/discount-base.php:1042 v1/view/view-pricing-rules.php:844
397
+ #: v1/view/view-pricing-rules.php:846
398
  msgid "Buy X Get Y - Selected item(s) (Cheapest in cart)"
399
  msgstr ""
400
 
401
+ #: v1/includes/discount-base.php:1043 v1/view/view-pricing-rules.php:864
402
+ #: v1/view/view-pricing-rules.php:866
403
  msgid "Buy X get Y - Cheapest among all items in cart"
404
  msgstr ""
405
 
406
+ #: v1/includes/discount-base.php:1044 v1/view/view-pricing-rules.php:892
407
  msgid "Free quantity"
408
  msgstr ""
409
 
410
+ #: v1/includes/discount-base.php:1045 v1/view/view-pricing-rules.php:892
411
  msgid "Number of quantity(ies) in each selected product(s)"
412
  msgstr ""
413
 
414
+ #: v1/includes/discount-base.php:1046 v1/view/view-pricing-rules.php:912
415
  msgid "Fixed item count (not recommended)"
416
  msgstr ""
417
 
418
+ #: v1/includes/discount-base.php:1047 v1/view/view-pricing-rules.php:911
419
  msgid "Dynamic item count"
420
  msgstr ""
421
 
422
+ #: v1/includes/discount-base.php:1048 v1/view/view-pricing-rules.php:914
423
  msgid ""
424
  "Fixed item count - You need to provide item count manually. Dynamic item "
425
  "count - System will choose dynamically based on cart"
426
  msgstr ""
427
 
428
+ #: v1/includes/discount-base.php:1049 v1/view/view-pricing-rules.php:915
429
  msgid "Item count"
430
  msgstr ""
431
 
432
+ #: v1/includes/discount-base.php:1050 v1/view/view-pricing-rules.php:915
433
  msgid "Discount for number of item(s) in cart"
434
  msgstr ""
435
 
436
+ #: v1/includes/discount-base.php:1051 v1/view/view-pricing-rules.php:922
437
  msgid "Discount for number of quantity(ies)"
438
  msgstr ""
439
 
440
+ #: v1/includes/discount-base.php:1052 v1/view/view-pricing-rules.php:922
441
  msgid "Item quantity"
442
  msgstr ""
443
 
444
+ #: v1/includes/discount-base.php:1053
445
  msgid "Search for a products"
446
  msgstr ""
447
 
448
+ #: v1/includes/discount-base.php:1054
449
  msgid "and"
450
  msgstr ""
451
 
452
+ #: v1/includes/discount-base.php:1055 v1/view/view-pricing-rules.php:956
453
  msgid "100% percent"
454
  msgstr ""
455
 
456
+ #: v1/includes/discount-base.php:1056 v1/view/view-pricing-rules.php:957
457
  msgid "Limited percent"
458
  msgstr ""
459
 
460
+ #: v1/includes/discount-base.php:1057
461
  msgid "Percentage"
462
  msgstr ""
463
 
464
+ #: v1/includes/discount-base.php:1058
465
  msgid "as discount"
466
  msgstr ""
467
 
468
+ #: v1/includes/discount-base.php:1059 v1/view/view-cart-rules.php:701
469
+ #: v1/view/view-pricing-rules.php:974
470
  msgid "Remove"
471
  msgstr ""
472
 
473
+ #: v1/includes/discount-base.php:1060 v1/view/cart-rules.php:185
474
+ #: v1/view/pricing-rules.php:215 v1/view/view-pricing-rules.php:971
475
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:220
476
  msgid "Duplicate"
477
  msgstr ""
478
 
479
+ #: v1/includes/discount-base.php:1061
480
  msgid "none"
481
  msgstr ""
482
 
483
+ #: v1/includes/discount-base.php:1062
484
  msgid "Are you sure to remove this ?"
485
  msgstr ""
486
 
487
+ #: v1/includes/discount-base.php:1064 v1/view/cart-rules.php:130
488
+ #: v1/view/pricing-rules.php:160 v2/App/Controllers/Admin/Settings.php:401
489
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:76
490
  msgid "Disable"
491
  msgstr ""
492
 
493
+ #: v1/includes/discount-base.php:1065
494
  msgid "Are you sure to remove ?"
495
  msgstr ""
496
 
497
+ #: v1/includes/discount-base.php:1066 v1/view/view-cart-rules.php:172
498
  msgid "Type"
499
  msgstr ""
500
 
501
+ #: v1/includes/discount-base.php:1067 v1/view/view-cart-rules.php:176
502
  msgid "Cart Subtotal"
503
  msgstr ""
504
 
505
+ #: v1/includes/discount-base.php:1068 v1/view/view-cart-rules.php:179
506
  msgid "Subtotal at least"
507
  msgstr ""
508
 
509
+ #: v1/includes/discount-base.php:1069 v1/view/view-cart-rules.php:183
510
  msgid "Subtotal less than"
511
  msgstr ""
512
 
513
+ #: v1/includes/discount-base.php:1070 v1/view/view-cart-rules.php:186
514
  msgid "Cart Item Count"
515
  msgstr ""
516
 
517
+ #: v1/includes/discount-base.php:1071 v1/view/view-cart-rules.php:189
518
  msgid "Number of line items in the cart (not quantity) at least"
519
  msgstr ""
520
 
521
+ #: v1/includes/discount-base.php:1072 v1/view/view-cart-rules.php:193
522
  msgid "Number of line items in the cart (not quantity) less than"
523
  msgstr ""
524
 
525
+ #: v1/includes/discount-base.php:1073 v1/view/view-cart-rules.php:196
526
  msgid "Quantity Sum"
527
  msgstr ""
528
 
529
+ #: v1/includes/discount-base.php:1074 v1/view/view-cart-rules.php:202
530
+ #: v1/view/view-cart-rules.php:205
531
  msgid "Total number of quantities in the cart at least"
532
  msgstr ""
533
 
534
+ #: v1/includes/discount-base.php:1075 v1/view/view-cart-rules.php:214
535
+ #: v1/view/view-cart-rules.php:217
536
  msgid "Total number of quantities in the cart less than"
537
  msgstr ""
538
 
539
+ #: v1/includes/discount-base.php:1076 v1/view/view-cart-rules.php:246
540
  msgid "Categories in cart"
541
  msgstr ""
542
 
543
+ #: v1/includes/discount-base.php:1077 v1/view/view-cart-rules.php:252
544
  msgid "Including sub-categories in cart"
545
  msgstr ""
546
 
547
+ #: v1/includes/discount-base.php:1078 v1/view/view-cart-rules.php:267
548
  msgid "Customer Details (must be logged in)"
549
  msgstr ""
550
 
551
+ #: v1/includes/discount-base.php:1079 v1/view/view-cart-rules.php:273
552
+ #: v1/view/view-cart-rules.php:275
553
  msgid "User in list"
554
  msgstr ""
555
 
556
+ #: v1/includes/discount-base.php:1080 v1/view/view-cart-rules.php:283
557
+ #: v1/view/view-cart-rules.php:285
558
  msgid "User role in list"
559
  msgstr ""
560
 
561
+ #: v1/includes/discount-base.php:1081 v1/view/view-cart-rules.php:349
562
+ #: v1/view/view-cart-rules.php:351
563
  msgid "Shipping country in list"
564
  msgstr ""
565
 
566
+ #: v1/includes/discount-base.php:1082 v1/view/view-cart-rules.php:289
567
  msgid "Customer Email"
568
  msgstr ""
569
 
570
+ #: v1/includes/discount-base.php:1083
571
  msgid "Email with TLD (Ege: edu)"
572
  msgstr ""
573
 
574
+ #: v1/includes/discount-base.php:1084 v1/view/view-cart-rules.php:305
575
+ #: v1/view/view-cart-rules.php:307
576
  msgid "Email with Domain (Eg: gmail.com)"
577
  msgstr ""
578
 
579
+ #: v1/includes/discount-base.php:1085 v1/view/view-cart-rules.php:311
580
  msgid "Customer Billing Details"
581
  msgstr ""
582
 
583
+ #: v1/includes/discount-base.php:1086 v1/view/view-cart-rules.php:317
584
+ #: v1/view/view-cart-rules.php:319
585
  msgid "Billing city"
586
  msgstr ""
587
 
588
+ #: v1/includes/discount-base.php:1087 v1/view/view-cart-rules.php:323
589
  msgid "Customer Shipping Details"
590
  msgstr ""
591
 
592
+ #: v1/includes/discount-base.php:1088 v1/view/view-cart-rules.php:339
593
+ #: v1/view/view-cart-rules.php:341
594
  msgid "Shipping state"
595
  msgstr ""
596
 
597
+ #: v1/includes/discount-base.php:1089 v1/view/view-cart-rules.php:329
598
+ #: v1/view/view-cart-rules.php:331
599
  msgid "Shipping city"
600
  msgstr ""
601
 
602
+ #: v1/includes/discount-base.php:1090 v1/view/view-cart-rules.php:359
603
+ #: v1/view/view-cart-rules.php:361
604
  msgid "Shipping zip code"
605
  msgstr ""
606
 
607
+ #: v1/includes/discount-base.php:1091 v1/view/view-cart-rules.php:365
608
+ #: v1/view/view-pricing-rules.php:536 v2/App/Helpers/ProOptions.php:190
609
+ #: v2/App/Helpers/ProOptions.php:198 v2/App/Helpers/ProOptions.php:206
610
+ #: v2/App/Helpers/ProOptions.php:214 v2/App/Helpers/ProOptions.php:222
611
+ #: v2/App/Helpers/ProOptions.php:230
612
  msgid "Purchase History"
613
  msgstr ""
614
 
615
+ #: v1/includes/discount-base.php:1092 v1/view/view-cart-rules.php:381
616
+ #: v1/view/view-cart-rules.php:383 v1/view/view-pricing-rules.php:551
617
  msgid "Purchased amount"
618
  msgstr ""
619
 
620
+ #: v1/includes/discount-base.php:1093 v1/view/view-cart-rules.php:391
621
+ #: v1/view/view-cart-rules.php:393 v1/view/view-pricing-rules.php:552
622
  msgid "Number of previous orders made"
623
  msgstr ""
624
 
625
+ #: v1/includes/discount-base.php:1094 v1/view/view-cart-rules.php:401
626
+ #: v1/view/view-cart-rules.php:403 v1/view/view-pricing-rules.php:553
627
  msgid "Number of previous orders made with following products"
628
  msgstr ""
629
 
630
+ #: v1/includes/discount-base.php:1095 v1/view/view-cart-rules.php:411
631
+ #: v1/view/view-cart-rules.php:413 v1/view/view-pricing-rules.php:554
632
  msgid "Number of quantity(s) in previous orders made with following products"
633
  msgstr ""
634
 
635
+ #: v1/includes/discount-base.php:1096 v1/view/view-cart-rules.php:417
636
  msgid "Coupon applied"
637
  msgstr ""
638
 
639
+ #: v1/includes/discount-base.php:1097 v1/view/view-cart-rules.php:423
640
+ #: v1/view/view-cart-rules.php:425 v1/view/view-pricing-rules.php:410
641
  msgid "Create your own coupon"
642
  msgstr ""
643
 
644
+ #: v1/includes/discount-base.php:1098 v1/view/view-cart-rules.php:433
645
+ #: v1/view/view-cart-rules.php:435
646
  msgid "Atleast any one (Select from WooCommerce)"
647
  msgstr ""
648
 
649
+ #: v1/includes/discount-base.php:1099 v1/view/view-cart-rules.php:443
650
+ #: v1/view/view-cart-rules.php:445
651
  msgid "All selected (Select from WooCommerce)"
652
  msgstr ""
653
 
654
+ #: v1/includes/discount-base.php:1100 v1/view/view-cart-rules.php:647
655
+ #: v1/view/view-pricing-rules.php:590
656
  msgid "Greater than or equal to"
657
  msgstr ""
658
 
659
+ #: v1/includes/discount-base.php:1101 v1/view/view-cart-rules.php:648
660
+ #: v1/view/view-pricing-rules.php:591 v1/view/view-pricing-rules.php:650
661
  msgid "Less than or equal to"
662
  msgstr ""
663
 
664
+ #: v1/includes/discount-base.php:1102 v1/view/view-cart-rules.php:650
665
+ #: v1/view/view-pricing-rules.php:594
666
  msgid "and the order status should be"
667
  msgstr ""
668
 
669
+ #: v1/includes/discount-base.php:1103 v1/view/cart-rules.php:114
670
+ #: v1/view/cart-rules.php:224 v1/view/pricing-rules.php:144
671
+ #: v1/view/pricing-rules.php:254 v1/view/view-cart-rules.php:700
672
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:124
673
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:269
674
  msgid "Action"
675
  msgstr ""
676
 
677
+ #: v1/includes/discount-base.php:1104 v1/view/settings.php:33
678
+ #: v1/view/settings_taxonomy.php:21 v2/App/Views/Admin/Rules/Manage.php:72
679
  msgid "Save"
680
  msgstr ""
681
 
682
+ #: v1/includes/discount-base.php:1105
683
  msgid "Saved Successfully!"
684
  msgstr ""
685
 
686
+ #: v1/includes/discount-base.php:1106 v1/view/view-cart-rules.php:491
687
+ #: v1/view/view-cart-rules.php:559 v1/view/view-cart-rules.php:579
688
+ #: v1/view/view-cart-rules.php:600 v1/view/view-cart-rules.php:655
689
+ #: v1/view/view-pricing-rules.php:238 v1/view/view-pricing-rules.php:254
690
+ #: v1/view/view-pricing-rules.php:602 v1/view/view-pricing-rules.php:686
691
+ #: v1/view/view-pricing-rules.php:942
692
  msgid "None selected"
693
  msgstr ""
694
 
695
+ #: v1/includes/discount-base.php:1107 v1/view/view-cart-rules.php:258
696
  msgid "In each category"
697
  msgstr ""
698
 
699
+ #: v1/includes/discount-base.php:1108 v1/view/settings_price_rules.php:208
700
+ #: v1/view/settings_price_rules.php:226 v1/view/settings_price_rules.php:244
701
+ #: v1/view/settings_price_rules.php:262
702
+ #: v2/App/Views/Admin/Tabs/settings.php:484
703
  msgid "Show"
704
  msgstr ""
705
 
706
+ #: v1/includes/discount-base.php:1109 v1/view/template/sidebar.php:12
707
  msgid "Hide"
708
  msgstr ""
709
 
710
+ #: v1/includes/discount-base.php:1110
711
  msgid "Please select at least one rule"
712
  msgstr ""
713
 
714
+ #: v1/includes/discount-base.php:1111
715
  msgid "Please select an action to apply"
716
  msgstr ""
717
 
718
+ #: v1/includes/discount-base.php:1112
719
  msgid "Are you sure to remove the selected rules"
720
  msgstr ""
721
 
722
+ #: v1/includes/discount-base.php:1113 v1/view/view-pricing-rules.php:931
723
  msgid "Choose product(s)"
724
  msgstr ""
725
 
726
+ #: v1/includes/discount-base.php:1114 v1/view/view-pricing-rules.php:941
727
  msgid "Choose category(ies)"
728
  msgstr ""
729
 
730
+ #: v1/includes/discount-base.php:1115
731
  msgid "Search for a coupon"
732
  msgstr ""
733
 
734
+ #: v1/includes/discount-base.php:1116 v1/view/view-pricing-rules.php:965
735
  #, php-format
736
  msgid "Enter only numeric values. Eg: <b>50</b> for 50% discount"
737
  msgstr ""
738
 
739
+ #: v1/includes/discount-base.php:1117
740
  #, php-format
741
  msgid "Enter the discount price. Eg: <b>10</b> for %s discount"
742
  msgstr ""
743
 
744
+ #: v1/includes/discount-base.php:1118
745
  #, php-format
746
  msgid "Enter the discounted price per unit. Eg: <b>10</b> for %s as unit price"
747
  msgstr ""
748
 
749
+ #: v1/includes/discount-base.php:1119
750
  #, php-format
751
  msgid ""
752
  "Enter the price for selected quantity. Eg: <b>10</b> then %s as total price "
753
  "for selected quantity"
754
  msgstr ""
755
 
756
+ #: v1/includes/discount-base.php:1120 v1/view/view-pricing-rules.php:890
757
  msgid ""
758
  "Auto add all selected products - Automatically added to the cart <br> Same "
759
  "product - get discount in same product <br> Any one cheapest from selected - "
764
  "no.of quantities"
765
  msgstr ""
766
 
767
+ #: v1/includes/discount-base.php:1121 v1/view/view-cart-rules.php:221
768
+ #: v2/App/Controllers/Base.php:45
769
  msgid "Products"
770
  msgstr ""
771
 
772
+ #: v1/includes/discount-base.php:1122 v1/view/view-cart-rules.php:226
773
  msgid "Products in cart"
774
  msgstr ""
775
 
776
+ #: v1/includes/discount-base.php:1123 v1/view/view-cart-rules.php:232
777
+ #: v1/view/view-pricing-rules.php:273
778
  msgid "Exclude products"
779
  msgstr ""
780
 
781
+ #: v1/includes/discount-base.php:1124 v1/view/view-cart-rules.php:238
782
  msgid "Exclude on sale products"
783
  msgstr ""
784
 
785
+ #: v1/includes/discount-base.php:1125 v1/view/view-cart-rules.php:529
786
  msgid "This will exclude the on sale products from discount"
787
  msgstr ""
788
 
789
+ #: v1/includes/discount-base.php:1126 v1/view/view-cart-rules.php:663
790
+ #: v1/view/view-pricing-rules.php:609
791
  msgid "From all previous orders"
792
  msgstr ""
793
 
794
+ #: v1/includes/discount-base.php:1127 v1/view/view-cart-rules.php:664
795
+ #: v1/view/view-pricing-rules.php:610
796
  msgid "Last 7 days"
797
  msgstr ""
798
 
799
+ #: v1/includes/discount-base.php:1128 v1/view/view-cart-rules.php:665
800
+ #: v1/view/view-pricing-rules.php:611
801
  msgid "Last 14 days"
802
  msgstr ""
803
 
804
+ #: v1/includes/discount-base.php:1129 v1/view/view-cart-rules.php:666
805
+ #: v1/view/view-pricing-rules.php:612
806
  msgid "Last 30 days"
807
  msgstr ""
808
 
809
+ #: v1/includes/discount-base.php:1130 v1/view/view-cart-rules.php:667
810
+ #: v1/view/view-pricing-rules.php:613
811
  msgid "Last 60 days"
812
  msgstr ""
813
 
814
+ #: v1/includes/discount-base.php:1131 v1/view/view-cart-rules.php:668
815
+ #: v1/view/view-pricing-rules.php:614
816
  msgid "Last 90 days"
817
  msgstr ""
818
 
819
+ #: v1/includes/discount-base.php:1132 v1/view/view-cart-rules.php:669
820
+ #: v1/view/view-pricing-rules.php:615
821
  msgid "Last 180 days"
822
  msgstr ""
823
 
824
+ #: v1/includes/discount-base.php:1133 v1/view/view-cart-rules.php:670
825
+ #: v1/view/view-pricing-rules.php:616
826
  msgid "Last 1 year"
827
  msgstr ""
828
 
829
+ #: v1/includes/discount-base.php:1134 v1/view/view-cart-rules.php:671
830
+ #: v1/view/view-pricing-rules.php:617
831
  msgid "Custom"
832
  msgstr ""
833
 
834
+ #: v1/includes/discount-base.php:1135 v1/view/view-cart-rules.php:674
835
+ #: v1/view/view-pricing-rules.php:621
836
  msgid "in days"
837
  msgstr ""
838
 
839
+ #: v1/includes/discount-base.php:1136 v1/view/view-pricing-rules.php:804
840
+ #: v1/view/view-pricing-rules.php:806
841
  msgid "Fixed Price Per Unit"
842
  msgstr ""
843
 
844
+ #: v1/includes/discount-base.php:1137 v1/view/view-pricing-rules.php:814
845
+ #: v1/view/view-pricing-rules.php:816
846
  msgid "Bundle (Set) Discount"
847
  msgstr ""
848
 
849
+ #: v1/includes/discount-base.php:1138 v1/view/view-cart-rules.php:371
850
+ #: v1/view/view-cart-rules.php:373 v1/view/view-pricing-rules.php:550
851
  msgid "First Order discount"
852
  msgstr ""
853
 
854
+ #: v1/includes/discount-base.php:1139 v1/view/view-cart-rules.php:264
855
  msgid "Exclude categories in cart"
856
  msgstr ""
857
 
858
+ #: v1/includes/discount-base.php:1141 v1/view/view-pricing-rules.php:824
859
+ #: v1/view/view-pricing-rules.php:826
860
  msgid "Buy X get X (Same product)"
861
  msgstr ""
862
 
863
+ #: v1/includes/discount-base.php:1142 v1/view/view-pricing-rules.php:834
864
+ #: v1/view/view-pricing-rules.php:836
865
  msgid "Buy X get Y (Auto add all selected products)"
866
  msgstr ""
867
 
868
+ #: v1/includes/discount-base.php:1143
869
  #, php-format
870
  msgid ""
871
  "The customer gets the same product free (Buy 2 get 1 free) or a limited "
872
  "percentage (Buy 2 and get 1 at 50% discount)"
873
  msgstr ""
874
 
875
+ #: v1/includes/discount-base.php:1144
876
  msgid ""
877
  "Provide a specific product free when purchasing another product."
878
  "<br><br>Example: Buy Product A and get Product B free. Product B will be "
879
  "automatically added to cart."
880
  msgstr ""
881
 
882
+ #: v1/includes/discount-base.php:1145
883
  msgid ""
884
  "Provide a specific product free when purchasing another product."
885
  "<br><br>Instead of automatically adding, if you wish to choose the free "
887
  "discounted only when the user manually adds the product to cart."
888
  msgstr ""
889
 
890
+ #: v1/includes/discount-base.php:1146
891
  msgid ""
892
  "Used to provide BOGO discount within categories.<br><br>Example 1: Buy 2 "
893
  "from Category A and get 1 free from the same Category A.<br>Example 2: Buy "
895
  "B."
896
  msgstr ""
897
 
898
+ #: v1/includes/discount-base.php:1147
899
  msgid ""
900
  "This allows you to offer the cheapest product in cart for free (or at a "
901
  "limited percentage like 50%)"
902
  msgstr ""
903
 
904
+ #: v1/includes/discount-base.php:1148
905
  #, php-format
906
  msgid ""
907
  "<span class=\"wdr_desc_text\">Useful for providing a discount on store wide "
909
  "\">Read docs</a>.</span>"
910
  msgstr ""
911
 
912
+ #: v1/includes/discount-base.php:1149
913
  #, php-format
914
  msgid ""
915
  "<span class=\"wdr_desc_text\">Useful for providing a discount on selected "
919
  "\">Read docs</a>.</span>"
920
  msgstr ""
921
 
922
+ #: v1/includes/discount-base.php:1150
923
  #, php-format
924
  msgid ""
925
  "<span class=\"wdr_desc_text\">Useful for providing a discount on a specific "
928
  "<a href=\"%s\">Read docs</a>.</span>"
929
  msgstr ""
930
 
931
+ #: v1/includes/discount-base.php:1151
932
  #, php-format
933
  msgid ""
934
  "<span class=\"wdr_desc_text\">Useful to offer discount based on attributes. "
937
  "defined in WooCommerce -> Attributes. <a href=\"%s\">Read docs</a>.</span>"
938
  msgstr ""
939
 
940
+ #: v1/includes/discount-base.php:1237 v2/App/Controllers/ManageDiscount.php:683
941
  #, php-format
942
  msgid ""
943
  "Sorry, it is not possible to apply coupon <b>\"%s\"</b> as you already have "
944
  "a discount applied in cart."
945
  msgstr ""
946
 
947
+ #: v1/includes/discount-base.php:1292 v1/view/includes/menu.php:16
948
+ #: v2/App/Controllers/Admin/Settings.php:61
949
+ #: v2/App/Controllers/Admin/Tabs/GeneralSettings.php:22
950
  msgid "Settings"
951
  msgstr ""
952
 
953
+ #: v1/includes/pricing-rules.php:3207 v1/view/view-pricing-rules.php:642
954
  msgid "Buy"
955
  msgstr ""
956
 
957
+ #: v1/includes/pricing-rules.php:3211
958
  msgid " less than or equal to "
959
  msgstr ""
960
 
961
+ #: v1/includes/pricing-rules.php:3211 v1/includes/pricing-rules.php:3217
962
  msgid " Quantity"
963
  msgstr ""
964
 
965
+ #: v1/includes/pricing-rules.php:3214
966
  msgid " Quantity "
967
  msgstr ""
968
 
969
+ #: v1/includes/pricing-rules.php:3221
970
  msgid " or more Quantity"
971
  msgstr ""
972
 
973
+ #: v1/includes/pricing-rules.php:3230
974
  msgid " any "
975
  msgstr ""
976
 
977
+ #: v1/includes/pricing-rules.php:3230
978
  msgid " products from "
979
  msgstr ""
980
 
981
+ #: v1/includes/pricing-rules.php:3237
982
  msgid " in each products"
983
  msgstr ""
984
 
985
+ #: v1/includes/pricing-rules.php:3249
986
  msgid " and get discount on "
987
  msgstr ""
988
 
989
+ #: v1/includes/pricing-rules.php:3252
990
  msgid " first "
991
  msgstr ""
992
 
993
+ #: v1/includes/pricing-rules.php:3254 v1/includes/pricing-rules.php:3258
994
  msgid " quantity of product(s) - "
995
  msgstr ""
996
 
997
+ #: v1/includes/pricing-rules.php:3256
998
  msgid " after first "
999
  msgstr ""
1000
 
1001
+ #: v1/includes/pricing-rules.php:3274
1002
  msgid "Category(ies) "
1003
  msgstr ""
1004
 
1005
+ #: v1/includes/pricing-rules.php:3345
1006
  msgid "Get "
1007
  msgstr ""
1008
 
1009
+ #: v1/includes/pricing-rules.php:3347
1010
  #, php-format
1011
  msgid "% discount in "
1012
  msgstr ""
1013
 
1014
+ #: v1/includes/pricing-rules.php:3350
1015
  msgid "same product"
1016
  msgstr ""
1017
 
1018
+ #: v1/includes/pricing-rules.php:3352
1019
  msgid "any cheapest one from cart"
1020
  msgstr ""
1021
 
1022
+ #: v1/includes/pricing-rules.php:3355
1023
  msgid "any cheapest one of "
1024
  msgstr ""
1025
 
1026
+ #: v1/includes/pricing-rules.php:3360
1027
  msgid " quantity of any "
1028
  msgstr ""
1029
 
1030
+ #: v1/includes/pricing-rules.php:3362
1031
  msgid " cheapest item "
1032
  msgstr ""
1033
 
1034
+ #: v1/includes/pricing-rules.php:3365
1035
  msgid " quantity of cheapest item "
1036
  msgstr ""
1037
 
1038
+ #: v1/includes/pricing-rules.php:3369
1039
  msgid "from the category "
1040
  msgstr ""
1041
 
1042
+ #: v1/includes/pricing-rules.php:3391
1043
  #, php-format
1044
  msgid "%s for %s Quantity(s)"
1045
  msgstr ""
1046
 
1047
+ #: v1/includes/pricing-rules.php:3393
1048
  #, php-format
1049
  msgid "%s as price per unit"
1050
  msgstr ""
1051
 
1052
+ #: v1/includes/survey.php:82 v2/App/Helpers/SurveyForm.php:84
1053
  msgid "Please select an option"
1054
  msgstr ""
1055
 
1056
+ #: v1/includes/survey.php:85 v2/App/Helpers/SurveyForm.php:87
1057
  msgid "Sending Feedback"
1058
  msgstr ""
1059
 
1060
+ #: v1/includes/survey.php:239 v2/App/Helpers/SurveyForm.php:241
1061
  msgid "Upgrading to PRO."
1062
  msgstr ""
1063
 
1064
+ #: v1/includes/survey.php:243 v2/App/Helpers/SurveyForm.php:245
1065
  msgid "I am switching to a different discount plugin."
1066
  msgstr ""
1067
 
1068
+ #: v1/includes/survey.php:247 v2/App/Helpers/SurveyForm.php:249
1069
  msgid "I could not get my discount rule to work."
1070
  msgstr ""
1071
 
1072
+ #: v1/includes/survey.php:251 v2/App/Helpers/SurveyForm.php:253
1073
  msgid "It does not meet my discount requirements."
1074
  msgstr ""
1075
 
1076
+ #: v1/includes/survey.php:255 v2/App/Helpers/SurveyForm.php:257
1077
  msgid "Plugin is complex."
1078
  msgstr ""
1079
 
1080
+ #: v1/includes/survey.php:259 v2/App/Helpers/SurveyForm.php:261
1081
  msgid "I'm trying to troubleshoot the plugin."
1082
  msgstr ""
1083
 
1084
+ #: v1/includes/survey.php:263 v2/App/Helpers/SurveyForm.php:265
1085
  msgid "I was instructed to deactivate by Flycart Support."
1086
  msgstr ""
1087
 
1088
+ #: v1/includes/survey.php:267 v2/App/Helpers/SurveyForm.php:269
1089
  msgid "I no longer use this plugin."
1090
  msgstr ""
1091
 
1092
+ #: v1/includes/survey.php:271 v2/App/Helpers/SurveyForm.php:273
1093
  msgid "It's a temporary deactivation."
1094
  msgstr ""
1095
 
1096
+ #: v1/includes/survey.php:275 v2/App/Helpers/SurveyForm.php:277
1097
  msgid "Other"
1098
  msgstr ""
1099
 
1100
+ #: v1/includes/survey.php:277 v2/App/Helpers/SurveyForm.php:279
1101
  msgid "Please share the reason"
1102
  msgstr ""
1103
 
1104
+ #: v1/includes/survey.php:287 v2/App/Helpers/SurveyForm.php:289
1105
  msgid "Quick Feedback"
1106
  msgstr ""
1107
 
1108
+ #: v1/includes/survey.php:288 v2/App/Helpers/SurveyForm.php:290
1109
  msgid "Close"
1110
  msgstr ""
1111
 
1112
+ #: v1/includes/survey.php:296 v2/App/Helpers/SurveyForm.php:298
1113
  #, php-format
1114
  msgid "If you have a moment, please share why you are deactivating %s:"
1115
  msgstr ""
1116
 
1117
+ #: v1/includes/survey.php:297 v2/App/Helpers/SurveyForm.php:299
1118
  msgid "Discount Rules for WooCommerce"
1119
  msgstr ""
1120
 
1121
+ #: v1/includes/survey.php:325 v2/App/Helpers/SurveyForm.php:327
1122
  msgid "Submit & Deactivate"
1123
  msgstr ""
1124
 
1125
+ #: v1/includes/survey.php:327 v2/App/Helpers/SurveyForm.php:329
1126
  msgid "Skip & Deactivate"
1127
  msgstr ""
1128
 
1129
+ #: v1/view/cart-rules.php:48
1130
  msgid "Cart Rules"
1131
  msgstr ""
1132
 
1133
+ #: v1/view/cart-rules.php:52 v1/view/pricing-rules.php:84
1134
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:55
1135
  msgid "View Examples"
1136
  msgstr ""
1137
 
1138
+ #: v1/view/cart-rules.php:53 v1/view/documentation.php:21
1139
+ #: v1/view/pricing-rules.php:85 v2/App/Views/Admin/Tabs/DiscountRule.php:57
1140
+ #: v2/App/Views/Admin/Tabs/help.php:12
1141
  msgid "Documentation"
1142
  msgstr ""
1143
 
1144
+ #: v1/view/cart-rules.php:63 v1/view/pricing-rules.php:95
1145
  msgid "You Reach Max. Rule Limit"
1146
  msgstr ""
1147
 
1148
+ #: v1/view/cart-rules.php:68 v1/view/pricing-rules.php:99
1149
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:12
1150
  msgid "Add New Rule"
1151
  msgstr ""
1152
 
1153
+ #: v1/view/cart-rules.php:79 v1/view/pricing-rules.php:109
1154
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:74
1155
  msgid "Bulk Actions"
1156
  msgstr ""
1157
 
1158
+ #: v1/view/cart-rules.php:80 v1/view/pricing-rules.php:110
1159
  msgid "Enable rules"
1160
  msgstr ""
1161
 
1162
+ #: v1/view/cart-rules.php:81 v1/view/pricing-rules.php:111
1163
  msgid "Disable rules"
1164
  msgstr ""
1165
 
1166
+ #: v1/view/cart-rules.php:82 v1/view/pricing-rules.php:112
1167
  msgid "Delete rules"
1168
  msgstr ""
1169
 
1170
+ #: v1/view/cart-rules.php:84 v1/view/pricing-rules.php:114
1171
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:79
1172
  msgid "Apply"
1173
  msgstr ""
1174
 
1175
+ #: v1/view/cart-rules.php:98 v1/view/cart-rules.php:208
1176
+ #: v1/view/pricing-rules.php:128 v1/view/pricing-rules.php:238
1177
+ #: v1/view/template/discount-table.php:36
1178
  msgid "Name"
1179
  msgstr ""
1180
 
1181
+ #: v1/view/cart-rules.php:99 v1/view/cart-rules.php:209
1182
+ #: v1/view/pricing-rules.php:129 v1/view/pricing-rules.php:239
1183
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:107
1184
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:252
1185
  msgid "Start Date"
1186
  msgstr ""
1187
 
1188
+ #: v1/view/cart-rules.php:100 v1/view/cart-rules.php:210
1189
+ #: v1/view/pricing-rules.php:130 v1/view/pricing-rules.php:240
1190
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:109
1191
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:254
1192
  msgid "Expired On"
1193
  msgstr ""
1194
 
1195
+ #: v1/view/cart-rules.php:101 v1/view/cart-rules.php:211
1196
+ #: v1/view/pricing-rules.php:131 v1/view/pricing-rules.php:241
1197
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:122
1198
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:267
1199
  msgid "Status"
1200
  msgstr ""
1201
 
1202
+ #: v1/view/cart-rules.php:104 v1/view/cart-rules.php:214
1203
+ #: v1/view/pricing-rules.php:134 v1/view/pricing-rules.php:244
1204
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:187
1205
  msgid "Language"
1206
  msgstr ""
1207
 
1208
+ #: v1/view/cart-rules.php:109 v1/view/cart-rules.php:219
1209
+ #: v1/view/pricing-rules.php:139 v1/view/pricing-rules.php:249
1210
  msgid "Order"
1211
  msgstr ""
1212
 
1213
+ #: v1/view/cart-rules.php:181 v1/view/pricing-rules.php:211
1214
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:218
1215
  msgid "Edit"
1216
  msgstr ""
1217
 
1218
+ #: v1/view/cart-rules.php:192 v1/view/pricing-rules.php:222
1219
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:77
1220
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:223
1221
  msgid "Delete"
1222
  msgstr ""
1223
 
1224
+ #: v1/view/documentation.php:28
1225
  msgid "Installation and Intro:"
1226
  msgstr ""
1227
 
1228
+ #: v1/view/documentation.php:30 v2/App/Views/Admin/Tabs/help.php:20
1229
  msgid "Getting started"
1230
  msgstr ""
1231
 
1232
+ #: v1/view/documentation.php:30 v2/App/Views/Admin/Tabs/help.php:21
1233
  msgid "Welcome onboard"
1234
  msgstr ""
1235
 
1236
+ #: v1/view/documentation.php:33
1237
  msgid "License Key activation"
1238
  msgstr ""
1239
 
1240
+ #: v1/view/documentation.php:33
1241
  msgid "Learn how to obtain the license key and activate it"
1242
  msgstr ""
1243
 
1244
+ #: v1/view/documentation.php:36
1245
  msgid "Version Updates!"
1246
  msgstr ""
1247
 
1248
+ #: v1/view/documentation.php:36
1249
  msgid "Learn how to update to latest versions"
1250
  msgstr ""
1251
 
1252
+ #: v1/view/documentation.php:39
1253
  msgid "Popular Discount Rules"
1254
  msgstr ""
1255
 
1256
+ #: v1/view/documentation.php:39
1257
  msgid "What type of discount scenarios are most commonly used"
1258
  msgstr ""
1259
 
1260
+ #: v1/view/documentation.php:43
1261
  msgid "Price rules/BOGO discounts:"
1262
  msgstr ""
1263
 
1264
+ #: v1/view/documentation.php:45
1265
  msgid "Bulk/Tiered pricing discounts"
1266
  msgstr ""
1267
 
1268
+ #: v1/view/documentation.php:45
1269
  msgid "Learn how to create bulk/tiered quantity discounts in WooCommerce"
1270
  msgstr ""
1271
 
1272
+ #: v1/view/documentation.php:48
1273
  msgid "How to create a perfect BOGO discount rule in WooCommerce"
1274
  msgstr ""
1275
 
1276
+ #: v1/view/documentation.php:48
1277
  msgid ""
1278
  "Buy One Get One deals can be simple to complex. Learn how to get them "
1279
  "working correct in your online store"
1280
  msgstr ""
1281
 
1282
+ #: v1/view/documentation.php:51
1283
  msgid "User Role based discount rules"
1284
  msgstr ""
1285
 
1286
+ #: v1/view/documentation.php:51
1287
  msgid ""
1288
  "Learn how to create user role based / customer group based discount in "
1289
  "WooCommerce"
1290
  msgstr ""
1291
 
1292
+ #: v1/view/documentation.php:54
1293
  msgid "Purchase History Based Discount"
1294
  msgstr ""
1295
 
1296
+ #: v1/view/documentation.php:54
1297
  msgid ""
1298
  "Price Rule and Cart Rule which gives discount based on the purchase history"
1299
  msgstr ""
1300
 
1301
+ #: v1/view/documentation.php:57
1302
  msgid "Coupon code based discounts"
1303
  msgstr ""
1304
 
1305
+ #: v1/view/documentation.php:57
1306
  msgid ""
1307
  "Apply the dynamic discount rules after the customer enters a valid coupon "
1308
  "code"
1309
  msgstr ""
1310
 
1311
+ #: v1/view/documentation.php:61
1312
  msgid "Cart Based Rules:"
1313
  msgstr ""
1314
 
1315
+ #: v1/view/documentation.php:63
1316
  msgid "Learn how to create a free shipping cart based rule"
1317
  msgstr ""
1318
 
1319
+ #: v1/view/documentation.php:66
1320
  msgid "Subtotal based - Tiered discounts"
1321
  msgstr ""
1322
 
1323
+ #: v1/view/documentation.php:66
1324
  msgid "Learn how to create tiered discount based on the subtotal value"
1325
  msgstr ""
1326
 
1327
+ #: v1/view/documentation.php:69
1328
  msgid "Free product discount"
1329
  msgstr ""
1330
 
1331
+ #: v1/view/documentation.php:69
1332
  msgid ""
1333
  "How to provide a automatic adding free product in cart under certain "
1334
  "conditions"
1335
  msgstr ""
1336
 
1337
+ #: v1/view/documentation.php:72
1338
  msgid "Category Combination"
1339
  msgstr ""
1340
 
1341
+ #: v1/view/documentation.php:72
1342
  msgid ""
1343
  "Category Combination (get discount only when Category A+ B + C are in the "
1344
  "cart)"
1345
  msgstr ""
1346
 
1347
+ #: v1/view/includes/cart-menu.php:9 v1/view/includes/sub-menu.php:9
1348
+ #: v1/view/settings.php:38 v1/view/view-cart-rules.php:65
1349
+ #: v1/view/view-pricing-rules.php:47 v2/App/Views/Admin/Tabs/settings.php:15
1350
  msgid "General"
1351
  msgstr ""
1352
 
1353
+ #: v1/view/includes/cart-menu.php:11
1354
  msgid "Conditions"
1355
  msgstr ""
1356
 
1357
+ #: v1/view/includes/cart-menu.php:13 v1/view/includes/sub-menu.php:13
1358
+ #: v1/view/template/discount-table.php:42 v1/view/view-cart-rules.php:756
1359
+ #: v1/view/view-pricing-rules.php:708 v2/App/Controllers/Admin/Settings.php:428
1360
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:59
1361
+ #: v2/App/Views/Admin/Rules/Manage.php:171
1362
  msgid "Discount"
1363
  msgstr ""
1364
 
1365
+ #: v1/view/includes/footer.php:7
1366
  msgid ""
1367
  "Having trouble in setting up the discount? Let us set up the rules for you "
1368
  "(for free)!"
1369
  msgstr ""
1370
 
1371
+ #: v1/view/includes/footer.php:7
1372
  msgid "Please contact our support team"
1373
  msgstr ""
1374
 
1375
+ #: v1/view/includes/header.php:14
1376
  #, php-format
1377
  msgid ""
1378
  "An another discount plugin %s is active. Please disable this plugin, Woo "
1379
  "Discount Rules might get conflict."
1380
  msgstr ""
1381
 
1382
+ #: v1/view/includes/menu.php:12
1383
  msgid "Price Discount Rules"
1384
  msgstr ""
1385
 
1386
+ #: v1/view/includes/menu.php:14
1387
  msgid "Cart Discount Rules"
1388
  msgstr ""
1389
 
1390
+ #: v1/view/includes/menu.php:20
1391
  msgid "Taxonomy Settings"
1392
  msgstr ""
1393
 
1394
+ #: v1/view/includes/menu.php:22
1395
  msgid "Read documentation"
1396
  msgstr ""
1397
 
1398
+ #: v1/view/includes/sub-menu.php:11
1399
  msgid "Condition"
1400
  msgstr ""
1401
 
1402
+ #: v1/view/pricing-rules.php:80
1403
  msgid "Price Rules"
1404
  msgstr ""
1405
 
1406
+ #: v1/view/settings.php:39
1407
  msgid "Price rules"
1408
  msgstr ""
1409
 
1410
+ #: v1/view/settings.php:40
1411
  msgid "Cart rules"
1412
  msgstr ""
1413
 
1414
+ #: v1/view/settings.php:41
1415
  msgid "Performance"
1416
  msgstr ""
1417
 
1418
+ #: v1/view/settings.php:42 v2/App/Views/Admin/Tabs/settings.php:295
1419
  msgid "Promotion"
1420
  msgstr ""
1421
 
1422
+ #: v1/view/settings_cart_rules.php:8
1423
  msgid "Cart rules settings"
1424
  msgstr ""
1425
 
1426
+ #: v1/view/settings_cart_rules.php:15
1427
  msgid "Discount identifier in the backend"
1428
  msgstr ""
1429
 
1430
+ #: v1/view/settings_cart_rules.php:21
1431
  msgid "Discount Coupon Name"
1432
  msgstr ""
1433
 
1434
+ #: v1/view/settings_cart_rules.php:31
1435
  msgid "Coupon name to be used in the cart/checkout in the storefront"
1436
  msgstr ""
1437
 
1438
+ #: v1/view/settings_cart_rules.php:35
1439
  msgid "Discounts applied: {rule_name}"
1440
  msgstr ""
1441
 
1442
+ #: v1/view/settings_cart_rules.php:38
1443
  msgid ""
1444
  "- Rule name. If more than one rule applies in cart, then the rule names will "
1445
  "be shown separated by comma(,)"
1446
  msgstr ""
1447
 
1448
+ #: v1/view/settings_cart_rules.php:42
1449
  msgid "Eg: "
1450
  msgstr ""
1451
 
1452
+ #: v1/view/settings_cart_rules.php:53
1453
  msgid "Rule Setup for Cart:"
1454
  msgstr ""
1455
 
1456
+ #: v1/view/settings_cart_rules.php:59 v1/view/settings_price_rules.php:32
1457
  msgid "Apply first matched rule"
1458
  msgstr ""
1459
 
1460
+ #: v1/view/settings_cart_rules.php:65 v1/view/settings_cart_rules.php:67
1461
+ #: v1/view/settings_price_rules.php:38 v1/view/settings_price_rules.php:40
1462
  msgid "Apply all matched rules"
1463
  msgstr ""
1464
 
1465
+ #: v1/view/settings_cart_rules.php:74 v1/view/settings_cart_rules.php:76
1466
+ #: v1/view/settings_price_rules.php:47 v1/view/settings_price_rules.php:49
1467
  msgid "Apply biggest discount"
1468
  msgstr ""
1469
 
1470
+ #: v1/view/settings_cart_rules.php:85
1471
  msgid "Enable free shipping option"
1472
  msgstr ""
1473
 
1474
+ #: v1/view/settings_cart_rules.php:92 v1/view/settings_price_rules.php:313
1475
+ #: v1/view/view-pricing-rules.php:315 v1/view/view-pricing-rules.php:383
1476
+ #: v1/view/view-pricing-rules.php:473 v1/view/view-pricing-rules.php:525
1477
+ #: v1/view/view-pricing-rules.php:561
1478
  msgid "Supported in PRO version"
1479
  msgstr ""
1480
 
1481
+ #: v1/view/settings_cart_rules.php:105
1482
  msgid "Use Woocommerce free shipping"
1483
  msgstr ""
1484
 
1485
+ #: v1/view/settings_cart_rules.php:108
1486
  msgid "Use Woo-Discount free shipping"
1487
  msgstr ""
1488
 
1489
+ #: v1/view/settings_cart_rules.php:122
1490
  msgid "Free shipping text to be displayed"
1491
  msgstr ""
1492
 
1493
+ #: v1/view/settings_cart_rules.php:129
1494
  msgid "Free Shipping title"
1495
  msgstr ""
1496
 
1497
+ #: v1/view/settings_cart_rules.php:136
1498
  msgid "Draft"
1499
  msgstr ""
1500
 
1501
+ #: v1/view/settings_cart_rules.php:146
1502
  msgid "Exclude Draft products in product select box."
1503
  msgstr ""
1504
 
1505
+ #: v1/view/settings_general.php:6
1506
  msgid "General Settings"
1507
  msgstr ""
1508
 
1509
+ #: v1/view/settings_general.php:13
1510
  msgid "License Key :"
1511
  msgstr ""
1512
 
1513
+ #: v1/view/settings_general.php:20
1514
  msgid "Your Unique License Key"
1515
  msgstr ""
1516
 
1517
+ #: v1/view/settings_general.php:21
1518
  msgid "Validate Key"
1519
  msgstr ""
1520
 
1521
+ #: v1/view/settings_general.php:45
1522
  msgid "Tip: Install pro package before validating the licence"
1523
  msgstr ""
1524
 
1525
+ #: v1/view/settings_general.php:49
1526
  msgid "Install pro package for validating the licence"
1527
  msgstr ""
1528
 
1529
+ #: v1/view/settings_general.php:57
1530
  msgid "Enable dropdowns (applies only for the rule engine in the backend.)"
1531
  msgstr ""
1532
 
1533
+ #: v1/view/settings_general.php:62 v1/view/settings_general.php:79
1534
+ #: v1/view/settings_general.php:113 v1/view/settings_performance.php:21
1535
+ #: v1/view/settings_price_rules.php:86 v1/view/settings_price_rules.php:98
1536
+ #: v1/view/settings_price_rules.php:110 v1/view/settings_price_rules.php:151
1537
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:43
1538
+ #: v2/App/Views/Admin/Tabs/settings.php:55
1539
+ #: v2/App/Views/Admin/Tabs/settings.php:86
1540
+ #: v2/App/Views/Admin/Tabs/settings.php:158
1541
+ #: v2/App/Views/Admin/Tabs/settings.php:253
1542
+ #: v2/App/Views/Admin/Tabs/settings.php:270
1543
+ #: v2/App/Views/Admin/Tabs/settings.php:332
1544
  msgid "Yes"
1545
  msgstr ""
1546
 
1547
+ #: v1/view/settings_general.php:63 v1/view/settings_general.php:80
1548
+ #: v1/view/settings_general.php:114 v1/view/settings_performance.php:22
1549
+ #: v1/view/settings_price_rules.php:87 v1/view/settings_price_rules.php:99
1550
+ #: v1/view/settings_price_rules.php:111 v1/view/settings_price_rules.php:152
1551
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:48
1552
+ #: v2/App/Views/Admin/Tabs/settings.php:59
1553
+ #: v2/App/Views/Admin/Tabs/settings.php:90
1554
+ #: v2/App/Views/Admin/Tabs/settings.php:161
1555
+ #: v2/App/Views/Admin/Tabs/settings.php:257
1556
+ #: v2/App/Views/Admin/Tabs/settings.php:276
1557
+ #: v2/App/Views/Admin/Tabs/settings.php:337
1558
  msgid "No"
1559
  msgstr ""
1560
 
1561
+ #: v1/view/settings_general.php:66
1562
  msgid ""
1563
  "Disabling this setting may affect dropdowns in rule engine (Disabling this "
1564
  "setting is not recommended). Change this only if you know what you are doing."
1565
  msgstr ""
1566
 
1567
+ #: v1/view/settings_general.php:74
1568
  msgid "Force refresh the cart widget while add and remove item to cart"
1569
  msgstr ""
1570
 
1571
+ #: v1/view/settings_general.php:86 v2/App/Views/Admin/Tabs/settings.php:65
1572
  msgid ""
1573
  "Choose how discount rules should work when WooCommerce coupons (or third "
1574
  "party) coupons are used?"
1575
  msgstr ""
1576
 
1577
+ #: v1/view/settings_general.php:93 v2/App/Views/Admin/Tabs/settings.php:72
1578
  msgid "Let both coupons and discount rules run together"
1579
  msgstr ""
1580
 
1581
+ #: v1/view/settings_general.php:96 v2/App/Views/Admin/Tabs/settings.php:74
1582
  msgid "Disable the discount rules (coupons will work)"
1583
  msgstr ""
1584
 
1585
+ #: v1/view/settings_general.php:99 v2/App/Views/Admin/Tabs/settings.php:73
1586
  msgid "Disable the coupons (discount rules will work)"
1587
  msgstr ""
1588
 
1589
+ #: v1/view/settings_general.php:108
1590
  msgid ""
1591
  "Hide $0.00 (zero value) of coupon codes in the totals column. Useful when a "
1592
  "coupon used with discount rule conditions"
1593
  msgstr ""
1594
 
1595
+ #: v1/view/settings_performance.php:8
1596
  msgid "Performance settings"
1597
  msgstr ""
1598
 
1599
+ #: v1/view/settings_performance.php:16
1600
  msgid "Enable cache for variable products table content"
1601
  msgstr ""
1602
 
1603
+ #: v1/view/settings_performance.php:28 v1/view/settings_performance.php:32
1604
  msgid "Clear cache"
1605
  msgstr ""
1606
 
1607
+ #: v1/view/settings_price_rules.php:8
1608
  msgid "Price rules settings"
1609
  msgstr ""
1610
 
1611
+ #: v1/view/settings_price_rules.php:14
1612
  msgid "Rule setup"
1613
  msgstr ""
1614
 
1615
+ #: v1/view/settings_price_rules.php:15
1616
  msgid "Display"
1617
  msgstr ""
1618
 
1619
+ #: v1/view/settings_price_rules.php:16
1620
  msgid "Offer table"
1621
  msgstr ""
1622
 
1623
+ #: v1/view/settings_price_rules.php:17
1624
  msgid "Sale badge"
1625
  msgstr ""
1626
 
1627
+ #: v1/view/settings_price_rules.php:26
1628
  msgid "Rule Setup"
1629
  msgstr ""
1630
 
1631
+ #: v1/view/settings_price_rules.php:58
1632
  msgid "Apply discount based on"
1633
  msgstr ""
1634
 
1635
+ #: v1/view/settings_price_rules.php:65 v2/App/Views/Admin/Tabs/settings.php:28
1636
  msgid "Sale price"
1637
  msgstr ""
1638
 
1639
+ #: v1/view/settings_price_rules.php:68 v2/App/Views/Admin/Tabs/settings.php:29
1640
  msgid "Regular price"
1641
  msgstr ""
1642
 
1643
+ #: v1/view/settings_price_rules.php:73
1644
  msgid ""
1645
  "If sale price is not entered in your products, the regular price will be "
1646
  "taken"
1647
  msgstr ""
1648
 
1649
+ #: v1/view/settings_price_rules.php:81
1650
  msgid ""
1651
  "Auto add free product when coupon is applied (For coupon-activated rules)"
1652
  msgstr ""
1653
 
1654
+ #: v1/view/settings_price_rules.php:93
1655
  msgid ""
1656
  "Auto add free product when checkout fields changed (For purchase history "
1657
  "rules)"
1658
  msgstr ""
1659
 
1660
+ #: v1/view/settings_price_rules.php:105
1661
  msgid "Include variants when just parent products are chosen in the rules"
1662
  msgstr ""
1663
 
1664
+ #: v1/view/settings_price_rules.php:122
1665
  msgid "Show Price discount on product pages :"
1666
  msgstr ""
1667
 
1668
+ #: v1/view/settings_price_rules.php:128
1669
+ #: v2/App/Views/Admin/Tabs/settings.php:228
1670
  msgid "Show when a rule condition is matched"
1671
  msgstr ""
1672
 
1673
+ #: v1/view/settings_price_rules.php:131
1674
+ #: v2/App/Views/Admin/Tabs/settings.php:229
1675
  msgid "Show after a rule condition is matched"
1676
  msgstr ""
1677
 
1678
+ #: v1/view/settings_price_rules.php:134
1679
+ #: v2/App/Views/Admin/Tabs/settings.php:230
1680
  msgid "Shown on quantity update (dynamic)"
1681
  msgstr ""
1682
 
1683
+ #: v1/view/settings_price_rules.php:137 v1/view/settings_price_rules.php:211
1684
+ #: v1/view/settings_price_rules.php:229 v1/view/settings_price_rules.php:247
1685
+ #: v1/view/settings_price_rules.php:265
1686
+ #: v2/App/Views/Admin/Tabs/settings.php:487
1687
  msgid "Don't Show"
1688
  msgstr ""
1689
 
1690
+ #: v1/view/settings_price_rules.php:146
1691
  msgid ""
1692
  "Show a crossed-out original price along with discounted price at line items "
1693
  "in cart"
1694
  msgstr ""
1695
 
1696
+ #: v1/view/settings_price_rules.php:163
1697
  msgid "Discount Table :"
1698
  msgstr ""
1699
 
1700
+ #: v1/view/settings_price_rules.php:172
1701
  msgid "Default layout"
1702
  msgstr ""
1703
 
1704
+ #: v1/view/settings_price_rules.php:175
1705
  msgid "Advance layout"
1706
  msgstr ""
1707
 
1708
+ #: v1/view/settings_price_rules.php:184
1709
  msgid "Table placement:"
1710
  msgstr ""
1711
 
1712
+ #: v1/view/settings_price_rules.php:190
1713
  msgid "Before cart form"
1714
  msgstr ""
1715
 
1716
+ #: v1/view/settings_price_rules.php:193
1717
  msgid "After cart form"
1718
  msgstr ""
1719
 
1720
+ #: v1/view/settings_price_rules.php:202
1721
  msgid "Table header :"
1722
  msgstr ""
1723
 
1724
+ #: v1/view/settings_price_rules.php:220
1725
  msgid "Title column on table :"
1726
  msgstr ""
1727
 
1728
+ #: v1/view/settings_price_rules.php:238
1729
  msgid "Range column on table :"
1730
  msgstr ""
1731
 
1732
+ #: v1/view/settings_price_rules.php:256
1733
  msgid "Discount column on table :"
1734
  msgstr ""
1735
 
1736
+ #: v1/view/settings_price_rules.php:278
1737
  msgid "Show a Sale badge on product pages :"
1738
  msgstr ""
1739
 
1740
+ #: v1/view/settings_price_rules.php:284
1741
+ #: v2/App/Views/Admin/Tabs/settings.php:115
1742
  msgid "Do not show"
1743
  msgstr ""
1744
 
1745
+ #: v1/view/settings_price_rules.php:287
1746
+ #: v2/App/Views/Admin/Tabs/settings.php:113
1747
  msgid "Show only after a rule condition is matched exactly"
1748
  msgstr ""
1749
 
1750
+ #: v1/view/settings_price_rules.php:290
1751
  msgid ""
1752
  "Show on products that are covered under any price based discount rule in the "
1753
  "plugin"
1754
  msgstr ""
1755
 
1756
+ #: v1/view/settings_price_rules.php:301
1757
+ #: v2/App/Views/Admin/Tabs/settings.php:121
1758
  msgid "Do you want to customize the sale badge?"
1759
  msgstr ""
1760
 
1761
+ #: v1/view/settings_price_rules.php:308
1762
+ #: v2/App/Views/Admin/Tabs/settings.php:131
1763
  msgid "Yes, I would like to customize the sale badge"
1764
  msgstr ""
1765
 
1766
+ #: v1/view/settings_price_rules.php:310
1767
+ #: v2/App/Views/Admin/Tabs/settings.php:135
1768
  msgid ""
1769
  "Force override the label for sale badge (useful when your theme has override "
1770
  "for sale badge)."
1771
  msgstr ""
1772
 
1773
+ #: v1/view/settings_price_rules.php:325
1774
  msgid "Sale badge content (TIP: You can use HTML inside)"
1775
  msgstr ""
1776
 
1777
+ #: v1/view/settings_price_rules.php:332
1778
  msgid ""
1779
  "IMPORTANT NOTE: This customized sale badge will be applicable only for "
1780
  "products that are part of the discount rules configured in this plugin"
1781
  msgstr ""
1782
 
1783
+ #: v1/view/settings_price_rules.php:336
1784
  msgid "Eg:"
1785
  msgstr ""
1786
 
1787
+ #: v1/view/settings_promotion.php:8
1788
  msgid "Promotion settings"
1789
  msgstr ""
1790
 
1791
+ #: v1/view/settings_promotion.php:16
1792
  msgid "Display savings text (for price rules)"
1793
  msgstr ""
1794
 
1795
+ #: v1/view/settings_promotion.php:25 v2/App/Views/Admin/Tabs/settings.php:306
1796
  msgid "On each line item"
1797
  msgstr ""
1798
 
1799
+ #: v1/view/settings_promotion.php:28 v2/App/Views/Admin/Tabs/settings.php:307
1800
  msgid "On after total"
1801
  msgstr ""
1802
 
1803
+ #: v1/view/settings_promotion.php:31 v2/App/Views/Admin/Tabs/settings.php:308
1804
  msgid "Both in line item and after total"
1805
  msgstr ""
1806
 
1807
+ #: v1/view/settings_promotion.php:39 v2/App/Views/Admin/Tabs/settings.php:315
1808
  msgid "Savings text to show"
1809
  msgstr ""
1810
 
1811
+ #: v1/view/settings_promotion.php:47
1812
  msgid "{{total_discount_price}} -> Total discount applied"
1813
  msgstr ""
1814
 
1815
+ #: v1/view/settings_promotion.php:55
1816
  msgid "Show a message on applying price rules in cart"
1817
  msgstr ""
1818
 
1819
+ #: v1/view/settings_promotion.php:73 v1/view/settings_promotion.php:108
1820
+ #: v1/view/view-cart-rules.php:730
1821
  msgid "Message"
1822
  msgstr ""
1823
 
1824
+ #: v1/view/settings_promotion.php:81 v1/view/settings_promotion.php:116
1825
  msgid "{{title}} -> Rule title"
1826
  msgstr ""
1827
 
1828
+ #: v1/view/settings_promotion.php:82 v1/view/settings_promotion.php:117
1829
  msgid "{{description}} -> Rule description"
1830
  msgstr ""
1831
 
1832
+ #: v1/view/settings_promotion.php:90
1833
  msgid "Show a message on applying cart rules in cart"
1834
  msgstr ""
1835
 
1836
+ #: v1/view/settings_promotion.php:125
1837
  msgid ""
1838
  "Subtotal based promo text (available only in cart rules -> subtotal based "
1839
  "discounts)"
1840
  msgstr ""
1841
 
1842
+ #: v1/view/settings_promotion.php:134
1843
  msgid "Shop page"
1844
  msgstr ""
1845
 
1846
+ #: v1/view/settings_promotion.php:137
1847
  msgid "Product page"
1848
  msgstr ""
1849
 
1850
+ #: v1/view/settings_promotion.php:140
1851
  msgid "Cart page"
1852
  msgstr ""
1853
 
1854
+ #: v1/view/settings_promotion.php:143
1855
  msgid "Checkout page"
1856
  msgstr ""
1857
 
1858
+ #: v1/view/settings_taxonomy.php:32
1859
  msgid ""
1860
  "Choose taxonomies that can be supported in the discount rules (as categories)"
1861
  msgstr ""
1862
 
1863
+ #: v1/view/settings_taxonomy.php:36
1864
  msgid ""
1865
  "Useful when you want to provide a taxonomy based discount. The selected "
1866
  "taxonomies here will be available as categories. So you can use the category "
1868
  "More examples can be found in the documentation"
1869
  msgstr ""
1870
 
1871
+ #: v1/view/template/discount-table.php:23
1872
  msgid "Hide table"
1873
  msgstr ""
1874
 
1875
+ #: v1/view/template/discount-table.php:25
1876
  msgid "This effect displays only for you (Admin)"
1877
  msgstr ""
1878
 
1879
+ #: v1/view/template/discount-table.php:39
1880
  msgid "Range"
1881
  msgstr ""
1882
 
1883
+ #: v1/view/template/discount-table.php:74
1884
  msgid "No Active Discounts."
1885
  msgstr ""
1886
 
1887
+ #: v1/view/template/loop/sale-flash.php:23
1888
+ #: v1/view/template/single-product/sale-flash.php:23
1889
+ #: v2/App/Views/Templates/loop/sale-flash.php:23
1890
+ #: v2/App/Views/Templates/single-product/sale-flash.php:23
1891
  msgid "Sale!"
1892
  msgstr ""
1893
 
1894
+ #: v1/view/template/sidebar.php:7 v2/App/Views/Admin/Tabs/DiscountRule.php:302
1895
  msgid "Looking for more features? Upgrade to PRO"
1896
  msgstr ""
1897
 
1898
+ #: v1/view/template/sidebar.php:19 v2/App/Views/Admin/Tabs/DiscountRule.php:307
1899
  msgid "With PRO version, you can create:"
1900
  msgstr ""
1901
 
1902
+ #: v1/view/template/sidebar.php:20 v2/App/Views/Admin/Tabs/DiscountRule.php:308
1903
  msgid "- Categories based discounts"
1904
  msgstr ""
1905
 
1906
+ #: v1/view/template/sidebar.php:21 v2/App/Views/Admin/Tabs/DiscountRule.php:309
1907
  msgid "- User roles based discounts"
1908
  msgstr ""
1909
 
1910
+ #: v1/view/template/sidebar.php:22 v2/App/Views/Admin/Tabs/DiscountRule.php:310
1911
  msgid "- Buy One Get One Free deals"
1912
  msgstr ""
1913
 
1914
+ #: v1/view/template/sidebar.php:23 v2/App/Views/Admin/Tabs/DiscountRule.php:311
1915
  msgid "- Buy X Get Y deals"
1916
  msgstr ""
1917
 
1918
+ #: v1/view/template/sidebar.php:24
1919
  #, php-format
1920
  msgid "- Buy 2, get 1 at 50% discount"
1921
  msgstr ""
1922
 
1923
+ #: v1/view/template/sidebar.php:25 v2/App/Views/Admin/Tabs/DiscountRule.php:312
1924
  msgid "- Buy 3 for $10 (Package / Bundle [Set] Discount)"
1925
  msgstr ""
1926
 
1927
+ #: v1/view/template/sidebar.php:26 v2/App/Views/Admin/Tabs/DiscountRule.php:313
1928
  msgid "- Different discounts with one coupon code"
1929
  msgstr ""
1930
 
1931
+ #: v1/view/template/sidebar.php:27
1932
  msgid "- Purchase history based discounts"
1933
  msgstr ""
1934
 
1935
+ #: v1/view/template/sidebar.php:28
1936
  msgid "- Free product / gift"
1937
  msgstr ""
1938
 
1939
+ #: v1/view/template/sidebar.php:29
1940
  msgid "- Discount for variants"
1941
  msgstr ""
1942
 
1943
+ #: v1/view/template/sidebar.php:30
1944
  msgid "- Conditional discounts"
1945
  msgstr ""
1946
 
1947
+ #: v1/view/template/sidebar.php:31
1948
  msgid "- Fixed cost discounts"
1949
  msgstr ""
1950
 
1951
+ #: v1/view/template/sidebar.php:32
1952
  msgid "- Offer fixed price on certain conditions"
1953
  msgstr ""
1954
 
1955
+ #: v1/view/view-cart-rules.php:56 v1/view/view-pricing-rules.php:38
1956
  msgid "Close and go back to list"
1957
  msgstr ""
1958
 
1959
+ #: v1/view/view-cart-rules.php:60
1960
  msgid "New Cart Rule"
1961
  msgstr ""
1962
 
1963
+ #: v1/view/view-cart-rules.php:62
1964
  msgid "Edit Cart Rule"
1965
  msgstr ""
1966
 
1967
+ #: v1/view/view-cart-rules.php:75 v1/view/view-pricing-rules.php:57
1968
+ #: v2/App/Views/Admin/Rules/Manage.php:13
1969
+ #: v2/App/Views/Admin/Rules/Manage.php:20
1970
  msgid "This rule is not running currently: "
1971
  msgstr ""
1972
 
1973
+ #: v1/view/view-cart-rules.php:84 v1/view/view-pricing-rules.php:66
1974
  msgid "Priority :"
1975
  msgstr ""
1976
 
1977
+ #: v1/view/view-cart-rules.php:86
1978
  msgid ""
1979
  "The Simple Ranking concept to said, which one is going to execute first and "
1980
  "so on."
1981
  msgstr ""
1982
 
1983
+ #: v1/view/view-cart-rules.php:98 v1/view/view-pricing-rules.php:81
1984
  msgid "Rule Name"
1985
  msgstr ""
1986
 
1987
+ #: v1/view/view-cart-rules.php:100 v1/view/view-cart-rules.php:112
1988
+ #: v1/view/view-pricing-rules.php:95
1989
  msgid "Rule Descriptions."
1990
  msgstr ""
1991
 
1992
+ #: v1/view/view-cart-rules.php:105 v1/view/view-pricing-rules.php:89
1993
  msgid "ex. Standard Rule."
1994
  msgstr ""
1995
 
1996
+ #: v1/view/view-cart-rules.php:110 v1/view/view-pricing-rules.php:94
1997
  msgid "Rule Description"
1998
  msgstr ""
1999
 
2000
+ #: v1/view/view-cart-rules.php:121 v1/view/view-pricing-rules.php:130
2001
  msgid "Validity"
2002
  msgstr ""
2003
 
2004
+ #: v1/view/view-cart-rules.php:122 v1/view/view-pricing-rules.php:131
2005
  msgid "Period of Rule Active. Format: month/day/Year Hour:Min"
2006
  msgstr ""
2007
 
2008
+ #: v1/view/view-cart-rules.php:135 v1/view/view-pricing-rules.php:144
2009
+ #: v1/view/view-pricing-rules.php:652
2010
  msgid "From"
2011
  msgstr ""
2012
 
2013
+ #: v1/view/view-cart-rules.php:139
2014
  msgid "To"
2015
  msgstr ""
2016
 
2017
+ #: v1/view/view-cart-rules.php:140 v1/view/view-pricing-rules.php:149
2018
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:122
2019
  #, php-format
2020
  msgid "Current date and time: %s"
2021
  msgstr ""
2022
 
2023
+ #: v1/view/view-cart-rules.php:145 v1/view/view-cart-rules.php:750
2024
+ #: v1/view/view-pricing-rules.php:183 v1/view/view-pricing-rules.php:701
2025
  msgid "Next"
2026
  msgstr ""
2027
 
2028
+ #: v1/view/view-cart-rules.php:149
2029
  msgid "Cart Conditions"
2030
  msgstr ""
2031
 
2032
+ #: v1/view/view-cart-rules.php:152
2033
  msgid "Add Condition"
2034
  msgstr ""
2035
 
2036
+ #: v1/view/view-cart-rules.php:241
2037
  msgid "Categories In Cart"
2038
  msgstr ""
2039
 
2040
+ #: v1/view/view-cart-rules.php:295 v1/view/view-cart-rules.php:297
2041
  msgid "Email with TLD (Eg: edu)"
2042
  msgstr ""
2043
 
2044
+ #: v1/view/view-cart-rules.php:713
2045
  msgid "Promotion message"
2046
  msgstr ""
2047
 
2048
+ #: v1/view/view-cart-rules.php:718
2049
  msgid "Subtotal from"
2050
  msgstr ""
2051
 
2052
+ #: v1/view/view-cart-rules.php:724
2053
  #, php-format
2054
  msgid ""
2055
  "Set a threshold from which you want to start showing the promotion "
2058
  "text when his cart subtotal reaches 900"
2059
  msgstr ""
2060
 
2061
+ #: v1/view/view-cart-rules.php:735
2062
  #, php-format
2063
  msgid "Spend {{difference_amount}} more and get 10% discount"
2064
  msgstr ""
2065
 
2066
+ #: v1/view/view-cart-rules.php:737
2067
  msgid "{{difference_amount}} -> Difference amount to get discount"
2068
  msgstr ""
2069
 
2070
+ #: v1/view/view-cart-rules.php:738
2071
  #, php-format
2072
  msgid "<b>Eg:</b> Spend {{difference_amount}} more and get 10% discount"
2073
  msgstr ""
2074
 
2075
+ #: v1/view/view-cart-rules.php:749 v1/view/view-cart-rules.php:846
2076
+ #: v1/view/view-pricing-rules.php:700 v1/view/view-pricing-rules.php:1019
2077
  msgid "Previous"
2078
  msgstr ""
2079
 
2080
+ #: v1/view/view-cart-rules.php:752
2081
  msgid "Guide to create cart rules"
2082
  msgstr ""
2083
 
2084
+ #: v1/view/view-cart-rules.php:772
2085
  msgid "Discount Type :"
2086
  msgstr ""
2087
 
2088
+ #: v1/view/view-cart-rules.php:791 v1/view/view-cart-rules.php:793
2089
  msgid "Product Discount"
2090
  msgstr ""
2091
 
2092
+ #: v1/view/view-cart-rules.php:800 v1/view/view-cart-rules.php:802
2093
  msgid "Free shipping"
2094
  msgstr ""
2095
 
2096
+ #: v1/view/view-cart-rules.php:811
2097
  msgid "value :"
2098
  msgstr ""
2099
 
2100
+ #: v1/view/view-cart-rules.php:819
2101
  msgid "Select products :"
2102
  msgstr ""
2103
 
2104
+ #: v1/view/view-cart-rules.php:833
2105
  msgid "Quantity :"
2106
  msgstr ""
2107
 
2108
+ #: v1/view/view-pricing-rules.php:42
2109
  msgid "New Price Rule"
2110
  msgstr ""
2111
 
2112
+ #: v1/view/view-pricing-rules.php:44
2113
  msgid "Edit Price Rule"
2114
  msgstr ""
2115
 
2116
+ #: v1/view/view-pricing-rules.php:67
2117
  msgid ""
2118
  "The Simple Ranking concept, which one is going to execute first and so on."
2119
  msgstr ""
2120
 
2121
+ #: v1/view/view-pricing-rules.php:82
2122
  msgid "Rule name / title."
2123
  msgstr ""
2124
 
2125
+ #: v1/view/view-pricing-rules.php:105
2126
  msgid "Method"
2127
  msgstr ""
2128
 
2129
+ #: v1/view/view-pricing-rules.php:106
2130
  msgid "Method to Apply."
2131
  msgstr ""
2132
 
2133
+ #: v1/view/view-pricing-rules.php:113
2134
  msgid ""
2135
  "Quantity / category / product / user role based discounts and BOGO deals "
2136
  msgstr ""
2137
 
2138
+ #: v1/view/view-pricing-rules.php:120 v1/view/view-pricing-rules.php:122
2139
  msgid "Dependent / conditional based discount (by individual product)"
2140
  msgstr ""
2141
 
2142
+ #: v1/view/view-pricing-rules.php:148
2143
  msgid "To - Leave Empty if No Expiry"
2144
  msgstr ""
2145
 
2146
+ #: v1/view/view-pricing-rules.php:159
2147
  msgid "Format for advanced table display option (see plugin settings)"
2148
  msgstr ""
2149
 
2150
+ #: v1/view/view-pricing-rules.php:161
2151
  msgid "Used when advanced table display option is set in the plugin settings"
2152
  msgstr ""
2153
 
2154
+ #: v1/view/view-pricing-rules.php:164
2155
  msgid "Buy {{min_quantity}} or more quantity and get {{discount}} as discount"
2156
  msgstr ""
2157
 
2158
+ #: v1/view/view-pricing-rules.php:167
2159
  msgid "{{title}} -> Title"
2160
  msgstr ""
2161
 
2162
+ #: v1/view/view-pricing-rules.php:168
2163
  msgid "{{description}} -> Description"
2164
  msgstr ""
2165
 
2166
+ #: v1/view/view-pricing-rules.php:169
2167
  msgid "{{min_quantity}} -> Minimum quantity"
2168
  msgstr ""
2169
 
2170
+ #: v1/view/view-pricing-rules.php:170
2171
  msgid "{{max_quantity}} -> Maximum quantity"
2172
  msgstr ""
2173
 
2174
+ #: v1/view/view-pricing-rules.php:171
2175
  msgid "{{discount}} -> Discount"
2176
  msgstr ""
2177
 
2178
+ #: v1/view/view-pricing-rules.php:172
2179
  msgid "{{discounted_price}} -> Discounted price"
2180
  msgstr ""
2181
 
2182
+ #: v1/view/view-pricing-rules.php:173
2183
  msgid "{{condition}} -> Rule condition text"
2184
  msgstr ""
2185
 
2186
+ #: v1/view/view-pricing-rules.php:188
2187
  msgid "Discount Conditions"
2188
  msgstr ""
2189
 
2190
+ #: v1/view/view-pricing-rules.php:193
2191
  msgid "Apply To"
2192
  msgstr ""
2193
 
2194
+ #: v1/view/view-pricing-rules.php:202
2195
  msgid "All products"
2196
  msgstr ""
2197
 
2198
+ #: v1/view/view-pricing-rules.php:206
2199
  msgid "Specific products"
2200
  msgstr ""
2201
 
2202
+ #: v1/view/view-pricing-rules.php:212 v1/view/view-pricing-rules.php:214
2203
  msgid "Specific categories"
2204
  msgstr ""
2205
 
2206
+ #: v1/view/view-pricing-rules.php:221 v1/view/view-pricing-rules.php:223
2207
  msgid "Specific attributes"
2208
  msgstr ""
2209
 
2210
+ #: v1/view/view-pricing-rules.php:234
2211
  msgid ""
2212
  "Check this box to count item quantities in cart cumulatively across products"
2213
  msgstr ""
2214
 
2215
+ #: v1/view/view-pricing-rules.php:246
2216
  msgid "Check this box to count quantities cumulatively across category(ies)"
2217
  msgstr ""
2218
 
2219
+ #: v1/view/view-pricing-rules.php:249
2220
  msgid "Check this box to apply child category(ies)"
2221
  msgstr ""
2222
 
2223
+ #: v1/view/view-pricing-rules.php:263
2224
  msgid "Check this box to count quantities cumulatively across attribute"
2225
  msgstr ""
2226
 
2227
+ #: v1/view/view-pricing-rules.php:276
2228
  #, php-format
2229
  msgid ""
2230
  "Use this option to exclude selected products from getting a discount. <a "
2231
  "href=\"%s\">Read docs</a>."
2232
  msgstr ""
2233
 
2234
+ #: v1/view/view-pricing-rules.php:298
2235
  msgid "Exclude sale items"
2236
  msgstr ""
2237
 
2238
+ #: v1/view/view-pricing-rules.php:301
2239
  msgid ""
2240
  "Tick this checkbox if you wish to exclude products that already have a sale "
2241
  "price set via WooCommerce."
2242
  msgstr ""
2243
 
2244
+ #: v1/view/view-pricing-rules.php:309
2245
  msgid "Check this box if the rule should not apply to items on sale."
2246
  msgstr ""
2247
 
2248
+ #: v1/view/view-pricing-rules.php:328
2249
  msgid "Customers"
2250
  msgstr ""
2251
 
2252
+ #: v1/view/view-pricing-rules.php:331
2253
  #, php-format
2254
  msgid ""
2255
  "Use this option to apply the rule for specific customers. <a href=\"%s"
2256
  "\">Read docs</a>."
2257
  msgstr ""
2258
 
2259
+ #: v1/view/view-pricing-rules.php:339 v1/view/view-pricing-rules.php:673
2260
  msgid "All"
2261
  msgstr ""
2262
 
2263
+ #: v1/view/view-pricing-rules.php:346 v1/view/view-pricing-rules.php:348
2264
  msgid "Only Given"
2265
  msgstr ""
2266
 
2267
+ #: v1/view/view-pricing-rules.php:362
2268
  msgid "User roles"
2269
  msgstr ""
2270
 
2271
+ #: v1/view/view-pricing-rules.php:365
2272
  #, php-format
2273
  msgid ""
2274
  "Use this option to set a discount based on user roles. <a href=\"%s\">Read "
2275
  "docs</a>."
2276
  msgstr ""
2277
 
2278
+ #: v1/view/view-pricing-rules.php:373 v1/view/view-pricing-rules.php:409
2279
+ #: v1/view/view-pricing-rules.php:500 v1/view/view-pricing-rules.php:549
2280
  msgid "Do not use"
2281
  msgstr ""
2282
 
2283
+ #: v1/view/view-pricing-rules.php:394
2284
  msgid "Coupon"
2285
  msgstr ""
2286
 
2287
+ #: v1/view/view-pricing-rules.php:397
2288
  #, php-format
2289
  msgid ""
2290
  "Useful if you wish to activate this discount rule via coupon code.<br>You "
2292
  "WooCommerce -> Coupons. <a href=\"%s\">Read docs</a>."
2293
  msgstr ""
2294
 
2295
+ #: v1/view/view-pricing-rules.php:411
2296
  msgid "Apply if any one coupon applied (Select from WooCommerce)"
2297
  msgstr ""
2298
 
2299
+ #: v1/view/view-pricing-rules.php:412
2300
  msgid "Apply if all coupon applied (Select from WooCommerce)"
2301
  msgstr ""
2302
 
2303
+ #: v1/view/view-pricing-rules.php:463
2304
  msgid "Make sure you have created the coupon already"
2305
  msgstr ""
2306
 
2307
+ #: v1/view/view-pricing-rules.php:484 v2/App/Conditions/CartSubTotal.php:14
2308
  msgid "Subtotal"
2309
  msgstr ""
2310
 
2311
+ #: v1/view/view-pricing-rules.php:487
2312
  #, php-format
2313
  msgid ""
2314
  "Useful when you want to limit the rule based on subtotal. (Use this only "
2317
  "discount rules."
2318
  msgstr ""
2319
 
2320
+ #: v1/view/view-pricing-rules.php:501
2321
  msgid "Subtotal atleast"
2322
  msgstr ""
2323
 
2324
+ #: v1/view/view-pricing-rules.php:506
2325
  msgid "Enter the amount"
2326
  msgstr ""
2327
 
2328
+ #: v1/view/view-pricing-rules.php:516
2329
  msgid "Supported in WooCommerce 3.x"
2330
  msgstr ""
2331
 
2332
+ #: v1/view/view-pricing-rules.php:539
2333
  #, php-format
2334
  msgid ""
2335
  "Useful for providing discounts based on previous purchase history."
2337
  "spent so far. <a href=\"%s\">Read docs</a>."
2338
  msgstr ""
2339
 
2340
+ #: v1/view/view-pricing-rules.php:644
2341
  msgid "Any"
2342
  msgstr ""
2343
 
2344
+ #: v1/view/view-pricing-rules.php:645
2345
  msgid "Each"
2346
  msgstr ""
2347
 
2348
+ #: v1/view/view-pricing-rules.php:646
2349
  msgid "Combine"
2350
  msgstr ""
2351
 
2352
+ #: v1/view/view-pricing-rules.php:649
2353
  msgid "More than or equal to"
2354
  msgstr ""
2355
 
2356
+ #: v1/view/view-pricing-rules.php:651
2357
  msgid "Equal"
2358
  msgstr ""
2359
 
2360
+ #: v1/view/view-pricing-rules.php:656
2361
  msgid "to"
2362
  msgstr ""
2363
 
2364
+ #: v1/view/view-pricing-rules.php:660
2365
  msgid "Product(s) from"
2366
  msgstr ""
2367
 
2368
+ #: v1/view/view-pricing-rules.php:666
2369
  msgid "Apply discount in product(s)"
2370
  msgstr ""
2371
 
2372
+ #: v1/view/view-pricing-rules.php:667
2373
  msgid "Apply discount in category(ies)"
2374
  msgstr ""
2375
 
2376
+ #: v1/view/view-pricing-rules.php:671
2377
  msgid "and get discount on "
2378
  msgstr ""
2379
 
2380
+ #: v1/view/view-pricing-rules.php:674
2381
  msgid "First quantity(s)"
2382
  msgstr ""
2383
 
2384
+ #: v1/view/view-pricing-rules.php:675
2385
  msgid "Skip first quantity(s)"
2386
  msgstr ""
2387
 
2388
+ #: v1/view/view-pricing-rules.php:680
2389
  msgid " Product(s) "
2390
  msgstr ""
2391
 
2392
+ #: v1/view/view-pricing-rules.php:684
2393
  msgid "Category(ies)"
2394
  msgstr ""
2395
 
2396
+ #: v1/view/view-pricing-rules.php:695
2397
  msgid "Guide for product dependent rules"
2398
  msgstr ""
2399
 
2400
+ #: v1/view/view-pricing-rules.php:711
2401
  msgid "Add quantity ranges"
2402
  msgstr ""
2403
 
2404
+ #: v1/view/view-pricing-rules.php:716
2405
  msgid ""
2406
  "Bundle (Set) Discount should NOT be mixed with any other adjustment types "
2407
  "when adding ranges. Example: If your first range's adjustment type is Bundle "
2408
  "(Set) Discount, other ranges should also be same type."
2409
  msgstr ""
2410
 
2411
+ #: v1/view/view-pricing-rules.php:886
2412
  msgid "Cheapest in cart - selected category(ies)"
2413
  msgstr ""
2414
 
2415
+ #: v1/view/view-pricing-rules.php:887
2416
  msgid "Cheapest in cart - selected item(s)"
2417
  msgstr ""
2418
 
2419
+ #: v1/view/view-pricing-rules.php:888
2420
  msgid "Cheapest among all items in cart"
2421
  msgstr ""
2422
 
2423
+ #: v1/view/view-pricing-rules.php:985
2424
  msgid ""
2425
  "<b>Example for Bundle (Set) Discount:</b> 3 for $10, 6 for $20<br>So "
2426
  "customer can add 3 products / quantities and get them for $10<br><b>NOTE:</"
2428
  "the 3 for $10 deal)"
2429
  msgstr ""
2430
 
2431
+ #: v1/view/view-pricing-rules.php:987 v1/view/view-pricing-rules.php:997
2432
  msgid "Read docs"
2433
  msgstr ""
2434
 
2435
+ #: v1/view/view-pricing-rules.php:995
2436
  msgid ""
2437
  "<b>Example for Fixed Price Per Unit:</b> Product A cost is $20. If customers "
2438
  "buy 5 to 10, they can get at $15 each (per unit).<br>Customer adds 6 "
2440
  "b> Enter the Unit price like 15"
2441
  msgstr ""
2442
 
2443
+ #: v1/view/view-pricing-rules.php:1002
2444
  msgid "Guide to create perfect BOGO rules"
2445
  msgstr ""
2446
 
2447
+ #: v1/view/view-pricing-rules.php:1012
2448
  msgid "Percent"
2449
  msgstr ""
2450
 
2451
+ #: v1/view/view-pricing-rules.php:1013
2452
  msgid "Fixed"
2453
  msgstr ""
2454
+
2455
+ #: v2/App/Compatibility/CompositeProductsBySomewhereWarm.php:44
2456
+ msgid "Add compatible for WooCommerce Composite Products"
2457
+ msgstr ""
2458
+
2459
+ #: v2/App/Compatibility/CompositeProductsBySomewhereWarm.php:47
2460
+ msgid ""
2461
+ "Limitation: Product page strikeout. We suggest to disable strikeout on "
2462
+ "product page."
2463
+ msgstr ""
2464
+
2465
+ #: v2/App/Compatibility/CurrencySwitcherByRealmag777.php:58
2466
+ #: v2/App/Compatibility/CurrencySwitcherByVillatheme.php:56
2467
+ #: v2/App/Compatibility/CurrencySwitcherByWPWham.php:44
2468
+ msgid "Add compatible for WooCommerce Currency Switcher"
2469
+ msgstr ""
2470
+
2471
+ #: v2/App/Compatibility/ExtraProductOptionsProByThemeHigh.php:52
2472
+ msgid "Add compatible for WooCommerce Extra Product Options"
2473
+ msgstr ""
2474
+
2475
+ #: v2/App/Compatibility/ExtraProductOptionsProByThemeHigh.php:55
2476
+ msgid "Limitation: Strikeout for add-on price and subtotal in product page."
2477
+ msgstr ""
2478
+
2479
+ #: v2/App/Compatibility/ProductAddOnsByWooCommerce.php:97
2480
+ msgid "Add compatible for WooCommerce Product Add Ons"
2481
+ msgstr ""
2482
+
2483
+ #: v2/App/Compatibility/WholesalePricesByRymeraWebCo.php:51
2484
+ msgid "Add compatible for WooCommerce Wholesale Prices"
2485
+ msgstr ""
2486
+
2487
+ #: v2/App/Conditions/CartLineItemsCount.php:13
2488
+ msgid "Line Item Count"
2489
+ msgstr ""
2490
+
2491
+ #: v2/App/Conditions/CartLineItemsCount.php:14
2492
+ #: v2/App/Conditions/CartSubTotal.php:15 v2/App/Helpers/ProOptions.php:78
2493
+ #: v2/App/Helpers/ProOptions.php:134 v2/App/Helpers/ProOptions.php:142
2494
+ #: v2/App/Helpers/ProOptions.php:150 v2/App/Views/Admin/Tabs/settings.php:241
2495
+ msgid "Cart"
2496
+ msgstr ""
2497
+
2498
+ #: v2/App/Controllers/Admin/Settings.php:159
2499
+ msgid ""
2500
+ "We found that your were using our old \"Woo discount rules\" plugin, Please "
2501
+ "disable it!"
2502
+ msgstr ""
2503
+
2504
+ #: v2/App/Controllers/Admin/Settings.php:215
2505
+ msgid "no results"
2506
+ msgstr ""
2507
+
2508
+ #: v2/App/Controllers/Admin/Settings.php:216
2509
+ msgid "Select Values"
2510
+ msgstr ""
2511
+
2512
+ #: v2/App/Controllers/Admin/Settings.php:404
2513
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:211
2514
+ msgid " - (Running)"
2515
+ msgstr ""
2516
+
2517
+ #: v2/App/Controllers/Admin/Settings.php:405
2518
+ msgid "Oops!! something went wrong!"
2519
+ msgstr ""
2520
+
2521
+ #: v2/App/Controllers/Admin/Settings.php:406
2522
+ msgid "Rule duplicated successfully!"
2523
+ msgstr ""
2524
+
2525
+ #: v2/App/Controllers/Admin/Settings.php:407
2526
+ msgid "Rule deleted successfully!"
2527
+ msgstr ""
2528
+
2529
+ #: v2/App/Controllers/Admin/Settings.php:408
2530
+ msgid "Are you sure want to delete this rule!"
2531
+ msgstr ""
2532
+
2533
+ #: v2/App/Controllers/Admin/Settings.php:409
2534
+ msgid "Rule disabled successfully!"
2535
+ msgstr ""
2536
+
2537
+ #: v2/App/Controllers/Admin/Settings.php:410
2538
+ msgid "Rule enabled successfully!"
2539
+ msgstr ""
2540
+
2541
+ #: v2/App/Controllers/Admin/Settings.php:411
2542
+ msgid "Rule saved successfully!"
2543
+ msgstr ""
2544
+
2545
+ #: v2/App/Controllers/Admin/Settings.php:412
2546
+ msgid "Settings saved successfully!"
2547
+ msgstr ""
2548
+
2549
+ #: v2/App/Controllers/Admin/Settings.php:413
2550
+ msgid "Rule priority changed successfully!"
2551
+ msgstr ""
2552
+
2553
+ #: v2/App/Controllers/Admin/Settings.php:414
2554
+ msgid "Rule priority not changed !"
2555
+ msgstr ""
2556
+
2557
+ #: v2/App/Controllers/Admin/Settings.php:415
2558
+ msgid "No data for this period"
2559
+ msgstr ""
2560
+
2561
+ #: v2/App/Controllers/Admin/Settings.php:416
2562
+ msgid "Oops! Coupon already exists in Woocommerce"
2563
+ msgstr ""
2564
+
2565
+ #: v2/App/Controllers/Admin/Settings.php:417
2566
+ msgid "Copied!"
2567
+ msgstr ""
2568
+
2569
+ #: v2/App/Controllers/Admin/Settings.php:418
2570
+ #: v2/App/Views/Admin/Tabs/settings.php:447
2571
+ msgid "Copy ShortCode"
2572
+ msgstr ""
2573
+
2574
+ #: v2/App/Controllers/Admin/Settings.php:419
2575
+ msgid "If you make this recursive other row(s) will be removed!"
2576
+ msgstr ""
2577
+
2578
+ #: v2/App/Controllers/Admin/Settings.php:421
2579
+ msgid "Minimum Quantity"
2580
+ msgstr ""
2581
+
2582
+ #: v2/App/Controllers/Admin/Settings.php:422
2583
+ msgid "Discount value"
2584
+ msgstr ""
2585
+
2586
+ #: v2/App/Controllers/Admin/Settings.php:424
2587
+ msgid "Filter (Buy)"
2588
+ msgstr ""
2589
+
2590
+ #: v2/App/Controllers/Admin/Settings.php:425
2591
+ #: v2/App/Views/Admin/Rules/Manage.php:126
2592
+ msgid "Filter"
2593
+ msgstr ""
2594
+
2595
+ #: v2/App/Controllers/Admin/Settings.php:426
2596
+ msgid ""
2597
+ "<p>Choose <b>what gets discount</b> (products/categories/attributes/SKU and "
2598
+ "so on )</p>\n"
2599
+ "<p>Note : You can also exclude products/categories.</p>"
2600
+ msgstr ""
2601
+
2602
+ #: v2/App/Controllers/Admin/Settings.php:429
2603
+ msgid ""
2604
+ "<p>Select discount type and its value (percentage/price/fixed price)</p>"
2605
+ msgstr ""
2606
+
2607
+ #: v2/App/Controllers/Admin/Settings.php:430
2608
+ msgid "Rules (optional)"
2609
+ msgstr ""
2610
+
2611
+ #: v2/App/Controllers/Admin/Settings.php:431
2612
+ msgid ""
2613
+ "<p>Include additional conditions (if necessary) to apply discount for "
2614
+ "product filters.</p>"
2615
+ msgstr ""
2616
+
2617
+ #: v2/App/Controllers/Admin/Settings.php:432
2618
+ msgid ""
2619
+ "<p>Choose Buy Products. (products/categories/attributes/tags/sku) Example : "
2620
+ "For Buy X get Y scenarios, choose X here.</p>"
2621
+ msgstr ""
2622
+
2623
+ #: v2/App/Controllers/Admin/Settings.php:433
2624
+ msgid ""
2625
+ "<p>Choose on which products the discount should be applied (This can be "
2626
+ "products/categories/SKU)</p>"
2627
+ msgstr ""
2628
+
2629
+ #: v2/App/Controllers/Admin/Settings.php:434
2630
+ #: v2/App/Controllers/Admin/Settings.php:436
2631
+ msgid "Get Discount"
2632
+ msgstr ""
2633
+
2634
+ #: v2/App/Controllers/Admin/Settings.php:435
2635
+ msgid ""
2636
+ "<p>Enter the min/max ranges and choose free item quantity.</p><p>Note : "
2637
+ "Enable recursive checkbox if the discounts should be applied in sequential "
2638
+ "ranges. </p><p>Example : Buy 1 get 1, Buy 2 get 2, Buy 3 get 3 and so on..</"
2639
+ "p>"
2640
+ msgstr ""
2641
+
2642
+ #: v2/App/Controllers/Admin/Settings.php:437
2643
+ msgid ""
2644
+ "<p>Choose the adjustment type to which the discount should be applied. You "
2645
+ "can choose from products/categories/all products.</p><p>Note : Enable "
2646
+ "recursive checkbox if the discounts should be applied in sequential ranges. "
2647
+ "</p>"
2648
+ msgstr ""
2649
+
2650
+ #: v2/App/Controllers/Admin/Settings.php:438
2651
+ msgid ""
2652
+ "<p>Choose the adjustment type to which the discount should be applied. You "
2653
+ "can choose from products/categories/all products.</p><p>Note : Enable "
2654
+ "recursive checkbox if the discounts should be applied in sequential ranges. "
2655
+ "</p><p>Example ranges:</p><p>Buy 2, get 1 free (a.k.a: Buy 1 get 1 free)</"
2656
+ "p><table><tbody><tr><td>Min quantity</td><td>Max quantity</td><td>Free "
2657
+ "quantity</td></tr><tr><td>2</td><td>3</td><td>1</td></tr></tr><tr><td>4</"
2658
+ "td><td>5</td><td>2</td></tr></tbody></table>"
2659
+ msgstr ""
2660
+
2661
+ #: v2/App/Controllers/Admin/Settings.php:439
2662
+ #: v2/App/Controllers/Admin/Settings.php:440
2663
+ msgid "<p>Include additional conditions (if necessary)</p>"
2664
+ msgstr ""
2665
+
2666
+ #: v2/App/Controllers/Admin/Settings.php:441
2667
+ msgid "<p>Processing migration, please wait...</p>"
2668
+ msgstr ""
2669
+
2670
+ #: v2/App/Controllers/Admin/Settings.php:442
2671
+ msgid "<p>Migration completed.</p>"
2672
+ msgstr ""
2673
+
2674
+ #: v2/App/Controllers/Admin/Settings.php:443
2675
+ msgid "<p>Migration skipped.</p>"
2676
+ msgstr ""
2677
+
2678
+ #: v2/App/Controllers/Admin/Settings.php:444
2679
+ msgid "<p>Skipping migration, please wait...</p>"
2680
+ msgstr ""
2681
+
2682
+ #: v2/App/Controllers/Admin/Settings.php:445
2683
+ msgid ""
2684
+ "<span><b>Example:</b> Product A - Small and Product A - Medium will be "
2685
+ "counted as 2 quantity</span>"
2686
+ msgstr ""
2687
+
2688
+ #: v2/App/Controllers/Admin/Settings.php:446
2689
+ msgid "<span>Discount applies to all eligible products in the store</span>"
2690
+ msgstr ""
2691
+
2692
+ #: v2/App/Controllers/Admin/Settings.php:447
2693
+ msgid ""
2694
+ "<span>Choose products that get the discount using \"In List\". If you want "
2695
+ "to exclude a few products, choose \"Not In List\" and select the products "
2696
+ "you wanted to exclude from discount. (You can add multiple filters)</span>"
2697
+ msgstr ""
2698
+
2699
+ #: v2/App/Controllers/Admin/Settings.php:448
2700
+ msgid ""
2701
+ "<span>Choose categories that get the discount using \"In List\". If you want "
2702
+ "to exclude a few categories, choose \"Not In List\" and select the "
2703
+ "categories you wanted to exclude from discount. (You can add multiple "
2704
+ "filters of same type)</span>"
2705
+ msgstr ""
2706
+
2707
+ #: v2/App/Controllers/Admin/Settings.php:449
2708
+ msgid ""
2709
+ "<span> Choose attributes that get the discount using \"In List\". If you "
2710
+ "want to exclude a few attributes, choose \"Not In List\" and select the "
2711
+ "attributes you wanted to exclude from discount. (You can add multiple "
2712
+ "filters of same type)</span>"
2713
+ msgstr ""
2714
+
2715
+ #: v2/App/Controllers/Admin/Settings.php:450
2716
+ msgid ""
2717
+ "<span>Choose tags that get the discount using \"In List\". If you want to "
2718
+ "exclude a few tags, choose \"Not In List\" and select the tags you wanted to "
2719
+ "exclude from discount. (You can add multiple filters of same type)</span>"
2720
+ msgstr ""
2721
+
2722
+ #: v2/App/Controllers/Admin/Settings.php:451
2723
+ msgid ""
2724
+ "<span>Choose SKUs that get the discount using \"In List\". If you want to "
2725
+ "exclude a few SKUs, choose \"Not In List\" and select the SKUs you wanted to "
2726
+ "exclude from discount. (You can add multiple filters of same type)</span>"
2727
+ msgstr ""
2728
+
2729
+ #: v2/App/Controllers/Admin/Settings.php:452
2730
+ msgid ""
2731
+ "<span>Choose whether you want to include (or exclude) products on sale "
2732
+ "(those having a sale price) for the discount </span>"
2733
+ msgstr ""
2734
+
2735
+ #: v2/App/Controllers/Admin/Settings.php:453
2736
+ msgid "<span>Discount applies to custom taxonomy</span>"
2737
+ msgstr ""
2738
+
2739
+ #: v2/App/Controllers/Admin/Settings.php:454
2740
+ msgid "Processing please wait.."
2741
+ msgstr ""
2742
+
2743
+ #: v2/App/Controllers/Admin/Settings.php:455
2744
+ msgid "Rebuild index processed"
2745
+ msgstr ""
2746
+
2747
+ #: v2/App/Controllers/Admin/Settings.php:456
2748
+ msgid "Please select the rules to build index"
2749
+ msgstr ""
2750
+
2751
+ #: v2/App/Controllers/Admin/Tabs/Compatible.php:20
2752
+ msgid "Compatibility"
2753
+ msgstr ""
2754
+
2755
+ #: v2/App/Controllers/Admin/Tabs/DiscountRules.php:21
2756
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:10
2757
+ msgid "Discount Rules"
2758
+ msgstr ""
2759
+
2760
+ #: v2/App/Controllers/Admin/Tabs/Help.php:15
2761
+ msgid "Read Documentation"
2762
+ msgstr ""
2763
+
2764
+ #: v2/App/Controllers/Admin/Tabs/ImportExport.php:16
2765
+ #: v2/App/Views/Admin/Tabs/ImportExport.php:53
2766
+ msgid "Export"
2767
+ msgstr ""
2768
+
2769
+ #: v2/App/Controllers/Admin/Tabs/Reports/RuleAmount.php:14
2770
+ msgid "Rule amount data without cart adjustments"
2771
+ msgstr ""
2772
+
2773
+ #: v2/App/Controllers/Admin/Tabs/Reports/RuleAmount.php:18
2774
+ #: v2/App/Controllers/Admin/Tabs/Reports/RuleAmountWithCartDiscount.php:14
2775
+ msgid "TOP 5"
2776
+ msgstr ""
2777
+
2778
+ #: v2/App/Controllers/Admin/Tabs/Reports/RuleAmount.php:32
2779
+ msgid "Date"
2780
+ msgstr ""
2781
+
2782
+ #: v2/App/Controllers/Admin/Tabs/Reports/RuleAmountWithCartDiscount.php:10
2783
+ msgid "Rule amount data with cart discounts"
2784
+ msgstr ""
2785
+
2786
+ #: v2/App/Controllers/Admin/Tabs/Statistics.php:22
2787
+ msgid "Reports"
2788
+ msgstr ""
2789
+
2790
+ #: v2/App/Controllers/Admin/Tabs/Statistics.php:27
2791
+ msgid "Rule amount"
2792
+ msgstr ""
2793
+
2794
+ #: v2/App/Controllers/Admin/Tabs/Statistics.php:28
2795
+ #: v2/App/Controllers/Admin/Tabs/Statistics.php:33
2796
+ msgid "Rule"
2797
+ msgstr ""
2798
+
2799
+ #: v2/App/Controllers/Admin/Tabs/Statistics.php:32
2800
+ msgid "Rule amount with cart discount"
2801
+ msgstr ""
2802
+
2803
+ #: v2/App/Controllers/Base.php:40
2804
+ msgid "All Products"
2805
+ msgstr ""
2806
+
2807
+ #: v2/App/Controllers/Base.php:41 v2/App/Controllers/Base.php:46
2808
+ #: v2/App/Helpers/ProOptions.php:32 v2/App/Helpers/ProOptions.php:38
2809
+ #: v2/App/Helpers/ProOptions.php:44 v2/App/Helpers/ProOptions.php:50
2810
+ #: v2/App/Helpers/ProOptions.php:56 v2/App/Views/Admin/Tabs/settings.php:99
2811
+ msgid "Product"
2812
+ msgstr ""
2813
+
2814
+ #: v2/App/Controllers/Base.php:188
2815
+ msgid "Product Adjustment"
2816
+ msgstr ""
2817
+
2818
+ #: v2/App/Controllers/Base.php:189 v2/App/Controllers/Base.php:195
2819
+ #: v2/App/Helpers/ProOptions.php:330
2820
+ msgid "Simple Discount"
2821
+ msgstr ""
2822
+
2823
+ #: v2/App/Controllers/Base.php:194
2824
+ msgid "Cart Adjustment"
2825
+ msgstr ""
2826
+
2827
+ #: v2/App/Controllers/Base.php:200 v2/App/Controllers/Base.php:201
2828
+ #: v2/App/Helpers/ProOptions.php:336
2829
+ msgid "Bulk Discount"
2830
+ msgstr ""
2831
+
2832
+ #: v2/App/Controllers/ManageDiscount.php:533
2833
+ msgid "cart discount"
2834
+ msgstr ""
2835
+
2836
+ #: v2/App/Controllers/ManageDiscount.php:705
2837
+ msgid "Coupon code applied successfully."
2838
+ msgstr ""
2839
+
2840
+ #: v2/App/Controllers/ShortCodeManager.php:675
2841
+ msgid "No Banner Content"
2842
+ msgstr ""
2843
+
2844
+ #: v2/App/Helpers/Migration.php:131
2845
+ #, php-format
2846
+ msgid "%s Completed. Please wait.."
2847
+ msgstr ""
2848
+
2849
+ #: v2/App/Helpers/ProOptions.php:31 v2/App/Helpers/ProOptions.php:93
2850
+ msgid "Category - PRO -"
2851
+ msgstr ""
2852
+
2853
+ #: v2/App/Helpers/ProOptions.php:37 v2/App/Helpers/ProOptions.php:85
2854
+ msgid "Attributes - PRO -"
2855
+ msgstr ""
2856
+
2857
+ #: v2/App/Helpers/ProOptions.php:43 v2/App/Helpers/ProOptions.php:125
2858
+ msgid "Tags - PRO -"
2859
+ msgstr ""
2860
+
2861
+ #: v2/App/Helpers/ProOptions.php:49
2862
+ msgid "SKUs - PRO -"
2863
+ msgstr ""
2864
+
2865
+ #: v2/App/Helpers/ProOptions.php:55
2866
+ msgid "On sale products - PRO -"
2867
+ msgstr ""
2868
+
2869
+ #: v2/App/Helpers/ProOptions.php:77
2870
+ msgid "Coupons - PRO -"
2871
+ msgstr ""
2872
+
2873
+ #: v2/App/Helpers/ProOptions.php:86 v2/App/Helpers/ProOptions.php:94
2874
+ #: v2/App/Helpers/ProOptions.php:102 v2/App/Helpers/ProOptions.php:110
2875
+ #: v2/App/Helpers/ProOptions.php:118 v2/App/Helpers/ProOptions.php:126
2876
+ msgid "Cart Items"
2877
+ msgstr ""
2878
+
2879
+ #: v2/App/Helpers/ProOptions.php:101
2880
+ msgid "Product combination - PRO -"
2881
+ msgstr ""
2882
+
2883
+ #: v2/App/Helpers/ProOptions.php:109
2884
+ msgid "Products - PRO -"
2885
+ msgstr ""
2886
+
2887
+ #: v2/App/Helpers/ProOptions.php:117
2888
+ msgid "SKU - PRO -"
2889
+ msgstr ""
2890
+
2891
+ #: v2/App/Helpers/ProOptions.php:133
2892
+ msgid "Cart items quantity - PRO -"
2893
+ msgstr ""
2894
+
2895
+ #: v2/App/Helpers/ProOptions.php:141
2896
+ msgid "Total weight - PRO -"
2897
+ msgstr ""
2898
+
2899
+ #: v2/App/Helpers/ProOptions.php:149
2900
+ msgid "Payment Method - PRO -"
2901
+ msgstr ""
2902
+
2903
+ #: v2/App/Helpers/ProOptions.php:157
2904
+ msgid "Date - PRO -"
2905
+ msgstr ""
2906
+
2907
+ #: v2/App/Helpers/ProOptions.php:158 v2/App/Helpers/ProOptions.php:166
2908
+ #: v2/App/Helpers/ProOptions.php:174 v2/App/Helpers/ProOptions.php:182
2909
+ msgid "Date & Time"
2910
+ msgstr ""
2911
+
2912
+ #: v2/App/Helpers/ProOptions.php:165
2913
+ msgid "Date and Time - PRO -"
2914
+ msgstr ""
2915
+
2916
+ #: v2/App/Helpers/ProOptions.php:173
2917
+ msgid "Days - PRO -"
2918
+ msgstr ""
2919
+
2920
+ #: v2/App/Helpers/ProOptions.php:181
2921
+ msgid "Time - PRO -"
2922
+ msgstr ""
2923
+
2924
+ #: v2/App/Helpers/ProOptions.php:189
2925
+ msgid "First order - PRO -"
2926
+ msgstr ""
2927
+
2928
+ #: v2/App/Helpers/ProOptions.php:197
2929
+ msgid "Last order - PRO -"
2930
+ msgstr ""
2931
+
2932
+ #: v2/App/Helpers/ProOptions.php:205
2933
+ msgid "Last order amount - PRO -"
2934
+ msgstr ""
2935
+
2936
+ #: v2/App/Helpers/ProOptions.php:213
2937
+ msgid "Number of orders made - PRO -"
2938
+ msgstr ""
2939
+
2940
+ #: v2/App/Helpers/ProOptions.php:221
2941
+ msgid "Number of orders made with following products - PRO -"
2942
+ msgstr ""
2943
+
2944
+ #: v2/App/Helpers/ProOptions.php:229
2945
+ msgid "Spent - PRO -"
2946
+ msgstr ""
2947
+
2948
+ #: v2/App/Helpers/ProOptions.php:237
2949
+ msgid "City - PRO -"
2950
+ msgstr ""
2951
+
2952
+ #: v2/App/Helpers/ProOptions.php:238 v2/App/Helpers/ProOptions.php:246
2953
+ #: v2/App/Helpers/ProOptions.php:254 v2/App/Helpers/ProOptions.php:262
2954
+ msgid "Shipping"
2955
+ msgstr ""
2956
+
2957
+ #: v2/App/Helpers/ProOptions.php:245
2958
+ msgid "Country - PRO -"
2959
+ msgstr ""
2960
+
2961
+ #: v2/App/Helpers/ProOptions.php:253
2962
+ msgid "State - PRO -"
2963
+ msgstr ""
2964
+
2965
+ #: v2/App/Helpers/ProOptions.php:261
2966
+ msgid "Zipcode - PRO -"
2967
+ msgstr ""
2968
+
2969
+ #: v2/App/Helpers/ProOptions.php:269
2970
+ msgid "Email - PRO -"
2971
+ msgstr ""
2972
+
2973
+ #: v2/App/Helpers/ProOptions.php:270 v2/App/Helpers/ProOptions.php:278
2974
+ #: v2/App/Helpers/ProOptions.php:286 v2/App/Helpers/ProOptions.php:294
2975
+ msgid "Customer"
2976
+ msgstr ""
2977
+
2978
+ #: v2/App/Helpers/ProOptions.php:277
2979
+ msgid "User - PRO -"
2980
+ msgstr ""
2981
+
2982
+ #: v2/App/Helpers/ProOptions.php:285
2983
+ msgid "Is logged in - PRO -"
2984
+ msgstr ""
2985
+
2986
+ #: v2/App/Helpers/ProOptions.php:293
2987
+ msgid "User role - PRO -"
2988
+ msgstr ""
2989
+
2990
+ #: v2/App/Helpers/ProOptions.php:315
2991
+ msgid "Buy X get X - PRO -"
2992
+ msgstr ""
2993
+
2994
+ #: v2/App/Helpers/ProOptions.php:316 v2/App/Helpers/ProOptions.php:323
2995
+ msgid "Bogo Discount"
2996
+ msgstr ""
2997
+
2998
+ #: v2/App/Helpers/ProOptions.php:322
2999
+ msgid "Buy X get Y - PRO -"
3000
+ msgstr ""
3001
+
3002
+ #: v2/App/Helpers/ProOptions.php:329
3003
+ msgid "Free Shipping - PRO -"
3004
+ msgstr ""
3005
+
3006
+ #: v2/App/Helpers/ProOptions.php:335
3007
+ msgid "Set Discount - PRO -"
3008
+ msgstr ""
3009
+
3010
+ #: v2/App/Helpers/Rule.php:1072 v2/App/Helpers/Rule.php:1083
3011
+ msgid "discount"
3012
+ msgstr ""
3013
+
3014
+ #: v2/App/Helpers/Rule.php:1136 v2/App/Helpers/Rule.php:1213
3015
+ msgid "Untitled Rule"
3016
+ msgstr ""
3017
+
3018
+ #: v2/App/Helpers/Woocommerce.php:878
3019
+ msgid "Sunday"
3020
+ msgstr ""
3021
+
3022
+ #: v2/App/Helpers/Woocommerce.php:879
3023
+ msgid "Monday"
3024
+ msgstr ""
3025
+
3026
+ #: v2/App/Helpers/Woocommerce.php:880
3027
+ msgid "Tuesday"
3028
+ msgstr ""
3029
+
3030
+ #: v2/App/Helpers/Woocommerce.php:881
3031
+ msgid "Wednesday"
3032
+ msgstr ""
3033
+
3034
+ #: v2/App/Helpers/Woocommerce.php:882
3035
+ msgid "Thursday"
3036
+ msgstr ""
3037
+
3038
+ #: v2/App/Helpers/Woocommerce.php:883
3039
+ msgid "Friday"
3040
+ msgstr ""
3041
+
3042
+ #: v2/App/Helpers/Woocommerce.php:884
3043
+ msgid "Saturday"
3044
+ msgstr ""
3045
+
3046
+ #: v2/App/Helpers/Woocommerce.php:895
3047
+ msgid ""
3048
+ "Woocommerce before main content(Archive / Shop / Cat Pages / single product)"
3049
+ msgstr ""
3050
+
3051
+ #: v2/App/Helpers/Woocommerce.php:896
3052
+ msgid "Woocommerce archive description(Archive / Shop / Cat Pages)"
3053
+ msgstr ""
3054
+
3055
+ #: v2/App/Helpers/Woocommerce.php:897
3056
+ msgid "Woocommerce before shop loop(Archive / Shop / Cat Pages)"
3057
+ msgstr ""
3058
+
3059
+ #: v2/App/Helpers/Woocommerce.php:898
3060
+ msgid "Woocommerce after shop loop(Archive / Shop / Cat Pages)"
3061
+ msgstr ""
3062
+
3063
+ #: v2/App/Helpers/Woocommerce.php:899
3064
+ msgid ""
3065
+ "Woocommerce after main content(Archive / Shop / Cat Pages / single product)"
3066
+ msgstr ""
3067
+
3068
+ #: v2/App/Helpers/Woocommerce.php:900 v2/App/Views/Admin/Tabs/settings.php:179
3069
+ #: v2/App/Views/Admin/Tabs/settings.php:197
3070
+ msgid "Woocommerce before single product"
3071
+ msgstr ""
3072
+
3073
+ #: v2/App/Helpers/Woocommerce.php:901 v2/App/Views/Admin/Tabs/settings.php:181
3074
+ #: v2/App/Views/Admin/Tabs/settings.php:199
3075
+ msgid "Woocommerce before single product summary"
3076
+ msgstr ""
3077
+
3078
+ #: v2/App/Helpers/Woocommerce.php:902 v2/App/Views/Admin/Tabs/settings.php:180
3079
+ #: v2/App/Views/Admin/Tabs/settings.php:198
3080
+ msgid "Woocommerce after single product summary"
3081
+ msgstr ""
3082
+
3083
+ #: v2/App/Helpers/Woocommerce.php:903 v2/App/Views/Admin/Tabs/settings.php:178
3084
+ #: v2/App/Views/Admin/Tabs/settings.php:196
3085
+ msgid "Woocommerce after single product"
3086
+ msgstr ""
3087
+
3088
+ #: v2/App/Helpers/Woocommerce.php:904
3089
+ msgid "Woocommerce before cart"
3090
+ msgstr ""
3091
+
3092
+ #: v2/App/Helpers/Woocommerce.php:905
3093
+ msgid "Woocommerce before cart table"
3094
+ msgstr ""
3095
+
3096
+ #: v2/App/Helpers/Woocommerce.php:906
3097
+ msgid "Woocommerce before cart contents"
3098
+ msgstr ""
3099
+
3100
+ #: v2/App/Helpers/Woocommerce.php:907
3101
+ msgid "Woocommerce cart contents"
3102
+ msgstr ""
3103
+
3104
+ #: v2/App/Helpers/Woocommerce.php:908
3105
+ msgid "Woocommerce after cart contents"
3106
+ msgstr ""
3107
+
3108
+ #: v2/App/Helpers/Woocommerce.php:909
3109
+ msgid "Woocommerce after cart table"
3110
+ msgstr ""
3111
+
3112
+ #: v2/App/Helpers/Woocommerce.php:910
3113
+ msgid "Woocommerce after cart"
3114
+ msgstr ""
3115
+
3116
+ #: v2/App/Helpers/Woocommerce.php:911
3117
+ msgid "Woocommerce before checkout form"
3118
+ msgstr ""
3119
+
3120
+ #: v2/App/Helpers/Woocommerce.php:913
3121
+ msgid "Woocommerce before checkout billing form"
3122
+ msgstr ""
3123
+
3124
+ #: v2/App/Helpers/Woocommerce.php:914
3125
+ msgid "Woocommerce after checkout billing form"
3126
+ msgstr ""
3127
+
3128
+ #: v2/App/Helpers/Woocommerce.php:915
3129
+ msgid "Woocommerce before checkout shipping form"
3130
+ msgstr ""
3131
+
3132
+ #: v2/App/Helpers/Woocommerce.php:916
3133
+ msgid "Woocommerce after checkout shipping form"
3134
+ msgstr ""
3135
+
3136
+ #: v2/App/Helpers/Woocommerce.php:917
3137
+ msgid "Woocommerce before order notes"
3138
+ msgstr ""
3139
+
3140
+ #: v2/App/Helpers/Woocommerce.php:918
3141
+ msgid "Woocommerce after order notes"
3142
+ msgstr ""
3143
+
3144
+ #: v2/App/Views/Admin/Menu.php:21
3145
+ msgid ""
3146
+ "<span style='color: #FF8C00 ; padding: 3px; border-radius: 4px'> (public "
3147
+ "beta) </span>"
3148
+ msgstr ""
3149
+
3150
+ #: v2/App/Views/Admin/Menu.php:31
3151
+ msgid "Rebuild index"
3152
+ msgstr ""
3153
+
3154
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:12
3155
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:13
3156
+ msgid "Less than ( &lt; )"
3157
+ msgstr ""
3158
+
3159
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:13
3160
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:14
3161
+ msgid "Less than or equal ( &lt;= )"
3162
+ msgstr ""
3163
+
3164
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:14
3165
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:15
3166
+ msgid "Greater than or equal ( &gt;= )"
3167
+ msgstr ""
3168
+
3169
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:15
3170
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:16
3171
+ msgid "Greater than ( &gt; )"
3172
+ msgstr ""
3173
+
3174
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:17
3175
+ msgid "Line item count should be"
3176
+ msgstr ""
3177
+
3178
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:22
3179
+ msgid "1"
3180
+ msgstr ""
3181
+
3182
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:23
3183
+ msgid "Line item count"
3184
+ msgstr ""
3185
+
3186
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:27
3187
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:29
3188
+ msgid "Count all items in cart"
3189
+ msgstr ""
3190
+
3191
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:28
3192
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:30
3193
+ msgid "Only count items chosen in the filters set for this rule"
3194
+ msgstr ""
3195
+
3196
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php:30
3197
+ msgid "How to calculate the line item count"
3198
+ msgstr ""
3199
+
3200
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:18
3201
+ msgid "Subtotal should be"
3202
+ msgstr ""
3203
+
3204
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:23
3205
+ msgid "0.00"
3206
+ msgstr ""
3207
+
3208
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:24
3209
+ msgid "Subtotal Amount "
3210
+ msgstr ""
3211
+
3212
+ #: v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php:32
3213
+ msgid "How to calculate the subtotal"
3214
+ msgstr ""
3215
+
3216
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:7
3217
+ msgid "Rules (Optional)"
3218
+ msgstr ""
3219
+
3220
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:9
3221
+ msgid ""
3222
+ "Include additional conditions (if necessary) to apply discount for product "
3223
+ "filters."
3224
+ msgstr ""
3225
+
3226
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:20
3227
+ msgid "Conditions Relationship "
3228
+ msgstr ""
3229
+
3230
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:23
3231
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:99
3232
+ msgid "Match All"
3233
+ msgstr ""
3234
+
3235
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:25
3236
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:101
3237
+ msgid "Many Any"
3238
+ msgstr ""
3239
+
3240
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:71
3241
+ #: v2/App/Views/Admin/Rules/Others/CommonTemplates.php:87
3242
+ msgid "Condition Type"
3243
+ msgstr ""
3244
+
3245
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:89
3246
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:109
3247
+ msgid "Add condition"
3248
+ msgstr ""
3249
+
3250
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:97
3251
+ msgid "Conditions Relationship"
3252
+ msgstr ""
3253
+
3254
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:119
3255
+ msgid "Rule Limits"
3256
+ msgstr ""
3257
+
3258
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:132
3259
+ msgid "Unlimited"
3260
+ msgstr ""
3261
+
3262
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:139
3263
+ msgid "Maximum usage limit"
3264
+ msgstr ""
3265
+
3266
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:147
3267
+ msgid "Rule Vaild From"
3268
+ msgstr ""
3269
+
3270
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:152
3271
+ msgid "Vaild from"
3272
+ msgstr ""
3273
+
3274
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:159
3275
+ msgid "Rule Valid To"
3276
+ msgstr ""
3277
+
3278
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:163
3279
+ msgid "Vaild to"
3280
+ msgstr ""
3281
+
3282
+ #: v2/App/Views/Admin/Rules/Conditions/Main.php:174
3283
+ msgid "Select values"
3284
+ msgstr ""
3285
+
3286
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:10
3287
+ msgid "Discount Bar (Optional)"
3288
+ msgstr ""
3289
+
3290
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:17
3291
+ msgid "It helps to display discount information in product pages."
3292
+ msgstr ""
3293
+
3294
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:17
3295
+ msgid "Read docs."
3296
+ msgstr ""
3297
+
3298
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:18
3299
+ msgid "Preview"
3300
+ msgstr ""
3301
+
3302
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:22
3303
+ #: v2/App/Views/Admin/Tabs/settings.php:468
3304
+ msgid "Note:"
3305
+ msgstr ""
3306
+
3307
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:22
3308
+ msgid "Preview contains sample result for original result see product page."
3309
+ msgstr ""
3310
+
3311
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:35
3312
+ msgid "Show Discount Bar?"
3313
+ msgstr ""
3314
+
3315
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:36
3316
+ msgid "Show/hide discount bar on product pages"
3317
+ msgstr ""
3318
+
3319
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:50
3320
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:71
3321
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:92
3322
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:126
3323
+ #: v2/App/Views/Admin/Tabs/settings.php:364
3324
+ #: v2/App/Views/Admin/Tabs/settings.php:373
3325
+ #: v2/App/Views/Admin/Tabs/settings.php:436
3326
+ msgid ""
3327
+ "Unlock this feature by <a href='https://www.flycart.org/products/wordpress/"
3328
+ "woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>"
3329
+ msgstr ""
3330
+
3331
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:57
3332
+ msgid "Badge Background Color"
3333
+ msgstr ""
3334
+
3335
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:58
3336
+ msgid "Choose background color to be shown in product pages."
3337
+ msgstr ""
3338
+
3339
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:78
3340
+ msgid "Badge Text Color"
3341
+ msgstr ""
3342
+
3343
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:79
3344
+ msgid "Choose text color to be shown in product pages."
3345
+ msgstr ""
3346
+
3347
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:100
3348
+ msgid "Badge Text "
3349
+ msgstr ""
3350
+
3351
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:101
3352
+ msgid ""
3353
+ "Customise the text that you want to display. <br><b>Note</b> : You can also "
3354
+ "use shortcodes to show discount amount."
3355
+ msgstr ""
3356
+
3357
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:111
3358
+ msgid "Discount Text"
3359
+ msgstr ""
3360
+
3361
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:113
3362
+ msgid " Rule Title,"
3363
+ msgstr ""
3364
+
3365
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:117
3366
+ #, php-format
3367
+ msgid " Discount (if percentage eg: 20% or Flat, Fixed Price eg:$20),"
3368
+ msgstr ""
3369
+
3370
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:118
3371
+ msgid " Discounted Product Price,"
3372
+ msgstr ""
3373
+
3374
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:119
3375
+ msgid " Minimum quantity (shows only for bluk and set discount range),"
3376
+ msgstr ""
3377
+
3378
+ #: v2/App/Views/Admin/Rules/DiscountBatch/Main.php:120
3379
+ msgid " Maximum quantity (shows only for bulk discount range)"
3380
+ msgstr ""
3381
+
3382
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:16
3383
+ msgid "min"
3384
+ msgstr ""
3385
+
3386
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:22
3387
+ msgid "Minimum Quantity "
3388
+ msgstr ""
3389
+
3390
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:28
3391
+ msgid "max"
3392
+ msgstr ""
3393
+
3394
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:34
3395
+ msgid "Maximum Quantity "
3396
+ msgstr ""
3397
+
3398
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:41
3399
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:14
3400
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:13
3401
+ msgid "Percentage discount"
3402
+ msgstr ""
3403
+
3404
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:44
3405
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:15
3406
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:14
3407
+ msgid "Fixed discount"
3408
+ msgstr ""
3409
+
3410
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:48
3411
+ msgid "Fixed price for item"
3412
+ msgstr ""
3413
+
3414
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:50
3415
+ msgid "Fixed price for item - PRO -"
3416
+ msgstr ""
3417
+
3418
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:53
3419
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:24
3420
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:23
3421
+ msgid "Discount Type"
3422
+ msgstr ""
3423
+
3424
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:65
3425
+ #: v2/App/Views/Admin/Tabs/settings.php:534
3426
+ msgid "Discount Value"
3427
+ msgstr ""
3428
+
3429
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:70
3430
+ msgid "Label"
3431
+ msgstr ""
3432
+
3433
+ #: v2/App/Views/Admin/Rules/Discounts/Bulk.php:74
3434
+ msgid "Title column For Bulk Table"
3435
+ msgstr ""
3436
+
3437
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:17
3438
+ msgid "Fixed discount per product"
3439
+ msgstr ""
3440
+
3441
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:20
3442
+ msgid "Fixed discount per product -PRO-"
3443
+ msgstr ""
3444
+
3445
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:40
3446
+ msgid "Discount label"
3447
+ msgstr ""
3448
+
3449
+ #: v2/App/Views/Admin/Rules/Discounts/Cart.php:42
3450
+ msgid "Discount Label"
3451
+ msgstr ""
3452
+
3453
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:17
3454
+ msgid "Count by:"
3455
+ msgstr ""
3456
+
3457
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:22
3458
+ msgid "Product filters together"
3459
+ msgstr ""
3460
+
3461
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:25
3462
+ msgid "Individual product"
3463
+ msgstr ""
3464
+
3465
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:28
3466
+ msgid "All variants in each product together"
3467
+ msgstr ""
3468
+
3469
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:50
3470
+ msgid "Add Range"
3471
+ msgstr ""
3472
+
3473
+ #: v2/App/Views/Admin/Rules/Discounts/Main.php:58
3474
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:40
3475
+ msgid "Show discount in cart as coupon instead of changing the product price ?"
3476
+ msgstr ""
3477
+
3478
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:16
3479
+ msgid "Fixed price per item"
3480
+ msgstr ""
3481
+
3482
+ #: v2/App/Views/Admin/Rules/Discounts/simple.php:19
3483
+ msgid "Fixed price per item -PRO-"
3484
+ msgstr ""
3485
+
3486
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:54
3487
+ #: v2/App/Views/Admin/Rules/Filters/Products.php:10
3488
+ msgid "In List"
3489
+ msgstr ""
3490
+
3491
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:55
3492
+ #: v2/App/Views/Admin/Rules/Filters/Products.php:11
3493
+ msgid "Not In List"
3494
+ msgstr ""
3495
+
3496
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:81
3497
+ msgid "Select "
3498
+ msgstr ""
3499
+
3500
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:97
3501
+ msgid ""
3502
+ "Choose products that get the discount using \"In List\". If you want to "
3503
+ "exclude a few products, choose \"Not In List\" and select the products you "
3504
+ "wanted to exclude from discount. (You can add multiple filters)"
3505
+ msgstr ""
3506
+
3507
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:100
3508
+ msgid ""
3509
+ "Choose categories that get the discount using \"In List\". If you want to "
3510
+ "exclude a few categories, choose \"Not In List\" and select the categories "
3511
+ "you wanted to exclude from discount. (You can add multiple filters of same "
3512
+ "type)"
3513
+ msgstr ""
3514
+
3515
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:103
3516
+ msgid ""
3517
+ "Choose attributes that get the discount using \"In List\". If you want to "
3518
+ "exclude a few attributes, choose \"Not In List\" and select the attributes "
3519
+ "you wanted to exclude from discount. (You can add multiple filters of same "
3520
+ "type)"
3521
+ msgstr ""
3522
+
3523
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:106
3524
+ msgid ""
3525
+ "Choose tags that get the discount using \"In List\". If you want to exclude "
3526
+ "a few tags, choose \"Not In List\" and select the tags you wanted to exclude "
3527
+ "from discount. (You can add multiple filters of same type)"
3528
+ msgstr ""
3529
+
3530
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:109
3531
+ msgid ""
3532
+ "Choose SKUs that get the discount using \"In List\". If you want to exclude "
3533
+ "a few SKUs, choose \"Not In List\" and select the SKUs you wanted to exclude "
3534
+ "from discount. (You can add multiple filters of same type)"
3535
+ msgstr ""
3536
+
3537
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:112
3538
+ msgid ""
3539
+ "Choose whether you want to include (or exclude) products on sale (those "
3540
+ "having a sale price) for the discount "
3541
+ msgstr ""
3542
+
3543
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:115
3544
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:161
3545
+ msgid "Discount applies to all eligible products in the store"
3546
+ msgstr ""
3547
+
3548
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:119
3549
+ msgid "Discount applies to custom taxonomy"
3550
+ msgstr ""
3551
+
3552
+ #: v2/App/Views/Admin/Rules/Filters/Main.php:172
3553
+ msgid "Add filter"
3554
+ msgstr ""
3555
+
3556
+ #: v2/App/Views/Admin/Rules/Filters/Products.php:17
3557
+ msgid "Select Products"
3558
+ msgstr ""
3559
+
3560
+ #: v2/App/Views/Admin/Rules/Manage.php:13
3561
+ msgid " Start date and time is set in the future date"
3562
+ msgstr ""
3563
+
3564
+ #: v2/App/Views/Admin/Rules/Manage.php:20
3565
+ msgid " Validity expired"
3566
+ msgstr ""
3567
+
3568
+ #: v2/App/Views/Admin/Rules/Manage.php:49
3569
+ msgid "Enable?"
3570
+ msgstr ""
3571
+
3572
+ #: v2/App/Views/Admin/Rules/Manage.php:58
3573
+ msgid "Apply this rule if matched and ignore all other rules"
3574
+ msgstr ""
3575
+
3576
+ #: v2/App/Views/Admin/Rules/Manage.php:67
3577
+ msgid "#Rule ID: "
3578
+ msgstr ""
3579
+
3580
+ #: v2/App/Views/Admin/Rules/Manage.php:74
3581
+ msgid "Save & Close"
3582
+ msgstr ""
3583
+
3584
+ #: v2/App/Views/Admin/Rules/Manage.php:77
3585
+ msgid "Cancel"
3586
+ msgstr ""
3587
+
3588
+ #: v2/App/Views/Admin/Rules/Manage.php:89
3589
+ msgid "Select Discount Type"
3590
+ msgstr ""
3591
+
3592
+ #: v2/App/Views/Admin/Rules/Manage.php:128
3593
+ msgid ""
3594
+ "Choose which <b>gets</b> discount (products/categories/attributes/SKU and so "
3595
+ "on )"
3596
+ msgstr ""
3597
+
3598
+ #: v2/App/Views/Admin/Rules/Manage.php:129
3599
+ msgid "Note : You can also exclude products/categories."
3600
+ msgstr ""
3601
+
3602
+ #: v2/App/Views/Admin/Rules/Manage.php:173
3603
+ msgid "Select discount type and its value (percentage/price/fixed price)"
3604
+ msgstr ""
3605
+
3606
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:15
3607
+ msgid "Migrate rules from v1"
3608
+ msgstr ""
3609
+
3610
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:22
3611
+ msgid "Migration"
3612
+ msgstr ""
3613
+
3614
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:26
3615
+ #: v2/App/Views/Admin/welcome-text.php:6
3616
+ msgid "Migrate rules from v1 to v2"
3617
+ msgstr ""
3618
+
3619
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:30
3620
+ msgid "Available price rules"
3621
+ msgstr ""
3622
+
3623
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:33
3624
+ msgid "Available cart rules"
3625
+ msgstr ""
3626
+
3627
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:36
3628
+ msgid ""
3629
+ "Once migration is completed, please open the rules and check their "
3630
+ "configuration once again to make sure it meets your discount scenario. If "
3631
+ "required, please adjust the rule configuration. If you need any help, just "
3632
+ "open a ticket at <a href=\"https://www.flycart.org/support\" target=\"_blank"
3633
+ "\">https://www.flycart.org/support</a>"
3634
+ msgstr ""
3635
+
3636
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:41
3637
+ #: v2/App/Views/Admin/welcome-text.php:11
3638
+ msgid "Migrate"
3639
+ msgstr ""
3640
+
3641
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:42
3642
+ #: v2/App/Views/Admin/welcome-text.php:12
3643
+ msgid "Skip"
3644
+ msgstr ""
3645
+
3646
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:66
3647
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:72
3648
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:82
3649
+ msgid "Search Rules"
3650
+ msgstr ""
3651
+
3652
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:86
3653
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:288
3654
+ msgid "item"
3655
+ msgstr ""
3656
+
3657
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:86
3658
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:288
3659
+ msgid "items"
3660
+ msgstr ""
3661
+
3662
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:114
3663
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:259
3664
+ msgid "Language(s)"
3665
+ msgstr ""
3666
+
3667
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:146
3668
+ msgid "Exclusive"
3669
+ msgstr ""
3670
+
3671
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:187
3672
+ msgid "Enabled"
3673
+ msgstr ""
3674
+
3675
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:196
3676
+ msgid " - ( Will run in future)"
3677
+ msgstr ""
3678
+
3679
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:199
3680
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:207
3681
+ msgid "Your server current date and time:"
3682
+ msgstr ""
3683
+
3684
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:204
3685
+ msgid " - ( Not running - validity expired)"
3686
+ msgstr ""
3687
+
3688
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:234
3689
+ msgid "No rules found."
3690
+ msgstr ""
3691
+
3692
+ #: v2/App/Views/Admin/Tabs/DiscountRule.php:314
3693
+ msgid "Go PRO"
3694
+ msgstr ""
3695
+
3696
+ #: v2/App/Views/Admin/Tabs/ImportExport.php:12
3697
+ msgid "Export tool"
3698
+ msgstr ""
3699
+
3700
+ #: v2/App/Views/Admin/Tabs/Statistics.php:39
3701
+ msgid "This Week"
3702
+ msgstr ""
3703
+
3704
+ #: v2/App/Views/Admin/Tabs/Statistics.php:40
3705
+ msgid "This Month"
3706
+ msgstr ""
3707
+
3708
+ #: v2/App/Views/Admin/Tabs/Statistics.php:41
3709
+ msgid "Custom Range"
3710
+ msgstr ""
3711
+
3712
+ #: v2/App/Views/Admin/Tabs/Statistics.php:48
3713
+ msgid "From: yyyy/mm/dd"
3714
+ msgstr ""
3715
+
3716
+ #: v2/App/Views/Admin/Tabs/Statistics.php:59
3717
+ msgid "To: yyyy/mm/dd"
3718
+ msgstr ""
3719
+
3720
+ #: v2/App/Views/Admin/Tabs/Statistics.php:79
3721
+ msgid "Update Chart"
3722
+ msgstr ""
3723
+
3724
+ #: v2/App/Views/Admin/Tabs/compatible.php:12
3725
+ msgid "Compatibility for Woo Discount Rules"
3726
+ msgstr ""
3727
+
3728
+ #: v2/App/Views/Admin/Tabs/compatible.php:24
3729
+ msgid "Save Changes"
3730
+ msgstr ""
3731
+
3732
+ #: v2/App/Views/Admin/Tabs/compatible.php:30
3733
+ msgid ""
3734
+ "This section lists plugins that require a compatibility with discount rules "
3735
+ "to resolve conflicts. \n"
3736
+ "Please tick them (by checking the box) and then save. This will help "
3737
+ "discount rules to run smoothly along with these plugins"
3738
+ msgstr ""
3739
+
3740
+ #: v2/App/Views/Admin/Tabs/settings.php:23
3741
+ msgid "Calculate discount from"
3742
+ msgstr ""
3743
+
3744
+ #: v2/App/Views/Admin/Tabs/settings.php:24
3745
+ msgid "sale price or regular price"
3746
+ msgstr ""
3747
+
3748
+ #: v2/App/Views/Admin/Tabs/settings.php:35
3749
+ msgid "Apply discount"
3750
+ msgstr ""
3751
+
3752
+ #: v2/App/Views/Admin/Tabs/settings.php:36
3753
+ msgid "Highest/Lowest/First/All matched rules"
3754
+ msgstr ""
3755
+
3756
+ #: v2/App/Views/Admin/Tabs/settings.php:40
3757
+ msgid "Biggest one from matched rules"
3758
+ msgstr ""
3759
+
3760
+ #: v2/App/Views/Admin/Tabs/settings.php:41
3761
+ msgid "Lowest one from matched rules"
3762
+ msgstr ""
3763
+
3764
+ #: v2/App/Views/Admin/Tabs/settings.php:42
3765
+ msgid "First matched rules"
3766
+ msgstr ""
3767
+
3768
+ #: v2/App/Views/Admin/Tabs/settings.php:43
3769
+ msgid "All matched rules"
3770
+ msgstr ""
3771
+
3772
+ #: v2/App/Views/Admin/Tabs/settings.php:49
3773
+ msgid "Apply discount subsequently"
3774
+ msgstr ""
3775
+
3776
+ #: v2/App/Views/Admin/Tabs/settings.php:50
3777
+ msgid "discounts applied subsequently"
3778
+ msgstr ""
3779
+
3780
+ #: v2/App/Views/Admin/Tabs/settings.php:64
3781
+ msgid "Choose how discount rules should work"
3782
+ msgstr ""
3783
+
3784
+ #: v2/App/Views/Admin/Tabs/settings.php:80
3785
+ msgid "Suppress third party discount plugins"
3786
+ msgstr ""
3787
+
3788
+ #: v2/App/Views/Admin/Tabs/settings.php:81
3789
+ msgid ""
3790
+ "suppress third party plugins from modifying the prices. other discount "
3791
+ "plugins may not works!"
3792
+ msgstr ""
3793
+
3794
+ #: v2/App/Views/Admin/Tabs/settings.php:105
3795
+ msgid "On-sale badge"
3796
+ msgstr ""
3797
+
3798
+ #: v2/App/Views/Admin/Tabs/settings.php:106
3799
+ msgid "show on-sale badge"
3800
+ msgstr ""
3801
+
3802
+ #: v2/App/Views/Admin/Tabs/settings.php:114
3803
+ msgid "Show on products that are covered under any discount rule in the plugin"
3804
+ msgstr ""
3805
+
3806
+ #: v2/App/Views/Admin/Tabs/settings.php:122
3807
+ msgid "Customize the sale badge"
3808
+ msgstr ""
3809
+
3810
+ #: v2/App/Views/Admin/Tabs/settings.php:140
3811
+ msgid "Sale badge content"
3812
+ msgstr ""
3813
+
3814
+ #: v2/App/Views/Admin/Tabs/settings.php:141
3815
+ msgid ""
3816
+ "You can use HTML inside. <br><b>IMPORTANT NOTE:</b> This customized sale "
3817
+ "badge will be applicable only for products that are part of the discount "
3818
+ "rules configured in this plugin <b>Eg:</b><span class=\"onsale\">Sale!</span>"
3819
+ msgstr ""
3820
+
3821
+ #: v2/App/Views/Admin/Tabs/settings.php:152
3822
+ msgid "Show discount table "
3823
+ msgstr ""
3824
+
3825
+ #: v2/App/Views/Admin/Tabs/settings.php:153
3826
+ msgid "Show discount table on product page"
3827
+ msgstr ""
3828
+
3829
+ #: v2/App/Views/Admin/Tabs/settings.php:162
3830
+ #: v2/App/Views/Admin/Tabs/settings.php:464
3831
+ msgid "Customize Discount Table"
3832
+ msgstr ""
3833
+
3834
+ #: v2/App/Views/Admin/Tabs/settings.php:169
3835
+ msgid "Position to show discount table"
3836
+ msgstr ""
3837
+
3838
+ #: v2/App/Views/Admin/Tabs/settings.php:170
3839
+ msgid "Position to show discount table on product page"
3840
+ msgstr ""
3841
+
3842
+ #: v2/App/Views/Admin/Tabs/settings.php:174
3843
+ #: v2/App/Views/Admin/Tabs/settings.php:192
3844
+ msgid "Woocommerce before add to cart form"
3845
+ msgstr ""
3846
+
3847
+ #: v2/App/Views/Admin/Tabs/settings.php:175
3848
+ #: v2/App/Views/Admin/Tabs/settings.php:193
3849
+ msgid "Woocommerce product meta end"
3850
+ msgstr ""
3851
+
3852
+ #: v2/App/Views/Admin/Tabs/settings.php:176
3853
+ #: v2/App/Views/Admin/Tabs/settings.php:194
3854
+ msgid "Woocommerce product meta start"
3855
+ msgstr ""
3856
+
3857
+ #: v2/App/Views/Admin/Tabs/settings.php:177
3858
+ #: v2/App/Views/Admin/Tabs/settings.php:195
3859
+ msgid "Woocommerce after add to cart form"
3860
+ msgstr ""
3861
+
3862
+ #: v2/App/Views/Admin/Tabs/settings.php:187
3863
+ msgid "Position to show discount bar"
3864
+ msgstr ""
3865
+
3866
+ #: v2/App/Views/Admin/Tabs/settings.php:188
3867
+ msgid "Position to show discount bar on product page"
3868
+ msgstr ""
3869
+
3870
+ #: v2/App/Views/Admin/Tabs/settings.php:205
3871
+ msgid "Show strikeout price"
3872
+ msgstr ""
3873
+
3874
+ #: v2/App/Views/Admin/Tabs/settings.php:206
3875
+ msgid "Show product strikeout price on"
3876
+ msgstr ""
3877
+
3878
+ #: v2/App/Views/Admin/Tabs/settings.php:211
3879
+ msgid "On shop page?"
3880
+ msgstr ""
3881
+
3882
+ #: v2/App/Views/Admin/Tabs/settings.php:214
3883
+ msgid "On product page?"
3884
+ msgstr ""
3885
+
3886
+ #: v2/App/Views/Admin/Tabs/settings.php:217
3887
+ msgid "On category page?"
3888
+ msgstr ""
3889
+
3890
+ #: v2/App/Views/Admin/Tabs/settings.php:223
3891
+ msgid "Show Strikeout when"
3892
+ msgstr ""
3893
+
3894
+ #: v2/App/Views/Admin/Tabs/settings.php:224
3895
+ msgid "Show Strikeout when this option is matched"
3896
+ msgstr ""
3897
+
3898
+ #: v2/App/Views/Admin/Tabs/settings.php:247
3899
+ msgid "Show strikeout on cart"
3900
+ msgstr ""
3901
+
3902
+ #: v2/App/Views/Admin/Tabs/settings.php:248
3903
+ msgid "Show price strikeout on cart"
3904
+ msgstr ""
3905
+
3906
+ #: v2/App/Views/Admin/Tabs/settings.php:262
3907
+ msgid "Combine all cart discounts"
3908
+ msgstr ""
3909
+
3910
+ #: v2/App/Views/Admin/Tabs/settings.php:263
3911
+ msgid "Combine all cart discounts in single discount label"
3912
+ msgstr ""
3913
+
3914
+ #: v2/App/Views/Admin/Tabs/settings.php:282
3915
+ #: v2/App/Views/Admin/Tabs/settings.php:283
3916
+ msgid "Discount label for combined discounts"
3917
+ msgstr ""
3918
+
3919
+ #: v2/App/Views/Admin/Tabs/settings.php:300
3920
+ msgid "Display you saved text"
3921
+ msgstr ""
3922
+
3923
+ #: v2/App/Views/Admin/Tabs/settings.php:301
3924
+ msgid "Display you saved text when rule applied"
3925
+ msgstr ""
3926
+
3927
+ #: v2/App/Views/Admin/Tabs/settings.php:316
3928
+ msgid "You save text to show when rule applied"
3929
+ msgstr ""
3930
+
3931
+ #: v2/App/Views/Admin/Tabs/settings.php:325
3932
+ msgid "Show a discount applied message on cart?"
3933
+ msgstr ""
3934
+
3935
+ #: v2/App/Views/Admin/Tabs/settings.php:326
3936
+ msgid "Show message in cart page on rule applied"
3937
+ msgstr ""
3938
+
3939
+ #: v2/App/Views/Admin/Tabs/settings.php:342
3940
+ msgid "Applied rule message text on cart"
3941
+ msgstr ""
3942
+
3943
+ #: v2/App/Views/Admin/Tabs/settings.php:343
3944
+ msgid "Text to show when rule applied"
3945
+ msgstr ""
3946
+
3947
+ #: v2/App/Views/Admin/Tabs/settings.php:353
3948
+ msgid "Banner"
3949
+ msgstr ""
3950
+
3951
+ #: v2/App/Views/Admin/Tabs/settings.php:360
3952
+ msgid "Banner Content"
3953
+ msgstr ""
3954
+
3955
+ #: v2/App/Views/Admin/Tabs/settings.php:361
3956
+ msgid ""
3957
+ "A static banner you that you want to display in your storefront. <br><br> "
3958
+ "<b>NOTE:</b> It is a static banner. You can use any content or html here."
3959
+ msgstr ""
3960
+
3961
+ #: v2/App/Views/Admin/Tabs/settings.php:370
3962
+ msgid "Banner Content display position"
3963
+ msgstr ""
3964
+
3965
+ #: v2/App/Views/Admin/Tabs/settings.php:371
3966
+ msgid "Choose a display position for the banner in your storefront"
3967
+ msgstr ""
3968
+
3969
+ #: v2/App/Views/Admin/Tabs/settings.php:382
3970
+ msgid "On-Sale page"
3971
+ msgstr ""
3972
+
3973
+ #: v2/App/Views/Admin/Tabs/settings.php:388
3974
+ msgid "Select rules for the On Sale Page"
3975
+ msgstr ""
3976
+
3977
+ #: v2/App/Views/Admin/Tabs/settings.php:401
3978
+ msgid "Type the name of the rule to select it"
3979
+ msgstr ""
3980
+
3981
+ #: v2/App/Views/Admin/Tabs/settings.php:409
3982
+ msgid "All active rules"
3983
+ msgstr ""
3984
+
3985
+ #: v2/App/Views/Admin/Tabs/settings.php:434
3986
+ msgid "Save and Build Index"
3987
+ msgstr ""
3988
+
3989
+ #: v2/App/Views/Admin/Tabs/settings.php:444
3990
+ msgid ""
3991
+ "ShortCode to load all products which has discount through Woo Discount Rules"
3992
+ msgstr ""
3993
+
3994
+ #: v2/App/Views/Admin/Tabs/settings.php:467
3995
+ msgid "Settings Saved"
3996
+ msgstr ""
3997
+
3998
+ #: v2/App/Views/Admin/Tabs/settings.php:468
3999
+ msgid " This table contains sample content for design purpose."
4000
+ msgstr ""
4001
+
4002
+ #: v2/App/Views/Admin/Tabs/settings.php:478
4003
+ msgid "Table Header"
4004
+ msgstr ""
4005
+
4006
+ #: v2/App/Views/Admin/Tabs/settings.php:479
4007
+ msgid "Show/Hide table header column names"
4008
+ msgstr ""
4009
+
4010
+ #: v2/App/Views/Admin/Tabs/settings.php:492
4011
+ msgid "Title column Name on table"
4012
+ msgstr ""
4013
+
4014
+ #: v2/App/Views/Admin/Tabs/settings.php:493
4015
+ msgid "Give name for rule title column"
4016
+ msgstr ""
4017
+
4018
+ #: v2/App/Views/Admin/Tabs/settings.php:504
4019
+ msgid "Discount column Name on table"
4020
+ msgstr ""
4021
+
4022
+ #: v2/App/Views/Admin/Tabs/settings.php:505
4023
+ msgid "Give name for discount column"
4024
+ msgstr ""
4025
+
4026
+ #: v2/App/Views/Admin/Tabs/settings.php:516
4027
+ msgid "Range column Name on table"
4028
+ msgstr ""
4029
+
4030
+ #: v2/App/Views/Admin/Tabs/settings.php:517
4031
+ msgid "Give name for range column"
4032
+ msgstr ""
4033
+
4034
+ #: v2/App/Views/Admin/Tabs/settings.php:528
4035
+ msgid "Discount column value on table"
4036
+ msgstr ""
4037
+
4038
+ #: v2/App/Views/Admin/Tabs/settings.php:529
4039
+ msgid "Show Discount value/price in table"
4040
+ msgstr ""
4041
+
4042
+ #: v2/App/Views/Admin/Tabs/settings.php:537
4043
+ msgid "Discounted Price"
4044
+ msgstr ""
4045
+
4046
+ #: v2/App/Views/Admin/Tabs/settings.php:612
4047
+ #: v2/App/Views/Admin/Tabs/settings.php:635
4048
+ msgid "Bulk Rule"
4049
+ msgstr ""
4050
+
4051
+ #: v2/App/Views/Admin/Tabs/settings.php:620
4052
+ #: v2/App/Views/Admin/Tabs/settings.php:666
4053
+ #: v2/App/Views/Admin/Tabs/settings.php:733
4054
+ #: v2/App/Views/Templates/discount_table.php:111
4055
+ msgid " flat"
4056
+ msgstr ""
4057
+
4058
+ #: v2/App/Views/Admin/Tabs/settings.php:626
4059
+ msgid "1 - 5"
4060
+ msgstr ""
4061
+
4062
+ #: v2/App/Views/Admin/Tabs/settings.php:649
4063
+ msgid "11 - 15"
4064
+ msgstr ""
4065
+
4066
+ #: v2/App/Views/Admin/Tabs/settings.php:658
4067
+ msgid "Bulk Flat discount"
4068
+ msgstr ""
4069
+
4070
+ #: v2/App/Views/Admin/Tabs/settings.php:672
4071
+ msgid "50 - 60"
4072
+ msgstr ""
4073
+
4074
+ #: v2/App/Views/Admin/Tabs/settings.php:681
4075
+ msgid "Bulk percentage discount"
4076
+ msgstr ""
4077
+
4078
+ #: v2/App/Views/Admin/Tabs/settings.php:694
4079
+ msgid "70 - 80"
4080
+ msgstr ""
4081
+
4082
+ #: v2/App/Views/Admin/Tabs/settings.php:703
4083
+ #, php-format
4084
+ msgid "Bulk % discount"
4085
+ msgstr ""
4086
+
4087
+ #: v2/App/Views/Admin/Tabs/settings.php:716
4088
+ msgid "450 - 500"
4089
+ msgstr ""
4090
+
4091
+ #: v2/App/Views/Admin/Tabs/settings.php:725
4092
+ msgid "Bulk flat"
4093
+ msgstr ""
4094
+
4095
+ #: v2/App/Views/Admin/Tabs/settings.php:739
4096
+ msgid "600 - 700"
4097
+ msgstr ""
4098
+
4099
+ #: v2/App/Views/Admin/Tabs/settings.php:748
4100
+ msgid "set percentage discount"
4101
+ msgstr ""
4102
+
4103
+ #: v2/App/Views/Admin/Tabs/settings.php:761
4104
+ msgid "5"
4105
+ msgstr ""
4106
+
4107
+ #: v2/App/Views/Admin/Tabs/settings.php:770
4108
+ msgid "Fixed discount for set"
4109
+ msgstr ""
4110
+
4111
+ #: v2/App/Views/Admin/Tabs/settings.php:783
4112
+ msgid "10"
4113
+ msgstr ""
4114
+
4115
+ #: v2/App/Views/Admin/Tabs/settings.php:792
4116
+ msgid "set flat discount"
4117
+ msgstr ""
4118
+
4119
+ #: v2/App/Views/Admin/Tabs/settings.php:805
4120
+ msgid "15"
4121
+ msgstr ""
4122
+
4123
+ #: v2/App/Views/Templates/discount_table.php:106
4124
+ msgid " (in cart)"
4125
+ msgstr ""
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.4
7
- Stable tag: 1.9.7
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -336,6 +336,13 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
336
 
337
  == Changelog ==
338
 
 
 
 
 
 
 
 
339
  = 1.9.7 - 20/04/20 =
340
  * Fix - PHP warning count()
341
  * Improvement - Changed the script handle name
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.4
7
+ Stable tag: 1.9.8
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
336
 
337
  == Changelog ==
338
 
339
+ = 1.9.8 - 13/05/20 =
340
+ * Feature - Included v2 beta with new UI
341
+ * Fix - PHP warning fix
342
+ * Improvement - Event: apply_filters('woo_discount_rules_discounted_suffix_price', $discountPrice, $product);
343
+ * Improvement - Event: woo_discount_rule_generate_discount_table_information, woo_discount_rule_discount_table_information
344
+ * Improvement - Don't add free product when haveToApplyTheRules method return false
345
+
346
  = 1.9.7 - 20/04/20 =
347
  * Fix - PHP warning count()
348
  * Improvement - Changed the script handle name
{assets → v1/assets}/css/bootstrap-datetimepicker.min.css RENAMED
File without changes
{assets → v1/assets}/css/bootstrap.min.css RENAMED
File without changes
{assets → v1/assets}/css/bootstrap.select.min.css RENAMED
File without changes
{assets → v1/assets}/css/custom.css RENAMED
File without changes
{assets → v1/assets}/css/jquery-ui.css RENAMED
File without changes
{assets → v1/assets}/css/select2.min.css RENAMED
File without changes
{assets → v1/assets}/css/style.css RENAMED
@@ -267,4 +267,81 @@ select.discount_product_option,
267
  }
268
  .wdr_price_rule_listing_table_con{
269
  padding: 0 15px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  }
267
  }
268
  .wdr_price_rule_listing_table_con{
269
  padding: 0 15px;
270
+ }
271
+
272
+ /*Model Popup*/
273
+ .wdr_woo_discount_header_con .modal,
274
+ .wdr_woo_discount_header_con .modal-box {
275
+ z-index: 9999;
276
+ }
277
+
278
+ .wdr_woo_discount_header_con .modal-sandbox {
279
+ position: fixed;
280
+ width: 100%;
281
+ height: 100%;
282
+ top: 0;
283
+ left: 0;
284
+ background: transparent;
285
+ }
286
+
287
+ .wdr_woo_discount_header_con .modal {
288
+ display: none;
289
+ position: fixed;
290
+ width: 100%;
291
+ height: 100%;
292
+ left: 0;
293
+ top: 0;
294
+ background: rgb(0,0,0);
295
+ background: rgba(0,0,0,.8);
296
+ overflow: auto;
297
+ }
298
+
299
+ .wdr_woo_discount_header_con .modal-box {
300
+ position: relative;
301
+ width: 80%;
302
+ max-width: 920px;
303
+ margin: 100px auto;
304
+ animation-name: modalbox;
305
+ animation-duration: .4s;
306
+ animation-timing-function: cubic-bezier(0,0,.3,1.6);
307
+ }
308
+
309
+ .wdr_woo_discount_header_con .modal-header {
310
+ padding: 20px 40px;
311
+ background: #6495ed;
312
+ color: #ffffff;
313
+ }
314
+
315
+ .wdr_woo_discount_header_con .modal-body {
316
+ background: #ECEFF1;
317
+ padding: 50px 15px;
318
+ }
319
+
320
+ /* Close Button */
321
+ .wdr_woo_discount_header_con .close-modal {
322
+ text-align: right;
323
+ cursor: pointer;
324
+ }
325
+
326
+ /* Animation */
327
+ @-webkit-keyframes modalbox {
328
+ 0% {
329
+ top: -250px;
330
+ opacity: 0;
331
+ }
332
+ 100% {
333
+ top: 0;
334
+ opacity: 1;
335
+ }
336
+ }
337
+
338
+ @keyframes modalbox {
339
+ 0% {
340
+ top: -250px;
341
+ opacity: 0;
342
+ }
343
+ 100% {
344
+ top: 0;
345
+ opacity: 1;
346
+ }
347
  }
{assets → v1/assets}/css/tabbablePanel.css RENAMED
File without changes
{assets → v1/assets}/css/woo_discount_rules.css RENAMED
File without changes
{assets → v1/assets}/fonts/glyphicons-halflings-regular.eot RENAMED
File without changes
{assets → v1/assets}/fonts/glyphicons-halflings-regular.svg RENAMED
File without changes
{assets → v1/assets}/fonts/glyphicons-halflings-regular.ttf RENAMED
File without changes
{assets → v1/assets}/fonts/glyphicons-halflings-regular.woff RENAMED
File without changes
{assets → v1/assets}/fonts/glyphicons-halflings-regular.woff2 RENAMED
File without changes
{assets → v1/assets}/js/app.js RENAMED
@@ -263,10 +263,10 @@ function wooo_discount_range_altered() {
263
  license_key.removeClass('invalid-field');
264
  resp_msg.html('');
265
  }
266
-
267
  var form = $('#discount_config').serialize();
268
  var current = $(this);
269
-
270
  event.preventDefault();
271
 
272
  current.removeClass('button-primary');
@@ -283,26 +283,26 @@ function wooo_discount_range_altered() {
283
  current.removeClass('button-secondary');
284
  current.val('Validate');
285
  }, 300);
286
-
287
  //adminNotice();
288
  // display a success message
289
  }
290
  });
291
  license_chk_req.done(function( resp ) {
292
-
293
- response = JSON.parse(resp);
294
- if (response['error']) {
295
- resp_msg.html('<div class="notice-message error inline notice-error notice-alt">'+response['error']+'</div>');
296
- } else if( response['success']){
297
- resp_msg.html('<div class="notice-message success inline notice-success notice-alt">'+response['success']+'</div>');
298
- }
299
-
300
- });
301
  });
302
 
303
  //To add an duplicate range fields
304
  $(document).on('click', '.create_duplicate_discount_range', function () {
305
- //$(".create_duplicate_discount_range").on('click', function () {
306
  var data_id = $(this).attr('data-id');
307
  $('#addNewDiscountRange').trigger('click');
308
  var new_inputs = $("#discount_rule_list .discount_rule_list:last-child").find('input,select');
@@ -788,10 +788,10 @@ function wooo_discount_range_altered() {
788
  '<option disabled>'+woo_discount_localization.exclude_sale_products+' <b>' + pro_suffix + '</b></option>' +
789
  '</optgroup>' +
790
  '<optgroup label="'+woo_discount_localization.categories_in_cart+'">' +
791
- '<option disabled>'+woo_discount_localization.categories_in_cart+' <b>' + pro_suffix + '</b></option>' +
792
- '<option disabled>'+woo_discount_localization.atleast_one_including_sub_categories+' <b>' + pro_suffix + '</b></option>' +
793
- '<option disabled>'+woo_discount_localization.in_each_category_cart+' <b>' + pro_suffix + '</b></option>' +
794
- '<option disabled>'+woo_discount_localization.exclude_categories_in_cart+' <b>' + pro_suffix + '</b></option>' +
795
  '</optgroup>' +
796
  '<optgroup label="'+woo_discount_localization.customer_details_must_be_logged_in+'"><option disabled>'+woo_discount_localization.user_in_list+' <b>' + pro_suffix + '</b></option><option disabled>'+woo_discount_localization.user_role_in_list+' <b>' + pro_suffix + '</b></option></optgroup>' +
797
  '<optgroup label="'+woo_discount_localization.customer_email+'"><option disabled>'+woo_discount_localization.customer_email_tld+' <b>' + pro_suffix + '</b></option><option disabled>'+woo_discount_localization.customer_email_domain+'<b>' + pro_suffix + '</b></option></optgroup>' +
@@ -1145,6 +1145,52 @@ function wooo_discount_range_altered() {
1145
  }
1146
  });
1147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1148
  // Removing Cart Condition.
1149
  $(document).on('click', '.remove_cart_rule', function () {
1150
  var confirm_remove = confirm(woo_discount_localization.are_you_sure_to_remove);
@@ -1279,7 +1325,7 @@ function wooo_discount_range_altered() {
1279
 
1280
  $('.duplicate_price_rule_btn').on('click', function (event) {
1281
  event.preventDefault();
1282
- ; createDuplicateRule($(this).attr('data-id'), 'price_rule');
1283
  });
1284
  $('.duplicate_cart_rule_btn').on('click', function (event) {
1285
  event.preventDefault();
@@ -1394,7 +1440,7 @@ function wooo_discount_range_altered() {
1394
  $('select#enable_free_shipping').trigger('change');
1395
 
1396
  $(document).on('change', 'select.purchased_history_duration', function () {
1397
- //$('select.purchased_history_duration').on('change', function () {
1398
  var option_val = $(this).val();
1399
  var option_index = $(this).attr('data-index');
1400
  if(option_index != undefined && option_index != null && option_index != ''){
263
  license_key.removeClass('invalid-field');
264
  resp_msg.html('');
265
  }
266
+
267
  var form = $('#discount_config').serialize();
268
  var current = $(this);
269
+
270
  event.preventDefault();
271
 
272
  current.removeClass('button-primary');
283
  current.removeClass('button-secondary');
284
  current.val('Validate');
285
  }, 300);
286
+
287
  //adminNotice();
288
  // display a success message
289
  }
290
  });
291
  license_chk_req.done(function( resp ) {
292
+
293
+ response = JSON.parse(resp);
294
+ if (response['error']) {
295
+ resp_msg.html('<div class="notice-message error inline notice-error notice-alt">'+response['error']+'</div>');
296
+ } else if( response['success']){
297
+ resp_msg.html('<div class="notice-message success inline notice-success notice-alt">'+response['success']+'</div>');
298
+ }
299
+
300
+ });
301
  });
302
 
303
  //To add an duplicate range fields
304
  $(document).on('click', '.create_duplicate_discount_range', function () {
305
+ //$(".create_duplicate_discount_range").on('click', function () {
306
  var data_id = $(this).attr('data-id');
307
  $('#addNewDiscountRange').trigger('click');
308
  var new_inputs = $("#discount_rule_list .discount_rule_list:last-child").find('input,select');
788
  '<option disabled>'+woo_discount_localization.exclude_sale_products+' <b>' + pro_suffix + '</b></option>' +
789
  '</optgroup>' +
790
  '<optgroup label="'+woo_discount_localization.categories_in_cart+'">' +
791
+ '<option disabled>'+woo_discount_localization.categories_in_cart+' <b>' + pro_suffix + '</b></option>' +
792
+ '<option disabled>'+woo_discount_localization.atleast_one_including_sub_categories+' <b>' + pro_suffix + '</b></option>' +
793
+ '<option disabled>'+woo_discount_localization.in_each_category_cart+' <b>' + pro_suffix + '</b></option>' +
794
+ '<option disabled>'+woo_discount_localization.exclude_categories_in_cart+' <b>' + pro_suffix + '</b></option>' +
795
  '</optgroup>' +
796
  '<optgroup label="'+woo_discount_localization.customer_details_must_be_logged_in+'"><option disabled>'+woo_discount_localization.user_in_list+' <b>' + pro_suffix + '</b></option><option disabled>'+woo_discount_localization.user_role_in_list+' <b>' + pro_suffix + '</b></option></optgroup>' +
797
  '<optgroup label="'+woo_discount_localization.customer_email+'"><option disabled>'+woo_discount_localization.customer_email_tld+' <b>' + pro_suffix + '</b></option><option disabled>'+woo_discount_localization.customer_email_domain+'<b>' + pro_suffix + '</b></option></optgroup>' +
1145
  }
1146
  });
1147
 
1148
+
1149
+ $('.awdr-switch-version-button').on('click', function (event) {
1150
+ event.preventDefault();
1151
+ var version = $(this).attr('data-version');
1152
+ var page = $(this).attr('data-page');
1153
+ $.ajax({
1154
+ url: ajax_url,
1155
+ type: 'POST',
1156
+ data: {action: 'awdr_switch_version', version: version, page: page},
1157
+ success: function (data) {
1158
+ if(data.data.status == true){
1159
+ window.location.replace(data.data.url);
1160
+ }
1161
+ if(data.data.type !== undefined){
1162
+ if(data.data.type == 'auto_install'){
1163
+ $("#wdr_switch_popup").modal("show");
1164
+ $(".wdr_pro_install_message").html(data.data.message);
1165
+ } else {
1166
+ $(".wdr_switch_message").html(data.data.message);
1167
+ }
1168
+ } else {
1169
+ $(".wdr_switch_message").html(data.data.message);
1170
+ }
1171
+ }
1172
+ });
1173
+ });
1174
+ $(document).on('click', '#wdr_switch_popup .wdr-close-modal-box, #wdr_switch_popup .modal-sandbox', function (event) {
1175
+ $('#wdr_switch_popup').modal('hide');
1176
+ });
1177
+ $(document).on('click', '.awdr_auto_install_pro_plugin', function (event) {
1178
+ event.preventDefault();
1179
+ $(".awdr_auto_install_pro_plugin").html("Proccessing please wait..")
1180
+ $.ajax({
1181
+ url: ajax_url,
1182
+ type: 'POST',
1183
+ data: {action: 'awdr_auto_install_pro_plugin'},
1184
+ success: function (data) {
1185
+ $(".wdr_switch_message").html('');
1186
+ $(".wdr_pro_install_message").html(data);
1187
+ if($("#wdr_pro_install_status").val() == "1"){
1188
+ $('.awdr-switch-version-button').trigger('click');
1189
+ }
1190
+ }
1191
+ });
1192
+ });
1193
+
1194
  // Removing Cart Condition.
1195
  $(document).on('click', '.remove_cart_rule', function () {
1196
  var confirm_remove = confirm(woo_discount_localization.are_you_sure_to_remove);
1325
 
1326
  $('.duplicate_price_rule_btn').on('click', function (event) {
1327
  event.preventDefault();
1328
+ ; createDuplicateRule($(this).attr('data-id'), 'price_rule');
1329
  });
1330
  $('.duplicate_cart_rule_btn').on('click', function (event) {
1331
  event.preventDefault();
1440
  $('select#enable_free_shipping').trigger('change');
1441
 
1442
  $(document).on('change', 'select.purchased_history_duration', function () {
1443
+ //$('select.purchased_history_duration').on('change', function () {
1444
  var option_val = $(this).val();
1445
  var option_index = $(this).attr('data-index');
1446
  if(option_index != undefined && option_index != null && option_index != ''){
{assets → v1/assets}/js/bootstrap-datetimepicker.min.js RENAMED
File without changes
{assets → v1/assets}/js/bootstrap.min.js RENAMED
File without changes
{assets → v1/assets}/js/bootstrap.select.min.js RENAMED
File without changes
{assets → v1/assets}/js/select2.min.js RENAMED
File without changes
{assets → v1/assets}/js/woo_discount_rules.js RENAMED
File without changes
{helper → v1/helper}/activation-helper.php RENAMED
File without changes
{helper → v1/helper}/general-helper.php RENAMED
File without changes
{helper → v1/helper}/purchase.php RENAMED
File without changes
{helper → v1/helper}/woo-function.php RENAMED
File without changes
{includes → v1/includes}/cart-rules.php RENAMED
@@ -351,6 +351,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
351
  public function analyse($woocommerce, $free_shipping_check = 0)
352
  {
353
  global $woocommerce;
 
354
  // Re-arranging the Rules.
355
  $this->organizeRules();
356
  // Apply Group of Rules.
@@ -363,8 +364,6 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
363
  global $flycart_woo_discount_rules;
364
  $flycart_woo_discount_rules->cart_rules = $this;
365
 
366
- if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
367
-
368
  // Add a Coupon Virtually (Temporary access).
369
  if(!$free_shipping_check)
370
  if ($this->discount_total != 0) {
@@ -2336,7 +2335,11 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
2336
  continue;
2337
  }
2338
  $product_id = FlycartWoocommerceProduct::get_id($cart_item['data']);
2339
- $added_products[$product_id] = array('product'=> $cart_item['data'], 'item_name'=> FlycartWoocommerceProduct::get_name($cart_item['data']), 'item_quantity' => $cart_item['quantity'], 'item' => $cart_item_key, 'item_price' => FlycartWoocommerceProduct::get_price($cart_item['data'], true));
 
 
 
 
2340
  }
2341
  if(is_array($product_ids) && count($product_ids)){
2342
  foreach ($product_ids as $discounted_product_id) {
351
  public function analyse($woocommerce, $free_shipping_check = 0)
352
  {
353
  global $woocommerce;
354
+ if (!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
355
  // Re-arranging the Rules.
356
  $this->organizeRules();
357
  // Apply Group of Rules.
364
  global $flycart_woo_discount_rules;
365
  $flycart_woo_discount_rules->cart_rules = $this;
366
 
 
 
367
  // Add a Coupon Virtually (Temporary access).
368
  if(!$free_shipping_check)
369
  if ($this->discount_total != 0) {
2335
  continue;
2336
  }
2337
  $product_id = FlycartWoocommerceProduct::get_id($cart_item['data']);
2338
+ if (isset($added_products[$product_id]) && !empty($added_products[$product_id])) {
2339
+ $added_products[$product_id]['item_quantity'] = $added_products[$product_id]['item_quantity'] + $cart_item['quantity'];
2340
+ } else {
2341
+ $added_products[$product_id] = array('product' => $cart_item['data'], 'item_name' => FlycartWoocommerceProduct::get_name($cart_item['data']), 'item_quantity' => $cart_item['quantity'], 'item' => $cart_item_key, 'item_price' => FlycartWoocommerceProduct::get_price($cart_item['data'], true));
2342
+ }
2343
  }
2344
  if(is_array($product_ids) && count($product_ids)){
2345
  foreach ($product_ids as $discounted_product_id) {
{includes → v1/includes}/compatibility.php RENAMED
@@ -70,10 +70,10 @@ if (!class_exists('FlycartWooDiscountRulesCompatibility')) {
70
  foreach ($additional_taxonomies as $taxonomy) {
71
  $terms = get_the_terms($product_id, $taxonomy);
72
  if (!empty($terms)) {
73
- if((is_object($terms) || is_array($terms))) {
74
  if (FlycartWooDiscountRulesGeneralHelper::is_countable($terms)) {
75
  foreach ($terms as $term) {
76
- if(!empty($term->term_id)){
77
  $categories[] = $term->term_id;
78
  }
79
  }
70
  foreach ($additional_taxonomies as $taxonomy) {
71
  $terms = get_the_terms($product_id, $taxonomy);
72
  if (!empty($terms)) {
73
+ if ((is_object($terms) || is_array($terms))) {
74
  if (FlycartWooDiscountRulesGeneralHelper::is_countable($terms)) {
75
  foreach ($terms as $term) {
76
+ if (!empty($term->term_id)) {
77
  $categories[] = $term->term_id;
78
  }
79
  }
{includes → v1/includes}/discount-base.php RENAMED
@@ -144,13 +144,19 @@ if (!class_exists('FlycartWooDiscountBase')) {
144
  */
145
  public function storeLog($order_id)
146
  {
147
- $log['price_discount'] = WC()->session->get('woo_price_discount', array());
148
- $log['cart_discount'] = WC()->session->get('woo_cart_discount', array());
 
 
 
149
 
150
- add_post_meta($order_id, 'woo_discount_log', json_encode($log), 1);
151
 
152
- // Reset the Coupon Status.
153
- WC()->session->set('woo_coupon_removed', '');
 
 
 
154
  }
155
 
156
  /**
144
  */
145
  public function storeLog($order_id)
146
  {
147
+ if (function_exists('WC')) {
148
+ if (!empty(WC()->session)) {
149
+ if (method_exists(WC()->session, 'get')) {
150
+ $log['price_discount'] = WC()->session->get('woo_price_discount', array());
151
+ $log['cart_discount'] = WC()->session->get('woo_cart_discount', array());
152
 
153
+ add_post_meta($order_id, 'woo_discount_log', json_encode($log), 1);
154
 
155
+ // Reset the Coupon Status.
156
+ WC()->session->set('woo_coupon_removed', '');
157
+ }
158
+ }
159
+ }
160
  }
161
 
162
  /**
{includes → v1/includes}/pricing-productbased.php RENAMED
File without changes
{includes → v1/includes}/pricing-rules.php RENAMED
@@ -698,7 +698,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
698
  $product = FlycartWoocommerceProduct::wc_get_product($free_product_id);
699
  $productParentId = FlycartWoocommerceProduct::get_parent_id($product);
700
  if($productParentId){
701
- FlycartWoocommerceCart::add_to_cart($productParentId, $bogo_match['count'], $free_product_id, FlycartWoocommerceProduct::get_attributes($product));
 
 
702
  } else {
703
  FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
704
  }
@@ -3073,6 +3075,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3073
  $newTableContent->advance_table_format = empty($rule->advance_table_format)? '': $rule->advance_table_format;
3074
  $condition = $this->getTextForProductDiscountCondition($rule);
3075
  $newTableContent->condition = $condition;
 
3076
  $discount_range[][] = $newTableContent;
3077
  }
3078
  }
@@ -3395,7 +3398,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3395
  }
3396
  $dataReturn[$index.$id]['title'] = $title;
3397
  $dataReturn[$index.$id]['condition'] = apply_filters('woo_discount_rules_table_content_condition_html', $condition, $value);
3398
- $dataReturn[$index.$id]['discount'] = apply_filters('woo_discount_rules_table_content_discount_html', $discount, $value->discount_type, $value->to_discount, $value);
 
3399
  }
3400
  }
3401
  }
@@ -4006,10 +4010,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4006
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
4007
  return self::$product_strike_out_price[$product_id];
4008
  }
4009
- if($discountPrice > 0 || ($this->hasDiscountForProductId($product_id))){
4010
  $price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
4011
  $item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
4012
- $item_price = '<del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix($discountPrice) . '</ins>';
 
4013
  }
4014
  self::$product_strike_out_price[$product_id] = $item_price;
4015
  }
@@ -4056,8 +4061,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4056
  $price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display, $show_original);
4057
  }
4058
  if(!$show_original){
 
4059
  self::$product_has_strike_out[$product_id]['has_strikeout'] = 1;
4060
- self::$product_has_strike_out[$product_id]['new_strikeout_html'] = ($price_to_display).$product->get_price_suffix($discountPrice);
4061
  if($do_discount_from_regular_price){
4062
  $item_price = preg_replace('/<ins>.*<\/ins>/', '', $item_price);
4063
  } else {
@@ -4065,7 +4071,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4065
  }
4066
  $item_price = apply_filters('woo_discount_rules_price_strikeout_before_discount_price', $item_price, $product);
4067
  $original_item_price = $item_price;
4068
- $new_item_price = (($price_to_display).$product->get_price_suffix($discountPrice));
4069
  $is_both_are_same = FlycartWooDiscountRulesGeneralHelper::is_same_string($original_item_price, $new_item_price);
4070
  if(!$is_both_are_same){
4071
  $item_price = '<span class="cart_price wdr_product_strikeout"><del>' . $original_item_price . '</del> <ins>' . $new_item_price . '</ins></span>';
@@ -4090,11 +4096,12 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4090
  // if(!empty(self::$product_on_sale_details[$product_id])){
4091
  $sale_price = FlycartWoocommerceProduct::get_sale_price($product);
4092
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
4093
- if($sale_price <= 0){
4094
  $item_price = '<span class="cart_price wdr_product_strikeout">';
4095
  $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
4096
  $price_to_display = FlycartWoocommerceProduct::wc_price($regular_price);
4097
- $item_price .= (($price_to_display).$product->get_price_suffix($regular_price));
 
4098
  $item_price .= '</span>';
4099
  return $item_price;
4100
  }
@@ -4274,16 +4281,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4274
  $product_type = $product->get_type();
4275
  $sale_price = FlycartWoocommerceProduct::get_sale_price($product);
4276
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
4277
- if($sale_price > 0){
4278
  $html = '<span class="cart_price wdr_product_strikeout">';
4279
  $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
4280
  $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
4281
- if($product_type == 'variation'){
4282
  $html .= '<span class="price">';
4283
  }
4284
- $html .= "<del>".FlycartWoocommerceProduct::wc_price($regular_price)."</del>";
4285
- $html .= "<ins>".FlycartWoocommerceProduct::wc_price($sale_price).$product->get_price_suffix($sale_price)."</ins>";
4286
- if($product_type == 'variation'){
 
4287
  $html .= '</span>';
4288
  }
4289
  $html .= '</span>';
@@ -4291,11 +4299,12 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4291
  $sale_price = FlycartWoocommerceProduct::get_price($product);
4292
  $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
4293
  $html = '';
4294
- if($product_type == 'variation'){
4295
  $html = '<span class="price">';
4296
  }
4297
- $html .= FlycartWoocommerceProduct::wc_price($sale_price).$product->get_price_suffix($sale_price);
4298
- if($product_type == 'variation'){
 
4299
  $html .= '</span>';
4300
  }
4301
  }
698
  $product = FlycartWoocommerceProduct::wc_get_product($free_product_id);
699
  $productParentId = FlycartWoocommerceProduct::get_parent_id($product);
700
  if($productParentId){
701
+ $variations = FlycartWoocommerceProduct::get_attributes($product);
702
+ $variations = apply_filters('woo_discount_rule_product_variations', $variations, $product, $free_product_id);
703
+ FlycartWoocommerceCart::add_to_cart($productParentId, $bogo_match['count'], $free_product_id, $variations);
704
  } else {
705
  FlycartWoocommerceCart::add_to_cart($free_product_id, $bogo_match['count']);
706
  }
3075
  $newTableContent->advance_table_format = empty($rule->advance_table_format)? '': $rule->advance_table_format;
3076
  $condition = $this->getTextForProductDiscountCondition($rule);
3077
  $newTableContent->condition = $condition;
3078
+ $newTableContent = apply_filters('woo_discount_rule_generate_discount_table_information', $newTableContent, $rule);
3079
  $discount_range[][] = $newTableContent;
3080
  }
3081
  }
3398
  }
3399
  $dataReturn[$index.$id]['title'] = $title;
3400
  $dataReturn[$index.$id]['condition'] = apply_filters('woo_discount_rules_table_content_condition_html', $condition, $value);
3401
+ $dataReturn[$index . $id]['discount'] = apply_filters('woo_discount_rules_table_content_discount_html', $discount, $value->discount_type, $value->to_discount, $value);
3402
+ $dataReturn[$index . $id] = apply_filters('woo_discount_rule_discount_table_information', $dataReturn[$index . $id], $value);
3403
  }
3404
  }
3405
  }
4010
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
4011
  return self::$product_strike_out_price[$product_id];
4012
  }
4013
+ if($discountPrice > 0 || ($this->hasDiscountForProductId($product_id))) {
4014
  $price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
4015
  $item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
4016
+ $suffix_price = apply_filters('woo_discount_rules_discounted_suffix_price', $discountPrice, $product);
4017
+ $item_price = '<del>' . $item_price . '</del> <ins>' . ($price_to_display) . $product->get_price_suffix($suffix_price) . '</ins>';
4018
  }
4019
  self::$product_strike_out_price[$product_id] = $item_price;
4020
  }
4061
  $price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display, $show_original);
4062
  }
4063
  if(!$show_original){
4064
+ $suffix_price = apply_filters('woo_discount_rules_discounted_suffix_price', $discountPrice, $product);
4065
  self::$product_has_strike_out[$product_id]['has_strikeout'] = 1;
4066
+ self::$product_has_strike_out[$product_id]['new_strikeout_html'] = ($price_to_display) . $product->get_price_suffix($suffix_price);
4067
  if($do_discount_from_regular_price){
4068
  $item_price = preg_replace('/<ins>.*<\/ins>/', '', $item_price);
4069
  } else {
4071
  }
4072
  $item_price = apply_filters('woo_discount_rules_price_strikeout_before_discount_price', $item_price, $product);
4073
  $original_item_price = $item_price;
4074
+ $new_item_price = (($price_to_display) . $product->get_price_suffix($suffix_price));
4075
  $is_both_are_same = FlycartWooDiscountRulesGeneralHelper::is_same_string($original_item_price, $new_item_price);
4076
  if(!$is_both_are_same){
4077
  $item_price = '<span class="cart_price wdr_product_strikeout"><del>' . $original_item_price . '</del> <ins>' . $new_item_price . '</ins></span>';
4096
  // if(!empty(self::$product_on_sale_details[$product_id])){
4097
  $sale_price = FlycartWoocommerceProduct::get_sale_price($product);
4098
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
4099
+ if($sale_price <= 0) {
4100
  $item_price = '<span class="cart_price wdr_product_strikeout">';
4101
  $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
4102
  $price_to_display = FlycartWoocommerceProduct::wc_price($regular_price);
4103
+ $suffix_price = apply_filters('woo_discount_rules_discounted_suffix_price', $regular_price, $product);
4104
+ $item_price .= (($price_to_display) . $product->get_price_suffix($suffix_price));
4105
  $item_price .= '</span>';
4106
  return $item_price;
4107
  }
4281
  $product_type = $product->get_type();
4282
  $sale_price = FlycartWoocommerceProduct::get_sale_price($product);
4283
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
4284
+ if($sale_price > 0) {
4285
  $html = '<span class="cart_price wdr_product_strikeout">';
4286
  $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
4287
  $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
4288
+ if ($product_type == 'variation') {
4289
  $html .= '<span class="price">';
4290
  }
4291
+ $html .= "<del>" . FlycartWoocommerceProduct::wc_price($regular_price) . "</del>";
4292
+ $suffix_price = apply_filters('woo_discount_rules_discounted_suffix_price', $sale_price, $product);
4293
+ $html .= "<ins>" . FlycartWoocommerceProduct::wc_price($sale_price) . $product->get_price_suffix($suffix_price) . "</ins>";
4294
+ if ($product_type == 'variation') {
4295
  $html .= '</span>';
4296
  }
4297
  $html .= '</span>';
4299
  $sale_price = FlycartWoocommerceProduct::get_price($product);
4300
  $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
4301
  $html = '';
4302
+ if ($product_type == 'variation') {
4303
  $html = '<span class="price">';
4304
  }
4305
+ $suffix_price = apply_filters('woo_discount_rules_discounted_suffix_price', $sale_price, $product);
4306
+ $html .= FlycartWoocommerceProduct::wc_price($sale_price) . $product->get_price_suffix($suffix_price);
4307
+ if ($product_type == 'variation') {
4308
  $html .= '</span>';
4309
  }
4310
  }
{includes → v1/includes}/survey.php RENAMED
File without changes
loader.php → v1/loader.php RENAMED
@@ -18,7 +18,7 @@ if(!function_exists('get_plugin_data')){
18
  /**
19
  * Version of Woo Discount Rules.
20
  */
21
- $pluginDetails = get_plugin_data(plugin_dir_path(__FILE__).'woo-discount-rules.php');
22
  define('WOO_DISCOUNT_VERSION', $pluginDetails['Version']);
23
 
24
  if(!class_exists('FlycartWooDiscountRules')){
@@ -48,7 +48,10 @@ if(!class_exists('FlycartWooDiscountRules')){
48
  $this->hasWPML();
49
  $this->includeFiles();
50
  $this->discountBase = new FlycartWooDiscountBase();
51
- $this->runUpdater();
 
 
 
52
  $this->pricingRules = new FlycartWooDiscountRulesPricingRules();
53
  if (is_admin()) {
54
  $this->loadAdminScripts();
@@ -103,7 +106,7 @@ if(!class_exists('FlycartWooDiscountRules')){
103
  }
104
  $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
105
  $update_url,
106
- plugin_dir_path( __FILE__ ).'woo-discount-rules.php',
107
  'woo-discount-rules'
108
  );
109
  add_action( 'after_plugin_row', array($purchase_helper, 'woodisc_after_plugin_row'),10,3 );
@@ -580,7 +583,7 @@ if(!class_exists('FlycartWooDiscountRules')){
580
  wp_register_style('woo_discount_rules_front_end', WOO_DISCOUNT_URI . '/assets/css/woo_discount_rules.css', array(), WOO_DISCOUNT_VERSION);
581
  wp_enqueue_style('woo_discount_rules_front_end');
582
  // Enqueued script with localized data.
583
- wp_register_script( 'woo_discount_rules_site_v1', WOO_DISCOUNT_URI . '/assets/js/woo_discount_rules.js', array('jquery'), WOO_DISCOUNT_VERSION, true );
584
  wp_localize_script('woo_discount_rules_site_v1', 'woo_discount_rules', array(
585
  'home_url' => get_home_url(),
586
  'admin_url' => admin_url(),
@@ -588,7 +591,7 @@ if(!class_exists('FlycartWooDiscountRules')){
588
  'show_product_strikeout' => $this->discountBase->getConfigData('show_price_discount_on_product_page', 'show'),
589
  'product_price_container_class' => apply_filters('woo_discount_rules_product_price_container_class', ''),
590
  ));
591
- wp_enqueue_script( 'woo_discount_rules_site_v1');
592
  }
593
 
594
  /**
18
  /**
19
  * Version of Woo Discount Rules.
20
  */
21
+ $pluginDetails = get_plugin_data(WDR_PLUGIN_BASE_PATH.'woo-discount-rules.php');
22
  define('WOO_DISCOUNT_VERSION', $pluginDetails['Version']);
23
 
24
  if(!class_exists('FlycartWooDiscountRules')){
48
  $this->hasWPML();
49
  $this->includeFiles();
50
  $this->discountBase = new FlycartWooDiscountBase();
51
+ //$this->runUpdater();
52
+ $purchase_helper = new FlycartWooDiscountRulesPurchase();
53
+ $purchase_helper->init();
54
+ add_action('wp_ajax_forceValidateLicenseKey', array($purchase_helper, 'forceValidateLicenseKey'));
55
  $this->pricingRules = new FlycartWooDiscountRulesPricingRules();
56
  if (is_admin()) {
57
  $this->loadAdminScripts();
106
  }
107
  $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
108
  $update_url,
109
+ WDR_PLUGIN_BASE_PATH.'woo-discount-rules.php',
110
  'woo-discount-rules'
111
  );
112
  add_action( 'after_plugin_row', array($purchase_helper, 'woodisc_after_plugin_row'),10,3 );
583
  wp_register_style('woo_discount_rules_front_end', WOO_DISCOUNT_URI . '/assets/css/woo_discount_rules.css', array(), WOO_DISCOUNT_VERSION);
584
  wp_enqueue_style('woo_discount_rules_front_end');
585
  // Enqueued script with localized data.
586
+ wp_register_script('woo_discount_rules_site_v1', WOO_DISCOUNT_URI . '/assets/js/woo_discount_rules.js', array('jquery'), WOO_DISCOUNT_VERSION, true);
587
  wp_localize_script('woo_discount_rules_site_v1', 'woo_discount_rules', array(
588
  'home_url' => get_home_url(),
589
  'admin_url' => admin_url(),
591
  'show_product_strikeout' => $this->discountBase->getConfigData('show_price_discount_on_product_page', 'show'),
592
  'product_price_container_class' => apply_filters('woo_discount_rules_product_price_container_class', ''),
593
  ));
594
+ wp_enqueue_script('woo_discount_rules_site_v1');
595
  }
596
 
597
  /**
{vendor → v1/vendor}/askupa-software/wp-admin-notification/LICENSE RENAMED
File without changes
{vendor → v1/vendor}/askupa-software/wp-admin-notification/README.md RENAMED
File without changes
{vendor → v1/vendor}/askupa-software/wp-admin-notification/bootstrap.php RENAMED
File without changes
{vendor → v1/vendor}/askupa-software/wp-admin-notification/composer.json RENAMED
File without changes
{vendor → v1/vendor}/askupa-software/wp-admin-notification/handler.php RENAMED
File without changes
{vendor → v1/vendor}/autoload.php RENAMED
File without changes
{vendor → v1/vendor}/composer/ClassLoader.php RENAMED
File without changes
{vendor → v1/vendor}/composer/LICENSE RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_classmap.php RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_files.php RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_namespaces.php RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_psr4.php RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_real.php RENAMED
File without changes
{vendor → v1/vendor}/composer/autoload_static.php RENAMED
File without changes
{vendor → v1/vendor}/composer/installed.json RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/composer.json RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/src/FFilterInput.php RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/src/FInput.php RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/src/InputFilter.php RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/src/ReadMe.md RENAMED
File without changes
{vendor → v1/vendor}/flycartinc/inputhelper/src/StringHelper.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/.editorconfig RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Autoloader.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Extension.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Panel.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginExtension.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginPanel.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/ThemePanel.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Factory.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/InstalledPackage.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Metadata.php RENAMED
@@ -39,7 +39,10 @@ if ( !class_exists('Puc_v4p7_Metadata', false) ):
39
  $valid = $target->validateMetadata($apiResponse);
40
  if ( is_wp_error($valid) ){
41
  do_action('puc_api_error', $valid);
42
- trigger_error($valid->get_error_message(), E_USER_NOTICE);
 
 
 
43
  return false;
44
  }
45
 
39
  $valid = $target->validateMetadata($apiResponse);
40
  if ( is_wp_error($valid) ){
41
  do_action('puc_api_error', $valid);
42
+ /**
43
+ * Commented Added by FLYCART as it throws warning while there is no response from server or return empty value
44
+ * */
45
+ //trigger_error($valid->get_error_message(), E_USER_NOTICE);
46
  return false;
47
  }
48
 
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/OAuthSignature.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Info.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Package.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Update.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/UpdateChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Scheduler.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/StateStore.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Package.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Update.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/UpdateChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Update.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpdateChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpgraderStatus.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Utils.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Api.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BaseChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BitBucketApi.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitHubApi.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitLabApi.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/PluginUpdateChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Reference.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/ThemeUpdateChecker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/README.md RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/composer.json RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/examples/plugin.json RENAMED
@@ -1,52 +1,52 @@
1
- {
2
- "name": "My Example Plugin",
3
- "version": "2.0",
4
- "download_url": "http://example.com/updates/example-plugin.zip",
5
-
6
- "homepage": "http://example.com/",
7
- "requires": "4.5",
8
- "tested": "4.8",
9
- "last_updated": "2017-01-01 16:17:00",
10
- "upgrade_notice": "Here's why you should upgrade...",
11
-
12
- "author": "Janis Elsts",
13
- "author_homepage": "http://example.com/",
14
-
15
- "sections": {
16
- "description": "(Required) Plugin description. Basic HTML can be used in all sections.",
17
- "installation": "(Recommended) Installation instructions.",
18
- "changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
19
- "custom_section": "This is a custom section labeled 'Custom Section'."
20
- },
21
-
22
- "icons" : {
23
- "1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png",
24
- "2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png"
25
- },
26
-
27
- "banners": {
28
- "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
29
- "high": "http://w-shadow.com/files/external-update-example/assets/banner-1544x500.png"
30
- },
31
-
32
- "translations": [
33
- {
34
- "language": "fr_FR",
35
- "version": "4.0",
36
- "updated": "2016-04-22 23:22:42",
37
- "package": "http://example.com/updates/translations/french-language-pack.zip"
38
- },
39
- {
40
- "language": "de_DE",
41
- "version": "5.0",
42
- "updated": "2016-04-22 23:22:42",
43
- "package": "http://example.com/updates/translations/german-language-pack.zip"
44
- }
45
- ],
46
-
47
- "rating": 90,
48
- "num_ratings": 123,
49
-
50
- "downloaded": 1234,
51
- "active_installs": 12345
52
  }
1
+ {
2
+ "name": "My Example Plugin",
3
+ "version": "2.0",
4
+ "download_url": "http://example.com/updates/example-plugin.zip",
5
+
6
+ "homepage": "http://example.com/",
7
+ "requires": "4.5",
8
+ "tested": "4.8",
9
+ "last_updated": "2017-01-01 16:17:00",
10
+ "upgrade_notice": "Here's why you should upgrade...",
11
+
12
+ "author": "Janis Elsts",
13
+ "author_homepage": "http://example.com/",
14
+
15
+ "sections": {
16
+ "description": "(Required) Plugin description. Basic HTML can be used in all sections.",
17
+ "installation": "(Recommended) Installation instructions.",
18
+ "changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
19
+ "custom_section": "This is a custom section labeled 'Custom Section'."
20
+ },
21
+
22
+ "icons" : {
23
+ "1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png",
24
+ "2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png"
25
+ },
26
+
27
+ "banners": {
28
+ "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
29
+ "high": "http://w-shadow.com/files/external-update-example/assets/banner-1544x500.png"
30
+ },
31
+
32
+ "translations": [
33
+ {
34
+ "language": "fr_FR",
35
+ "version": "4.0",
36
+ "updated": "2016-04-22 23:22:42",
37
+ "package": "http://example.com/updates/translations/french-language-pack.zip"
38
+ },
39
+ {
40
+ "language": "de_DE",
41
+ "version": "5.0",
42
+ "updated": "2016-04-22 23:22:42",
43
+ "package": "http://example.com/updates/translations/german-language-pack.zip"
44
+ }
45
+ ],
46
+
47
+ "rating": 90,
48
+ "num_ratings": 123,
49
+
50
+ "downloaded": 1234,
51
+ "active_installs": 12345
52
  }
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/examples/theme.json RENAMED
@@ -1,5 +1,5 @@
1
- {
2
- "version": "2.0",
3
- "details_url": "http://example.com/version-2.0-details.html",
4
- "download_url": "http://example.com/example-theme-2.0.zip"
5
  }
1
+ {
2
+ "version": "2.0",
3
+ "details_url": "http://example.com/version-2.0-details.html",
4
+ "download_url": "http://example.com/example-theme-2.0.zip"
5
  }
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/js/debug-bar.js RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-de_DE.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-de_DE.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fa_IR.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fa_IR.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-hu_HU.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-hu_HU.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-it_IT.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-it_IT.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.po RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/license.txt RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/plugin-update-checker.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/Parsedown.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/ParsedownLegacy.php RENAMED
File without changes
{vendor → v1/vendor}/yahnis-elsts/plugin-update-checker/vendor/readme-parser.php RENAMED
File without changes
{view → v1/view}/cart-rules.php RENAMED
File without changes
{view → v1/view}/documentation.php RENAMED
File without changes
{view → v1/view}/includes/cart-menu.php RENAMED
File without changes
{view → v1/view}/includes/footer.php RENAMED
File without changes
{view → v1/view}/includes/header.php RENAMED
File without changes
{view → v1/view}/includes/menu.php RENAMED
@@ -4,6 +4,11 @@ $proText = $purchase->getProText();
4
  $isPro = $purchase->isPro();
5
  ?>
6
  <i><h2><?php esc_html_e('Woo Discount Rules', 'woo-discount-rules'); ?> <?php echo $proText; ?> <span class="woo-discount-version">v<?php echo WOO_DISCOUNT_VERSION; ?></span></h2></i><hr>
 
 
 
 
 
7
  <h3 class="nav-tab-wrapper">
8
  <a class="nav-tab <?php if ($active == 'pricing-rules') { echo 'nav-tab-active'; } ?>" href="?page=woo_discount_rules&amp;tab=pricing-rules">
9
  <?php esc_html_e('Price Discount Rules', 'woo-discount-rules'); ?> </a>
4
  $isPro = $purchase->isPro();
5
  ?>
6
  <i><h2><?php esc_html_e('Woo Discount Rules', 'woo-discount-rules'); ?> <?php echo $proText; ?> <span class="woo-discount-version">v<?php echo WOO_DISCOUNT_VERSION; ?></span></h2></i><hr>
7
+ <div class="wdr_woo_discount_header_con updated woocommerce-message">
8
+ <?php
9
+ do_action('advanced_woo_discount_rules_on_settings_head');
10
+ ?>
11
+ </div>
12
  <h3 class="nav-tab-wrapper">
13
  <a class="nav-tab <?php if ($active == 'pricing-rules') { echo 'nav-tab-active'; } ?>" href="?page=woo_discount_rules&amp;tab=pricing-rules">
14
  <?php esc_html_e('Price Discount Rules', 'woo-discount-rules'); ?> </a>
{view → v1/view}/includes/sub-menu.php RENAMED
File without changes
{view → v1/view}/pricing-rules.php RENAMED
File without changes
{view → v1/view}/settings.php RENAMED
File without changes
{view → v1/view}/settings_cart_rules.php RENAMED
File without changes
{view → v1/view}/settings_general.php RENAMED
File without changes
{view → v1/view}/settings_performance.php RENAMED
File without changes
{view → v1/view}/settings_price_rules.php RENAMED
File without changes
{view → v1/view}/settings_promotion.php RENAMED
File without changes
{view → v1/view}/settings_taxonomy.php RENAMED
File without changes
{view → v1/view}/template/discount-table-advance.php RENAMED
File without changes
{view → v1/view}/template/discount-table.php RENAMED
File without changes
{view → v1/view}/template/loop/sale-flash.php RENAMED
File without changes
{view → v1/view}/template/sidebar.php RENAMED
File without changes
{view → v1/view}/template/single-product/sale-flash.php RENAMED
File without changes
{view → v1/view}/template/total-savings-cart.php RENAMED
File without changes
{view → v1/view}/template/total-savings-order.php RENAMED
File without changes
{view → v1/view}/view-cart-rules.php RENAMED
File without changes
{view → v1/view}/view-pricing-rules.php RENAMED
File without changes
v2/App/Compatibility/Base.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Compatibility;
3
+
4
+ use Wdr\App\Controllers\Admin\Tabs\Compatible;
5
+
6
+ if (!defined('ABSPATH')) exit;
7
+
8
+ class Base
9
+ {
10
+ protected $config;
11
+ public function __construct()
12
+ {
13
+ $this->config = Compatible::getInstance();
14
+ }
15
+ }
v2/App/Compatibility/CompositeProductsBySomewhereWarm.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class CompositeProductsBySomewhereWarm extends Base
8
+ {
9
+ protected $key = 'compatible_cp_somewherewarm';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_filter('advanced_woo_discount_rules_calculate_discount_for_cart_item', function($calculate_discount, $cart_item){
18
+ if(isset($cart_item['composite_item']) && !empty($cart_item['composite_item'])){
19
+ $calculate_discount = false;
20
+ }
21
+ return $calculate_discount;
22
+ }, 10, 2);
23
+
24
+ add_filter('advanced_woo_discount_rules_include_cart_item_to_count_quantity', function($take_count, $cart_item){
25
+ if(isset($cart_item['composite_item']) && !empty($cart_item['composite_item'])){
26
+ $take_count = false;
27
+ }
28
+ return $take_count;
29
+ }, 10, 2);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * load fields
35
+ * */
36
+ public function loadFields(&$available){
37
+ $value = $this->config->getConfigData($this->key, 0);
38
+ if ( is_plugin_active( 'woocommerce-composite-products/woocommerce-composite-products.php' ) || ($value == 1)) {
39
+ $available = true;
40
+ ?>
41
+ <div class="awdr-compatible-field">
42
+ <label>
43
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
44
+ <?php esc_html_e('Add compatible for WooCommerce Composite Products', WDR_TEXT_DOMAIN); ?>
45
+ </label>
46
+ <br>
47
+ <span class="wdr_desc_text awdr-clear-both"><?php esc_html_e('Limitation: Product page strikeout. We suggest to disable strikeout on product page.', WDR_TEXT_DOMAIN); ?></span>
48
+ </div>
49
+ <?php
50
+ }
51
+ }
52
+ }
v2/App/Compatibility/CurrencySwitcherByRealmag777.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class CurrencySwitcherByRealmag777 extends Base
8
+ {
9
+ protected $key = 'compatible_wcs_realmag777';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_filter('advanced_woo_discount_rules_discounted_price_of_cart_item', function($price, $cart_item, $cart_object, $discount_prices){
18
+ if(!empty($discount_prices) && isset($discount_prices['discounted_price'])){
19
+ global $WOOCS;
20
+ if(isset($WOOCS)){
21
+ if (method_exists($WOOCS, 'get_currencies')){
22
+ $currencies = $WOOCS->get_currencies();
23
+ $convert_to_current_currency = false;
24
+ if(isset($WOOCS->is_geoip_manipulation) && $WOOCS->is_geoip_manipulation){
25
+ $convert_to_current_currency = true;
26
+ }
27
+ if(isset($WOOCS->is_multiple_allowed) && $WOOCS->is_multiple_allowed){
28
+ $convert_to_current_currency = true;
29
+ }
30
+ if(isset($WOOCS->woocs_is_fixed_enabled) && $WOOCS->woocs_is_fixed_enabled){
31
+ $convert_to_current_currency = true;
32
+ }
33
+ if($convert_to_current_currency === true){
34
+ if(isset($currencies[$WOOCS->current_currency]) && isset($currencies[$WOOCS->current_currency]['rate'])){
35
+ $price = $price / $currencies[$WOOCS->current_currency]['rate'];
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ return $price;
43
+ }, 10, 4);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * load fields
49
+ * */
50
+ public function loadFields(&$available){
51
+ $value = $this->config->getConfigData($this->key, 0);
52
+ if ( is_plugin_active( 'woocommerce-currency-switcher/index.php' ) || ($value == 1)) {
53
+ $available = true;
54
+ ?>
55
+ <div class="awdr-compatible-field">
56
+ <label>
57
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
58
+ <?php esc_html_e('Add compatible for WooCommerce Currency Switcher', WDR_TEXT_DOMAIN); ?>
59
+ </label>
60
+ </div>
61
+ <?php
62
+ }
63
+ }
64
+ }
v2/App/Compatibility/CurrencySwitcherByVillatheme.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class CurrencySwitcherByVillatheme extends Base
8
+ {
9
+ protected $key = 'compatible_cs_villatheme';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_filter('advanced_woo_discount_rules_discounted_price_of_cart_item', function($price, $cart_item, $cart_object, $discount_prices){
18
+ $process_conversion = true;
19
+ if($process_conversion){
20
+ $class_exists = false;
21
+ if(class_exists('WOOMULTI_CURRENCY_F_Data')){
22
+ $setting = new WOOMULTI_CURRENCY_F_Data();
23
+ $class_exists = true;
24
+ } elseif(class_exists('WOOMULTI_CURRENCY_Data')){
25
+ $setting = new WOOMULTI_CURRENCY_Data();
26
+ $class_exists = true;
27
+ }
28
+ if($class_exists === true){
29
+ $selected_currencies = $setting->get_list_currencies();
30
+ $current_currency = $setting->get_current_currency();
31
+ if ( ! $current_currency ) {
32
+ return $price;
33
+ }
34
+ if ( $price ) {
35
+ $price = $price / $selected_currencies[ $current_currency ]['rate'];
36
+ }
37
+ }
38
+ }
39
+
40
+ return $price;
41
+ }, 10, 4);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * load fields
47
+ * */
48
+ public function loadFields(&$available){
49
+ $value = $this->config->getConfigData($this->key, 0);
50
+ if ( is_plugin_active( 'woocommerce-multi-currency/woocommerce-multi-currency.php' ) || ($value == 1)) {
51
+ $available = true;
52
+ ?>
53
+ <div class="awdr-compatible-field">
54
+ <label>
55
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
56
+ <?php esc_html_e('Add compatible for WooCommerce Currency Switcher', WDR_TEXT_DOMAIN); ?>
57
+ </label>
58
+ </div>
59
+ <?php
60
+ }
61
+ }
62
+ }
v2/App/Compatibility/CurrencySwitcherByWPWham.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class CurrencySwitcherByWPWham extends Base
8
+ {
9
+ protected $key = 'compatible_wcs_wpwham';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_filter('advanced_woo_discount_rules_discounted_price_of_cart_item', function($price, $cart_item, $cart_object, $discount_prices){
18
+ if(!empty($discount_prices) && isset($discount_prices['discounted_price'])){
19
+ //Alg_WC_Currency_Switcher compatible
20
+ if (class_exists( 'Alg_WC_Currency_Switcher' ) ) {
21
+ if(function_exists('alg_wc_cs_get_currency_exchange_rate') && function_exists('alg_get_current_currency_code')){
22
+ $alg_wc_cs = alg_wc_cs_get_currency_exchange_rate(alg_get_current_currency_code());
23
+ $price = $price / $alg_wc_cs;
24
+ }
25
+ }
26
+ }
27
+
28
+ return $price;
29
+ }, 10, 4);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * load fields
35
+ * */
36
+ public function loadFields(&$available){
37
+ $value = $this->config->getConfigData($this->key, 0);
38
+ if ( is_plugin_active( 'currency-switcher-woocommerce/currency-switcher-woocommerce.php' ) || ($value == 1)) {
39
+ $available = true;
40
+ ?>
41
+ <div class="awdr-compatible-field">
42
+ <label>
43
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
44
+ <?php esc_html_e('Add compatible for WooCommerce Currency Switcher', WDR_TEXT_DOMAIN); ?>
45
+ </label>
46
+ </div>
47
+ <?php
48
+ }
49
+ }
50
+ }
v2/App/Compatibility/ExtraProductOptionsProByThemeHigh.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class ExtraProductOptionsProByThemeHigh extends Base
8
+ {
9
+ protected $key = 'compatible_epop_themehigh';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_filter('thwepo_product_price_html', function($price_html, $product_id){
18
+ if(is_ajax()){
19
+ $price = trim(strip_tags($price_html));
20
+ $replace_strings = array('&#36;', '&nbsp;');
21
+ if(function_exists('wc_get_product')){
22
+ $product = wc_get_product($product_id);
23
+ $original_price = $product->get_price();
24
+ $prices = explode('&nbsp;', $price);
25
+ $price = str_replace($replace_strings, '', $prices[0]);
26
+ $price = (float)$price;
27
+ if($original_price != $price){
28
+ $result = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, 1, $price);
29
+ if($result !== false){
30
+ $price_html = "<del>".$price_html."</del><ins>".wc_price($result)."</ins>";
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ return $price_html;
37
+ }, 10, 2);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * load fields
43
+ * */
44
+ public function loadFields(&$available){
45
+ $value = $this->config->getConfigData($this->key, 0);
46
+ if ( is_plugin_active( 'woocommerce-extra-product-options-pro/woocommerce-extra-product-options-pro.php' ) || ($value == 1)) {
47
+ $available = true;
48
+ ?>
49
+ <div class="awdr-compatible-field">
50
+ <label>
51
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
52
+ <?php esc_html_e('Add compatible for WooCommerce Extra Product Options', WDR_TEXT_DOMAIN); ?>
53
+ </label>
54
+ <br>
55
+ <span class="wdr_desc_text awdr-clear-both"><?php esc_html_e('Limitation: Strikeout for add-on price and subtotal in product page.', WDR_TEXT_DOMAIN); ?></span>
56
+ </div>
57
+ <?php
58
+ }
59
+ }
60
+ }
v2/App/Compatibility/ProductAddOnsByWooCommerce.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class ProductAddOnsByWooCommerce extends Base
8
+ {
9
+ protected $key = 'compatible_woocommerce_product_addon';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ add_action( 'wp_head', function () { ?>
18
+ <script type="application/javascript">
19
+ (function ($) {
20
+ $(document).ready(function ($) {
21
+ var currency_string = '$';
22
+ var $form = jQuery('form.cart').first();
23
+ /**
24
+ * Strikeout for option title
25
+ * */
26
+ $('.product-addon .amount').each(function(){
27
+ var $targets = $(this);
28
+ $lock = $targets.attr('data-lock');
29
+ if($lock === undefined || $lock === null){
30
+ $lock = false;
31
+ }
32
+ if($lock == false){
33
+ var price = newText = $(this).text().replace(currency_string, '');
34
+ var option = {
35
+ custom_price: price,
36
+ original_price: price
37
+ };
38
+ $targets.attr('data-lock', true);
39
+ $.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option);
40
+ }
41
+ });
42
+
43
+ $(document.body).on( "advanced_woo_discount_rules_on_get_response_for_dynamic_discount", function ( e, response, target, options ) {
44
+ if(response.success == true){
45
+ var price_html = ''
46
+ if(response.data !== undefined){
47
+ price_html += '<del>'+response.data.initial_price_html+'</del>';
48
+ price_html += ' <ins>'+response.data.discounted_price_html+'</ins>';
49
+ target.html(price_html);
50
+ }
51
+ }
52
+ target.attr('data-lock', false);
53
+ });
54
+
55
+ /**
56
+ * Strikeout for option values and subtotal
57
+ * */
58
+ $form.on('updated_addons', function () {
59
+ setTimeout(function () {
60
+ $('.product-addon-totals .amount').each(function(){
61
+ var $targets = $(this);
62
+ $lock = $targets.attr('data-lock');
63
+ if($lock === undefined || $lock === null){
64
+ $lock = false;
65
+ }
66
+ if($lock == false){
67
+ var price = newText = $(this).text().replace(currency_string, '');
68
+ var option = {
69
+ custom_price: price,
70
+ original_price: price
71
+ };
72
+ $targets.attr('data-lock', true);
73
+ $.AdvanceWooDiscountRules.getDynamicDiscountPriceFromCartForm($form, $targets, option);
74
+ }
75
+ });
76
+ }, 0);
77
+ });
78
+ });
79
+
80
+ })(jQuery);
81
+ </script>
82
+ <?php } );
83
+ }
84
+ }
85
+
86
+ /**
87
+ * load fields
88
+ * */
89
+ public function loadFields(&$available){
90
+ $value = $this->config->getConfigData($this->key, 0);
91
+ if ( is_plugin_active( 'woocommerce-product-addons/woocommerce-product-addons.php' ) || ($value == 1)) {
92
+ $available = true;
93
+ ?>
94
+ <div class="awdr-compatible-field">
95
+ <label>
96
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
97
+ <?php esc_html_e('Add compatible for WooCommerce Product Add Ons', WDR_TEXT_DOMAIN); ?>
98
+ </label>
99
+ </div>
100
+ <?php
101
+ }
102
+ }
103
+ }
v2/App/Compatibility/WholesalePricesByRymeraWebCo.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Compatibility;
4
+
5
+ if (!defined('ABSPATH')) exit;
6
+
7
+ class WholesalePricesByRymeraWebCo extends Base
8
+ {
9
+ protected $key = 'compatible_wsp_rymera';
10
+
11
+ /**
12
+ * Do compatibility script
13
+ * */
14
+ public function run(){
15
+ $value = $this->config->getConfigData($this->key, 0);
16
+ if($value){
17
+ global $wdr_comp_disable_strikeout;
18
+ add_filter('wwp_filter_wholesale_price_html', function($wholesale_price_html , $price , $product , $user_wholesale_role , $wholesale_price_title_text , $raw_wholesale_price , $source){
19
+ global $wdr_comp_disable_strikeout;
20
+ $wdr_comp_disable_strikeout[$product->get_id()] = true;
21
+ $result = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, 1, $raw_wholesale_price);
22
+ if($result !== false){
23
+ /*To remove the original price strikeout un-comment the next line */
24
+ /*$wholesale_price_html = preg_replace('/<del.*<\/del>/', '', $wholesale_price_html);*/
25
+ $wholesale_price_html = "<del>".$wholesale_price_html."</del><ins>".$wholesale_price_title_text.' '.wc_price($result)."</ins>";
26
+ }
27
+ return $wholesale_price_html;
28
+ }, 10, 7);
29
+
30
+ add_filter('advanced_woo_discount_rules_modify_price_html', function($enable, $price_html, $product, $quantity){
31
+ global $wdr_comp_disable_strikeout;
32
+ if(isset($wdr_comp_disable_strikeout[$product->get_id()]) && $wdr_comp_disable_strikeout[$product->get_id()] == true){
33
+ $enable = false;
34
+ }
35
+ return $enable;
36
+ }, 10, 4);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * load fields
42
+ * */
43
+ public function loadFields(&$available){
44
+ $value = $this->config->getConfigData($this->key, 0);
45
+ if ( is_plugin_active( 'woocommerce-wholesale-prices/woocommerce-wholesale-prices.bootstrap.php' ) || is_plugin_active( 'woocommerce-wholesale-prices-premium/woocommerce-wholesale-prices-premium.bootstrap.php' ) || ($value == 1)) {
46
+ $available = true;
47
+ ?>
48
+ <div class="awdr-compatible-field">
49
+ <label>
50
+ <input type="checkbox" name="wdrc[<?php echo $this->key; ?>]" id="<?php echo $this->key; ?>" value="1" <?php if ($value == 1) { ?> checked <?php } ?>>
51
+ <?php esc_html_e('Add compatible for WooCommerce Wholesale Prices', WDR_TEXT_DOMAIN); ?>
52
+ </label>
53
+ </div>
54
+ <?php
55
+ }
56
+ }
57
+ }
v2/App/Conditions/Base.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Conditions;
4
+
5
+ use Wdr\App\Helpers\Filter;
6
+ use Wdr\App\Helpers\Helper;
7
+ use Wdr\App\Helpers\Input;
8
+ use Wdr\App\Helpers\Woocommerce;
9
+
10
+ if (!defined('ABSPATH')) exit;
11
+
12
+ abstract class Base
13
+ {
14
+ public static $woocommerce_helper, $filter;
15
+ public $name = NULL, $rule = null, $label = NULL, $group = NULL, $template = NULL, $input, $extra_params = array('render_saved_condition' => false);
16
+
17
+ function __construct()
18
+ {
19
+ self::$woocommerce_helper = (!empty(self::$woocommerce_helper)) ? self::$woocommerce_helper : new Woocommerce();
20
+ self::$filter = (!empty(self::$filter)) ? self::$filter : new Filter();
21
+ $this->input = new Input();
22
+ }
23
+
24
+ abstract function check($cart, $options);
25
+
26
+ /**
27
+ * return the name of the condition. If condition does not have name, then the condition will not get consider.
28
+ * @return null
29
+ */
30
+ function name()
31
+ {
32
+ return $this->name;
33
+ }
34
+
35
+ /**
36
+ * compare cart items with the product filter helper
37
+ * @param $cart
38
+ * @param $options
39
+ * @param $type
40
+ * @return bool
41
+ */
42
+ function doCartItemsCheck($cart, $options, $type)
43
+ {
44
+ if(empty($cart)){
45
+ return false;
46
+ }
47
+ $comparision_operator = isset($options->cartqty) ? $options->cartqty : 'less_than_or_equal';
48
+ $comparision_quantity = isset($options->qty) ? $options->qty : 0;
49
+ if (empty($comparision_quantity)) {
50
+ return true;
51
+ }
52
+ // $comparision_method = isset($options->method) ? $options->method : 'in_list';
53
+ $comparision_method = isset($options->operator) ? $options->operator : 'in_list';
54
+ $comparision_value = (array)isset($options->value) ? $options->value : array();
55
+ $cart_items = array();
56
+ if ($cart instanceof \WC_Cart) {
57
+ $cart_items = self::$woocommerce_helper->getCartItems($cart);
58
+ } elseif (is_array($cart)) {
59
+ $cart_items = $cart;
60
+ }
61
+ $quantity = 0;
62
+
63
+ foreach ($cart_items as $cart_item) {
64
+ $product = isset($cart_item['data']) ? $cart_item['data'] : array();
65
+ if(Helper::isCartItemConsideredForCalculation(true, $cart_item, $type)){
66
+ if (self::$filter->match($product, $type, $comparision_method, $comparision_value, $options)) {
67
+ if ($type != 'products') {
68
+ $quantity += (int)$cart_item['quantity'];
69
+ }
70
+ }
71
+ }
72
+ }
73
+ foreach ($cart_items as $item) {
74
+ $product = isset($item['data']) ? $item['data'] : array();
75
+ if(Helper::isCartItemConsideredForCalculation(true, $item, $type)){
76
+ if (self::$filter->match($product, $type, $comparision_method, $comparision_value, $options)) {
77
+ if($type == 'products'){
78
+ $quantity = 0;
79
+ $quantity = (int)$item['quantity'];
80
+ $product_parant_id = Woocommerce::getProductParentId($product);
81
+ if(!empty($product_parant_id)){
82
+ $quantity = $this->getChildVariantCountInCart($options, $product_parant_id, $quantity, $cart_items);
83
+ }
84
+ }
85
+ switch ($comparision_operator) {
86
+ case 'less_than':
87
+ if ($quantity < $comparision_quantity) {
88
+ return true;
89
+ }
90
+ break;
91
+ case 'greater_than_or_equal':
92
+ if ($quantity >= $comparision_quantity) {
93
+ return true;
94
+ }
95
+ break;
96
+ case 'greater_than':
97
+ if ($quantity > $comparision_quantity) {
98
+ return true;
99
+ }
100
+ break;
101
+ default:
102
+ case 'less_than_or_equal':
103
+ if ($quantity <= $comparision_quantity) {
104
+ return true;
105
+ }
106
+ break;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ return false;
112
+ }
113
+
114
+ /**
115
+ * get the date by passing days
116
+ * @param $value string; Example- +1 day,-1 month, now
117
+ * @param $format string
118
+ * @return bool|string
119
+ */
120
+ function getDateByString($value, $format = 'Y-m-d H:i:s')
121
+ {
122
+ if (!empty($value)) {
123
+ $value = str_replace('_', ' ', $value);
124
+ try {
125
+ $date = new \DateTime(current_time('mysql'));
126
+ $date->modify($value);
127
+ return $date->format($format);
128
+ } catch (\Exception $e) {
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+
134
+ /**
135
+ * Do the mathematical Comparision operation
136
+ * @param $operation
137
+ * @param $operand1 - user data
138
+ * @param $operand2 - admin condition data 1
139
+ * @param $operand3 - admin condition data 2, if range
140
+ * @return bool
141
+ */
142
+ function doComparisionOperation($operation, $operand1, $operand2, $operand3 = NULL)
143
+ {
144
+ $result = false;
145
+ switch ($operation) {
146
+ case 'equal_to':
147
+ $result = ($operand1 == $operand2);
148
+ break;
149
+ case 'not_equal_to';
150
+ $result = ($operand1 != $operand2);
151
+ break;
152
+ case 'greater_than';
153
+ $result = ($operand1 > $operand2);
154
+ break;
155
+ case 'less_than';
156
+ $result = ($operand1 < $operand2);
157
+ break;
158
+ case 'greater_than_or_equal';
159
+ $result = ($operand1 >= $operand2);
160
+ break;
161
+ case 'less_than_or_equal';
162
+ $result = ($operand1 <= $operand2);
163
+ break;
164
+ case 'in_range';
165
+ if (!empty($operand3)) {
166
+ $result = (($operand1 >= $operand2) && ($operand1 <= $operand3));
167
+ }
168
+ break;
169
+ default:
170
+ break;
171
+ }
172
+ return $result;
173
+ }
174
+
175
+ /**
176
+ * check the data is present in loop
177
+ * @param $operation
178
+ * @param $key
179
+ * @param $list
180
+ * @return bool
181
+ */
182
+ function doCompareInListOperation($operation, $key, $list)
183
+ {
184
+ if (!is_array($list))
185
+ return false;
186
+ switch ($operation) {
187
+ case 'not_in_list':
188
+ if (is_array($key) || is_object($key)) {
189
+ $key = (array)$key;
190
+ return !array_intersect($key, $list);
191
+ } else {
192
+ $result = !in_array($key, $list);
193
+ }
194
+ break;
195
+ default:
196
+ case 'in_list';
197
+ if (is_array($key) || is_object($key)) {
198
+ $key = (array)$key;
199
+ return array_intersect($key, $list);
200
+ } else {
201
+ $result = in_array($key, $list);
202
+ }
203
+ break;
204
+ }
205
+ return $result;
206
+ }
207
+
208
+ /**
209
+ * @param $options
210
+ * @param $parant_id
211
+ * @param $quantity
212
+ * @param $cart_items
213
+ * @return int
214
+ */
215
+ function getChildVariantCountInCart($options, $parant_id, $quantity, $cart_items){
216
+ $filter_value = (is_object($options) && isset($options->value)) ? $options->value : 0;
217
+ if(in_array($parant_id,$filter_value)){
218
+ $count_quantity = 0;
219
+ foreach ($cart_items as $cart_item){
220
+ $product = isset($cart_item['data']) ? $cart_item['data'] : 0;
221
+ $product_parant_id = Woocommerce::getProductParentId($product);
222
+ if($parant_id == $product_parant_id){
223
+ $count_quantity += (int)$cart_item['quantity'];
224
+ }
225
+ }
226
+ return $count_quantity;
227
+ }else{
228
+ return $quantity;
229
+ }
230
+ }
231
+ }
v2/App/Conditions/CartLineItemsCount.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Conditions;
4
+
5
+ use Wdr\App\Controllers\DiscountCalculator;
6
+
7
+ if (!defined('ABSPATH')) exit;
8
+
9
+ class CartLineItemsCount extends Base
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->name = 'cart_line_items_count';
15
+ $this->label = __('Line Item Count', WDR_TEXT_DOMAIN);
16
+ $this->group = __('Cart', WDR_TEXT_DOMAIN);
17
+ $this->template = WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php';
18
+ }
19
+
20
+ function check($cart, $options)
21
+ {
22
+ if(empty($cart)){
23
+ return false;
24
+ }
25
+ if (isset($options->operator) && $options->value) {
26
+ $operator = sanitize_text_field($options->operator);
27
+ $value = sanitize_key($options->value);
28
+ if($options->calculate_from == 'from_filter'){
29
+ $line_items = DiscountCalculator::getFilterBasedCartQuantities('cart_line_items_count', $this->rule);
30
+ }else{
31
+ $line_items = (is_array($cart)) ? count($cart) : 0;
32
+ }
33
+ return $this->doComparisionOperation($operator, $line_items, $value);
34
+ }
35
+ return false;
36
+ }
37
+ }
v2/App/Conditions/CartSubTotal.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Conditions;
4
+
5
+ use Wdr\App\Controllers\DiscountCalculator;
6
+ use Wdr\App\Helpers\Woocommerce;
7
+
8
+ if (!defined('ABSPATH')) exit;
9
+
10
+ class CartSubTotal extends Base
11
+ {
12
+ function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->name = 'cart_subtotal';
16
+ $this->label = __('Subtotal', WDR_TEXT_DOMAIN);
17
+ $this->group = __('Cart', WDR_TEXT_DOMAIN);
18
+ $this->template = WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Conditions/Cart/Subtotal.php';
19
+ }
20
+
21
+ public function check($cart, $options)
22
+ {
23
+ if(empty($cart)){
24
+ return false;
25
+ }
26
+ $sub_total_recalculate = false;
27
+ $cart_sub_total = 0;
28
+ if($options->calculate_from == 'from_filter'){
29
+ $cart_sub_total = DiscountCalculator::getFilterBasedCartQuantities('cart_subtotal', $this->rule);
30
+ $cart_sub_total = Woocommerce::round($cart_sub_total);
31
+ }else{
32
+ if(apply_filters('advanced_woo_discount_rules_calculate_cart_subtotal_manually', false)){
33
+ $cart = Woocommerce::getCart(true);
34
+ } else {
35
+ $cart_sub_total = self::$woocommerce_helper->getCartSubtotal();
36
+ }
37
+ $sub_total_recalculate = true;
38
+ }
39
+ if(!empty($cart) && $cart_sub_total == 0 && $sub_total_recalculate){
40
+ foreach ($cart as $cart_product){
41
+ $cart_sub_total += self::$woocommerce_helper->getCartLineItemSubtotal($cart_product);
42
+ }
43
+ $cart_sub_total = Woocommerce::round($cart_sub_total);
44
+ }
45
+ if (isset($options->operator) && $options->value) {
46
+ $operator = sanitize_text_field($options->operator);
47
+ $value = sanitize_key($options->value);
48
+ return $this->doComparisionOperation($operator, $cart_sub_total, $value);
49
+ }
50
+
51
+ return false;
52
+ }
53
+ }
v2/App/Controllers/Admin/Settings.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers\Admin;
4
+
5
+ use Wdr\App\Controllers\Admin\Tabs\Compatible;
6
+ use Wdr\App\Controllers\Admin\Tabs\DiscountRules;
7
+ use Wdr\App\Controllers\Admin\Tabs\Help;
8
+ use Wdr\App\Controllers\Admin\Tabs\GeneralSettings;
9
+ use Wdr\App\Controllers\Admin\Tabs\ImportExport;
10
+ use Wdr\App\Controllers\Admin\Tabs\Statistics;
11
+ use Wdr\App\Controllers\Base;
12
+ use Wdr\App\Controllers\OnSaleShortCode;
13
+ use Wdr\App\Helpers\Language;
14
+ use Wdr\App\Helpers\Migration;
15
+ use Wdr\App\Helpers\SurveyForm;
16
+
17
+ if (!defined('ABSPATH')) exit;
18
+
19
+ class Settings extends Base
20
+ {
21
+ public $tabs;
22
+
23
+ function __construct()
24
+ {
25
+ parent::__construct();
26
+ }
27
+
28
+ /**
29
+ * Initialize admin menu
30
+ */
31
+ function AddMenu()
32
+ {
33
+ if (!is_admin()) return;
34
+ global $submenu;
35
+ if (isset($submenu['woocommerce'])) {
36
+ add_submenu_page(
37
+ 'woocommerce',
38
+ __('Woo Discount Rules', WDR_TEXT_DOMAIN),
39
+ __('Woo Discount Rules', WDR_TEXT_DOMAIN),
40
+ 'manage_woocommerce', WDR_SLUG,
41
+ array($this, 'adminTabs')
42
+ );
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Show up the survey form
48
+ */
49
+ function setupSurveyForm()
50
+ {
51
+ $survey = new SurveyForm();
52
+ $survey->init('woo-discount-rules', 'Discount Rules for WooCommerce', WDR_TEXT_DOMAIN);
53
+ }
54
+
55
+ /**
56
+ * Add settings link
57
+ * @param $links
58
+ * @return array
59
+ */
60
+ function wdr_action_link($links)
61
+ {
62
+ $action_links = array(
63
+ 'settings' => '<a href="' . admin_url('admin.php?page=woo_discount_rules&tab=settings') . '">' . __('Settings', WDR_TEXT_DOMAIN) . '</a>',
64
+ );
65
+ return array_merge($action_links, $links);
66
+ }
67
+
68
+ /**
69
+ * Create admin tabs and menus
70
+ */
71
+ function adminTabs()
72
+ {
73
+ $id = $this->input->get('id', 0);
74
+ $current_tab = $this->getCurrentTab();
75
+ $tabs = $this->getTabs();
76
+ $page = $this->getPageTask();
77
+ $handler = isset($tabs[$current_tab]) ? $tabs[$current_tab] : $tabs[$this->getDefaultTab()];
78
+ $params = array(
79
+ 'tabs' => $tabs,
80
+ 'handler' => $handler,
81
+ 'page' => $page,
82
+ 'current_tab' => $current_tab);
83
+ $params['on_sale_page_rebuild'] = OnSaleShortCode::getOnPageReBuildOption($id);
84
+ // $load_welcome_content = $this->loadWelcomeContent();
85
+ $path = WDR_PLUGIN_PATH . 'App/Views/Admin/Menu.php';
86
+ // if($load_welcome_content === true){
87
+ // $path = WDR_PLUGIN_PATH . 'App/Views/Admin/welcome-text.php';
88
+ // }
89
+ self::$template_helper->setPath($path)->setData($params)->display();
90
+
91
+ }
92
+
93
+ /**
94
+ * Load welcome content
95
+ * */
96
+ protected function loadWelcomeContent(){
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * get current active tab
102
+ * @return mixed|string
103
+ */
104
+ private function getCurrentTab()
105
+ {
106
+ $get_current_tab = $this->input->get('tab');
107
+ return isset($get_current_tab) ? $get_current_tab : $this->getDefaultTab();
108
+ }
109
+
110
+ /**
111
+ * Default tab for admin
112
+ * @return string
113
+ */
114
+ private function getDefaultTab()
115
+ {
116
+ return 'rules';
117
+ }
118
+
119
+ /**
120
+ * Get available tabs
121
+ * @return mixed
122
+ */
123
+ private function getTabs()
124
+ {
125
+ // return $this->tabs;
126
+ $tabs = array(
127
+ 'rules' => new DiscountRules(),
128
+ 'settings' => new GeneralSettings(),
129
+ 'statistics' => new Statistics(),
130
+ 'compatible' => new Compatible(),
131
+ 'importexport' => new ImportExport(),
132
+ 'help' => new Help(),
133
+ );
134
+ uasort($tabs, function ($tab1, $tab2) {
135
+ $priority1 = (int)isset($tab1->priority) ? $tab1->priority : 1000;
136
+ $priority2 = (int)isset($tab2->priority) ? $tab2->priority : 1000;
137
+ if ($priority1 <= $priority2) {
138
+ return -1;
139
+ } else {
140
+ return 1;
141
+ }
142
+ });
143
+ return $this->tabs = $tabs;
144
+ }
145
+
146
+ /**
147
+ * get page action
148
+ * @return mixed|string
149
+ */
150
+ private function getPageTask()
151
+ {
152
+ return $this->input->get('task', '');
153
+ }
154
+
155
+ /**
156
+ * display the admin notices if our old plugin found
157
+ */
158
+ function adminNotices()
159
+ {
160
+ if (defined('WOO_DISCOUNT_VERSION')) {
161
+ echo '<div class="notice notice-warning is-dismissible"><p>' . __("We found that your were using our old \"Woo discount rules\" plugin, Please disable it!", WDR_TEXT_DOMAIN) . '</p></div>';
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Add admin scripts
167
+ * @param $hook
168
+ */
169
+ public function adminScripts()
170
+ {
171
+ if ( !isset($_GET['page']) || $_GET['page'] != WDR_SLUG) {
172
+ return;
173
+ }
174
+ /**
175
+ *Enqueue css
176
+ */
177
+ wp_enqueue_style(WDR_SLUG . '-datetimepickercss', WDR_PLUGIN_URL . 'Assets/Css/jquery.datetimepicker.min.css');
178
+ wp_enqueue_style(WDR_SLUG . '-admin', WDR_PLUGIN_URL . 'Assets/Css/admin_style.css');
179
+ wp_enqueue_style(WDR_SLUG . '-jquery-ui-css', WDR_PLUGIN_URL . 'Assets/Js/Jquery-ui/jquery-ui.min.css');
180
+ wp_enqueue_style(WDR_SLUG . '-dragable-ui-css', WDR_PLUGIN_URL . 'Assets/Css/dragtable.css');
181
+ /**
182
+ * Enqueue js
183
+ */
184
+ wp_enqueue_script('wdr-select2-js', self::$woocommerce_helper->getWooPluginUrl() . '/assets/js/select2/select2.full.min.js', array('jquery'));
185
+ wp_enqueue_style('wdr-select2-js', self::$woocommerce_helper->getWooPluginUrl() . '/assets/css/select2.css');
186
+ wp_enqueue_script( 'woocommerce_admin' );
187
+ //To load woocommerce product select
188
+ wp_enqueue_style( 'woocommerce_admin_styles' );
189
+
190
+ wp_enqueue_script(WDR_SLUG . '-jquery-ui', WDR_PLUGIN_URL . 'Assets/Js/Jquery-ui/jquery-ui.min.js', array('jquery', 'jquery'));
191
+ wp_enqueue_script(WDR_SLUG . '-datetimepickerjs', WDR_PLUGIN_URL . 'Assets/Js/jquery.datetimepicker.full.min.js', array('jquery', 'jquery'));
192
+ wp_enqueue_script(WDR_SLUG . '-moment', WDR_PLUGIN_URL . 'Assets/Js/moment.min.js', array('jquery', 'jquery'));
193
+ wp_enqueue_script(WDR_SLUG . '-rulebuilder', WDR_PLUGIN_URL . 'Assets/Js/rulebuilder.js', array('jquery', 'wdr-select2-js', WDR_SLUG . '-datetimepickerjs'));
194
+ wp_register_script(WDR_SLUG . '-admin', WDR_PLUGIN_URL . 'Assets/Js/admin_script.js');
195
+ wp_enqueue_script(WDR_SLUG . '-admin');
196
+ wp_enqueue_script(WDR_SLUG . '-dragndraop-js', WDR_PLUGIN_URL . 'Assets/Js/jquery.dragtable.js');
197
+
198
+ if ( isset( $_REQUEST['tab'] ) AND $_REQUEST['tab'] == 'statistics' ) {
199
+ wp_enqueue_script( 'google-charts-loader', 'https://www.gstatic.com/charts/loader.js' );
200
+
201
+ wp_enqueue_script( WDR_SLUG.'-statistics',
202
+ WDR_PLUGIN_URL . 'Assets/Js/admin-statistics.js', array( 'jquery' ), WDR_VERSION );
203
+ }
204
+ $preloaded_lists = array(
205
+ 'payment_methods' => $this->getPaymentMethod(),
206
+ 'countries' => $this->getCountries(),
207
+ 'states' => $this->getStates(),
208
+ 'user_roles' => $this->getUserRoles(),
209
+ 'weekdays' => $this->getWeekDays(),
210
+ 'site_languages' => $this->getSiteLanguages(),
211
+ 'order_status' => $this->getWoocommerceOrderStatus(),
212
+ 'banner_position' => $this->getBannerPosition(),
213
+ );
214
+ $localization_data = $this->getLocalizationData();
215
+ $wdr_data = array(
216
+ 'labels' => array(
217
+ 'select2_no_results' => __('no results', WDR_TEXT_DOMAIN),
218
+ 'placeholders' => __('Select Values', WDR_TEXT_DOMAIN),
219
+ ),
220
+ 'lists' => $preloaded_lists,
221
+ 'admin_url' => admin_url('admin.php?page=woo_discount_rules'),
222
+ 'localization_data' => $localization_data,
223
+ 'rule_id' => $this->input->get('task', 'create'),
224
+ );
225
+ wp_localize_script(WDR_SLUG . '-admin', 'wdr_data', $wdr_data);
226
+ }
227
+
228
+ /**
229
+ * Get Payment Gateway Methods from WC
230
+ * @return array
231
+ */
232
+ public function getPaymentMethod()
233
+ {
234
+ $payment_gateways = self::$woocommerce_helper->getPaymentMethodList();
235
+ $result = array();
236
+ foreach ($payment_gateways as $payment_gateway) {
237
+ $result[] = array(
238
+ 'id' => $payment_gateway->id,
239
+ 'text' => $payment_gateway->title,
240
+ );
241
+ }
242
+ return array_values($result);
243
+ }
244
+
245
+ /**
246
+ * get countries from WC
247
+ * @return array
248
+ */
249
+ public function getCountries()
250
+ {
251
+ $countries = self::$woocommerce_helper->getCountriesList();
252
+ $result = array_map(function ($id, $text) {
253
+ return array(
254
+ 'id' => $id,
255
+ 'text' => $text,
256
+ );
257
+ }, array_keys($countries), $countries);
258
+ return array_values($result);
259
+ }
260
+
261
+ /**
262
+ * get States from WC
263
+ * @return array
264
+ */
265
+ public function getStates()
266
+ {
267
+ $country_states = self::$woocommerce_helper->getStatesList();
268
+ $result = array();
269
+ foreach ($country_states as $states) {
270
+ foreach ($states as $id => $text) {
271
+ $result[] = array(
272
+ 'id' => $id,
273
+ 'text' => $text,
274
+ );
275
+ }
276
+ }
277
+ return $result;
278
+ }
279
+
280
+ /**
281
+ * get user roles
282
+ * @return array
283
+ */
284
+ public function getUserRoles()
285
+ {
286
+ $all_roles = self::$woocommerce_helper->getUserRolesList();
287
+ $result = array_map(function ($id, $role) {
288
+ return array(
289
+ 'id' => (string)$id,
290
+ 'text' => $role['name'],
291
+ );
292
+ }, array_keys($all_roles), $all_roles);
293
+ $result[] = array(
294
+ 'id' => 'woo_discount_rules_guest',
295
+ 'text' => esc_html__('Guest', WDR_TEXT_DOMAIN),
296
+ );
297
+ return array_values($result);
298
+ }
299
+
300
+ /**
301
+ * get users nickname
302
+ * @param $ids
303
+ * @return array
304
+ */
305
+ /* public function getUsers($ids)
306
+ {
307
+ $users = get_users(array(
308
+ 'fields' => array('ID', 'user_nicename'),
309
+ 'include' => $ids,
310
+ 'orderby' => 'user_nicename',
311
+ ));
312
+ return array_map(function ($user) {
313
+ return array(
314
+ 'id' => (string)$user->ID,
315
+ 'text' => $user->user_nicename,
316
+ );
317
+ }, $users);
318
+ }*/
319
+ /**
320
+ * Build week days
321
+ * @return array
322
+ */
323
+ public function getWeekDays()
324
+ {
325
+ $result = self::$woocommerce_helper->getWeekDaysList();
326
+ $days_array = array();
327
+ foreach ($result as $day_key => $day) {
328
+ $days_array[] = array(
329
+ 'id' => $day_key,
330
+ 'text' => $day,
331
+ );
332
+ }
333
+ return $days_array;
334
+ }
335
+
336
+ /**
337
+ * Build week days
338
+ * @return array
339
+ */
340
+ public function getBannerPosition()
341
+ {
342
+ $result = self::$woocommerce_helper->getBannerPositionList();
343
+ $banner_position_array = array();
344
+ foreach ($result as $position_key => $position) {
345
+ $banner_position_array[] = array(
346
+ 'id' => $position_key,
347
+ 'text' => $position,
348
+ );
349
+ }
350
+ return $banner_position_array;
351
+ }
352
+
353
+ /**
354
+ * Build week days
355
+ * @return array
356
+ */
357
+ public function getSiteLanguages()
358
+ {
359
+ $language_helper = new Language();
360
+ $available_languages = $language_helper::getAvailableLanguages();
361
+ $processed_languages = array();
362
+ if (!empty($available_languages)) {
363
+ foreach ($available_languages as $key => $lang) {
364
+ $native_name = isset($lang['native_name']) ? $lang['native_name'] : NULL;
365
+ $processed_languages[] = array(
366
+ 'id' => $key,
367
+ 'text' => $native_name,
368
+ );
369
+ }
370
+ } else {
371
+ $default_language = $language_helper->getDefaultLanguage();
372
+ $processed_languages[$default_language] = $language_helper->getLanguageLabel($default_language);
373
+ $processed_languages[] = array(
374
+ 'id' => $default_language,
375
+ 'text' => $language_helper->getLanguageLabel($default_language),
376
+ );
377
+ }
378
+ return $processed_languages;
379
+ }
380
+
381
+ /**
382
+ * get woocommerce order status
383
+ * @return array
384
+ */
385
+ public function getWoocommerceOrderStatus()
386
+ {
387
+ $order_status = self::$woocommerce_helper->getOrderStatusList();
388
+ $result = array_map(function ($id, $status) {
389
+ return array(
390
+ 'id' => $id,
391
+ 'text' => $status,
392
+ );
393
+ }, array_keys($order_status), $order_status);
394
+ return array_values($result);
395
+ }
396
+
397
+ /**
398
+ * Get localisation script
399
+ */
400
+ protected function getLocalizationData()
401
+ {
402
+ return array(
403
+ 'disable' => esc_html__('Disable', WDR_TEXT_DOMAIN),
404
+ 'active' => esc_html__('Active', WDR_TEXT_DOMAIN),
405
+ 'enable' => esc_html__('Enable', WDR_TEXT_DOMAIN),
406
+ 'running' => esc_html__(' - (Running)', WDR_TEXT_DOMAIN),
407
+ 'error' => esc_html__('Oops!! something went wrong!', WDR_TEXT_DOMAIN),
408
+ 'duplicate_rule' => esc_html__('Rule duplicated successfully!', WDR_TEXT_DOMAIN),
409
+ 'deleted_rule' => esc_html__('Rule deleted successfully!', WDR_TEXT_DOMAIN),
410
+ 'delete_confirm' => esc_html__('Are you sure want to delete this rule!', WDR_TEXT_DOMAIN),
411
+ 'disabled_rule' => esc_html__('Rule disabled successfully!', WDR_TEXT_DOMAIN),
412
+ 'enabled_rule' => esc_html__('Rule enabled successfully!', WDR_TEXT_DOMAIN),
413
+ 'save_rule' => esc_html__('Rule saved successfully!', WDR_TEXT_DOMAIN),
414
+ 'save_settings' => esc_html__('Settings saved successfully!', WDR_TEXT_DOMAIN),
415
+ 'save_priority' => esc_html__('Rule priority changed successfully!', WDR_TEXT_DOMAIN),
416
+ 'priority_not_saved' => esc_html__('Rule priority not changed !', WDR_TEXT_DOMAIN),
417
+ 'chart_data' => esc_html__('No data for this period', WDR_TEXT_DOMAIN),
418
+ 'coupon_exists' => esc_html__('Oops! Coupon already exists in Woocommerce', WDR_TEXT_DOMAIN),
419
+ 'copied' => esc_html__('Copied!', WDR_TEXT_DOMAIN),
420
+ 'copy_shortcode' => esc_html__('Copy ShortCode', WDR_TEXT_DOMAIN),
421
+ 'recursive_warning' => esc_html__('If you make this recursive other row(s) will be removed!', WDR_TEXT_DOMAIN),
422
+ 'recursive_qty' => esc_html__('Quantity', WDR_TEXT_DOMAIN),
423
+ 'recursive_min_qty' => esc_html__('Minimum Quantity', WDR_TEXT_DOMAIN),
424
+ 'buyx_getx_value' => esc_html__('Discount value', WDR_TEXT_DOMAIN),
425
+ 'buyx_getx_percentage' => esc_html__('Discount percentage', WDR_TEXT_DOMAIN),
426
+ 'bogo_buyx_gety_filter_heading' => esc_html__('Filter (Buy)', WDR_TEXT_DOMAIN),
427
+ 'common_filter_heading' => esc_html__('Filter', WDR_TEXT_DOMAIN),
428
+ 'common_filter_description' => __('<p>Choose <b>what gets discount</b> (products/categories/attributes/SKU and so on )</p>
429
+ <p>Note : You can also exclude products/categories.</p>', WDR_TEXT_DOMAIN),
430
+ 'common_discount_heading' => esc_html__('Discount', WDR_TEXT_DOMAIN),
431
+ 'common_discount_description' => __('<p>Select discount type and its value (percentage/price/fixed price)</p>', WDR_TEXT_DOMAIN),
432
+ 'common_rules_heading' => esc_html__('Rules (optional)', WDR_TEXT_DOMAIN),
433
+ 'common_rules_description' => __('<p>Include additional conditions (if necessary) to apply discount for product filters.</p>', WDR_TEXT_DOMAIN),
434
+ 'bogo_buyx_gety_filter_description' => __('<p>Choose Buy Products. (products/categories/attributes/tags/sku) Example : For Buy X get Y scenarios, choose X here.</p>', WDR_TEXT_DOMAIN),
435
+ 'bogo_buyx_getx_filter_description' => __('<p>Choose on which products the discount should be applied (This can be products/categories/SKU)</p>', WDR_TEXT_DOMAIN),
436
+ 'bogo_buyx_getx_discount_heading' => esc_html__('Get Discount', WDR_TEXT_DOMAIN),
437
+ 'bogo_buyx_getx_discount_content' => __('<p>Enter the min/max ranges and choose free item quantity.</p><p>Note : Enable recursive checkbox if the discounts should be applied in sequential ranges. </p><p>Example : Buy 1 get 1, Buy 2 get 2, Buy 3 get 3 and so on..</p>', WDR_TEXT_DOMAIN),
438
+ 'bogo_buyx_gety_discount_heading' => esc_html__('Get Discount', WDR_TEXT_DOMAIN),
439
+ 'bogo_buyx_gety_discount_content' => __('<p>Choose the adjustment type to which the discount should be applied. You can choose from products/categories/all products.</p><p>Note : Enable recursive checkbox if the discounts should be applied in sequential ranges. </p>', WDR_TEXT_DOMAIN),
440
+ 'bogo_buyx_gety_discount_content_for_cat_and_all' => __('<p>Choose the adjustment type to which the discount should be applied. You can choose from products/categories/all products.</p><p>Note : Enable recursive checkbox if the discounts should be applied in sequential ranges. </p><p>Example ranges:</p><p>Buy 2, get 1 free (a.k.a: Buy 1 get 1 free)</p><table><tbody><tr><td>Min quantity</td><td>Max quantity</td><td>Free quantity</td></tr><tr><td>2</td><td>3</td><td>1</td></tr></tr><tr><td>4</td><td>5</td><td>2</td></tr></tbody></table>', WDR_TEXT_DOMAIN),
441
+ 'bogo_buyx_getx_rules_description' => __('<p>Include additional conditions (if necessary)</p>', WDR_TEXT_DOMAIN),
442
+ 'bogo_buyx_gety_rules_description' => __('<p>Include additional conditions (if necessary)</p>', WDR_TEXT_DOMAIN),
443
+ 'processing_migration_text' => __('<p>Processing migration, please wait...</p>', WDR_TEXT_DOMAIN),
444
+ 'processing_migration_success_message' => __('<p>Migration completed.</p>', WDR_TEXT_DOMAIN),
445
+ 'skip_migration_success_message' => __('<p>Migration skipped.</p>', WDR_TEXT_DOMAIN),
446
+ 'skip_migration_text' => __('<p>Skipping migration, please wait...</p>', WDR_TEXT_DOMAIN),
447
+ 'mode_variation_cumulative_example' => __('<span><b>Example:</b> Product A - Small and Product A - Medium will be counted as 2 quantity</span>', WDR_TEXT_DOMAIN),
448
+ 'filter_all_products' => __('<span>Discount applies to all eligible products in the store</span>', WDR_TEXT_DOMAIN),
449
+ 'filter_products' => __('<span>Choose products that get the discount using "In List". If you want to exclude a few products, choose "Not In List" and select the products you wanted to exclude from discount. (You can add multiple filters)</span>', WDR_TEXT_DOMAIN),
450
+ 'filter_Category' => __('<span>Choose categories that get the discount using "In List". If you want to exclude a few categories, choose "Not In List" and select the categories you wanted to exclude from discount. (You can add multiple filters of same type)</span>', WDR_TEXT_DOMAIN),
451
+ 'filter_Attributes' => __('<span> Choose attributes that get the discount using "In List". If you want to exclude a few attributes, choose "Not In List" and select the attributes you wanted to exclude from discount. (You can add multiple filters of same type)</span>', WDR_TEXT_DOMAIN),
452
+ 'filter_Tags' => __('<span>Choose tags that get the discount using "In List". If you want to exclude a few tags, choose "Not In List" and select the tags you wanted to exclude from discount. (You can add multiple filters of same type)</span>', WDR_TEXT_DOMAIN),
453
+ 'filter_SKUs' => __('<span>Choose SKUs that get the discount using "In List". If you want to exclude a few SKUs, choose "Not In List" and select the SKUs you wanted to exclude from discount. (You can add multiple filters of same type)</span>', WDR_TEXT_DOMAIN),
454
+ 'filter_On_sale_products' => __('<span>Choose whether you want to include (or exclude) products on sale (those having a sale price) for the discount </span>', WDR_TEXT_DOMAIN),
455
+ 'filter_custom_taxonomies' => __('<span>Discount applies to custom taxonomy</span>', WDR_TEXT_DOMAIN),
456
+ 'rebuild_on_sale_list_processing_text' => __('Processing please wait..', WDR_TEXT_DOMAIN),
457
+ 'rebuild_on_sale_list_processed_text' => __('Rebuild index processed', WDR_TEXT_DOMAIN),
458
+ 'rebuild_on_sale_list_error_please_select_rule' => __('Please select the rules to build index', WDR_TEXT_DOMAIN),
459
+ );
460
+ }
461
+ }
v2/App/Controllers/Admin/Tabs/Base.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers\Admin\Tabs;
4
+
5
+ use Wdr\App\Controllers\Base as BaseController;
6
+
7
+ if (!defined('ABSPATH')) exit;
8
+
9
+ abstract class Base extends BaseController
10
+ {
11
+ public $title = NULL, $priority, $input, $base;
12
+ protected $tab;
13
+
14
+ /**
15
+ * Base constructor.
16
+ */
17
+ function __construct()
18
+ {
19
+ parent::__construct();
20
+ }
21
+
22
+ /**
23
+ * ajax call
24
+ */
25
+ public function ajax() {
26
+ $method = isset( $_REQUEST['method'] ) ? $_REQUEST['method'] : '';
27
+ $method = "ajax_{$method}";
28
+
29
+ if ( method_exists( $this, $method ) ) {
30
+ $this->$method();
31
+ }
32
+ }
33
+
34
+ /**
35
+ * render templates
36
+ * @param null $page
37
+ * @return mixed
38
+ */
39
+ abstract function render($page = NULL);
40
+
41
+
42
+ }
v2/App/Controllers/Admin/Tabs/Compatible.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs;
3
+
4
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
5
+
6
+ class Compatible extends Base
7
+ {
8
+ public $priority = 40;
9
+ protected $tab = 'compatible';
10
+ protected $option_key = 'awdr_compatibility';
11
+ protected $options = null;
12
+ public static $instance;
13
+ protected $available_classes = null;
14
+
15
+ /**
16
+ * GeneralSettings constructor.
17
+ */
18
+ public function __construct()
19
+ {
20
+ parent::__construct();
21
+ $this->title = __('Compatibility', WDR_TEXT_DOMAIN);
22
+ }
23
+
24
+ /**
25
+ * To create instance
26
+ * */
27
+ public static function getInstance()
28
+ {
29
+ if (!self::$instance) {
30
+ self::$instance = new self();
31
+ }
32
+
33
+ return self::$instance;
34
+ }
35
+
36
+ /**
37
+ * Render settings page
38
+ * @param null $page
39
+ * @return mixed|void
40
+ */
41
+ public function render($page = NULL)
42
+ {
43
+ $this->saveCompatibilitySettings();
44
+ $params=array(
45
+ 'woocommerce' => self::$woocommerce_helper,
46
+ 'template_helper' => self::$template_helper,
47
+ 'base' => $this,
48
+ );
49
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/compatible.php')->setData($params)->display();
50
+ }
51
+
52
+ /**
53
+ * Get Config
54
+ * */
55
+ public function getConfig($reload = 0){
56
+ if($this->options === null || $reload == 1){
57
+ $option = get_option($this->option_key, array());
58
+ if (empty($option)) {
59
+ $this->options = array();
60
+ } else {
61
+ $this->options = $option;
62
+ }
63
+ }
64
+
65
+ return $this->options;
66
+ }
67
+
68
+ /**
69
+ * Get config data
70
+ * */
71
+ public function getConfigData($key, $default = ''){
72
+ $options = $this->getConfig();
73
+ if(isset($options[$key])){
74
+ return $options[$key];
75
+ }
76
+ return $default;
77
+ }
78
+
79
+ /**
80
+ * Save compatibility settings
81
+ * */
82
+ protected function saveCompatibilitySettings(){
83
+ if(isset($_POST['awdr_compatibility_submit'])){
84
+ if($_POST['awdr_compatibility_submit'] == 1){
85
+ $wdrc = isset($_POST['wdrc'])? $_POST['wdrc']: array();
86
+ update_option($this->option_key, $wdrc);
87
+ }
88
+ }
89
+ }
90
+
91
+ /**
92
+ * load fields
93
+ * */
94
+ public function loadFields(&$has_compatibility_plugin){
95
+ $available_classes = $this->getAvailableCompatibilityClasses();
96
+ if(!empty($available_classes)){
97
+ foreach ($available_classes as $available_class){
98
+ if(method_exists($available_class, 'loadFields')){
99
+ $available_class->loadFields($has_compatibility_plugin);
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Run compatibility scripts
107
+ * */
108
+ public function runCompatibilityScripts(){
109
+ $available_classes = $this->getAvailableCompatibilityClasses();
110
+ if(!empty($available_classes)){
111
+ foreach ($available_classes as $available_class){
112
+ if(method_exists($available_class, 'run')){
113
+ $available_class->run();
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * available compatibility classes
121
+ * @return array
122
+ */
123
+ public function getAvailableCompatibilityClasses()
124
+ {
125
+ if($this->available_classes === null){
126
+ $this->available_classes = array();
127
+ //Read the compatibility directory
128
+ if (file_exists(WDR_PLUGIN_PATH . 'App/Compatibility/')) {
129
+ $compatibility_list = array_slice(scandir(WDR_PLUGIN_PATH . 'App/Compatibility/'), 2);
130
+ if (!empty($compatibility_list)) {
131
+ foreach ($compatibility_list as $compatible_file_name) {
132
+ $class_name = basename($compatible_file_name, '.php');
133
+ if (!in_array($class_name, array('Base'))) {
134
+ $compatible_class_name = 'Wdr\App\Compatibility\\' . $class_name;
135
+ if (class_exists($compatible_class_name)) {
136
+ $compatible_object = new $compatible_class_name();
137
+ if ($compatible_object instanceof \Wdr\App\Compatibility\Base) {
138
+ $this->available_classes[] = $compatible_object;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ $this->available_classes = apply_filters( 'advanced_woo_discount_rules_available_compatibility_classes', $this->available_classes);
146
+
147
+ }
148
+ return $this->available_classes;
149
+ }
150
+ }
v2/App/Controllers/Admin/Tabs/DiscountRules.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs;
3
+
4
+ use Wdr\App\Controllers\Configuration;
5
+ use Wdr\App\Controllers\OnSaleShortCode;
6
+ use Wdr\App\Helpers\Migration;
7
+ use Wdr\App\Helpers\Rule;
8
+
9
+ if (!defined('ABSPATH')) exit;
10
+
11
+ class DiscountRules extends Base
12
+ {
13
+ public $priority = 10;
14
+ protected $tab = 'rules';
15
+
16
+ /**
17
+ * DiscountRules constructor.
18
+ */
19
+ function __construct()
20
+ {
21
+ parent::__construct();
22
+ $this->title = __('Discount Rules', WDR_TEXT_DOMAIN);
23
+ }
24
+
25
+ /**
26
+ * Render rules listing page
27
+ * @param null $page
28
+ * @return mixed|void
29
+ */
30
+ function render($page = NULL)
31
+ {
32
+ $rule_helper = new Rule();
33
+ $available_conditions = $this->getAvailableConditions();
34
+ $params = array();
35
+ //$params['configuration'] = new Configuration();
36
+ $params['base'] = $this;
37
+ $params['site_languages'] = $this->getAvailableLanguages();
38
+ if (isset($page) && !empty($page)) {
39
+ $id = $this->input->get('id', 0);
40
+ $params['rule'] = $rule_helper->getRule($id, $available_conditions);
41
+ $params['page'] = $page;
42
+ $params['product_filters'] = $this->getProductFilterTypes();
43
+ $params['on_sale_page_rebuild'] = OnSaleShortCode::getOnPageReBuildOption($id);
44
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Manage.php')->setData($params)->display();
45
+ } else {
46
+ $params['has_migration'] = $this->isMigrationAvailable();
47
+ if($params['has_migration']){
48
+ $params['migration_rule_count'] =$this->getV1RuleCount();
49
+ }
50
+
51
+ $name = $this->input->get('name', '');
52
+ if (empty($name)) {
53
+ $params['rules'] = $rule_helper->getAllRules($available_conditions);
54
+ } else {
55
+ $params['rules'] = $rule_helper->searchRuleByName($name, $available_conditions);
56
+ }
57
+ $params['input'] = $this->input;
58
+
59
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/DiscountRule.php')->setData($params)->display();
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Load welcome content
65
+ * */
66
+ protected function getV1RuleCount(){
67
+ $migration = new Migration();
68
+ $data['price_rules'] = $data['cart_rules'] = 0;
69
+ $price_rules = $migration->getV1Rules('woo_discount', 1);
70
+ $cart_rules = $migration->getV1Rules('woo_discount_cart', 1);
71
+ if(!empty($price_rules)){
72
+ $data['price_rules'] = count($price_rules);
73
+ }
74
+ if(!empty($cart_rules)){
75
+ $data['cart_rules'] = count($cart_rules);
76
+ }
77
+
78
+ return $data;
79
+ }
80
+
81
+ /**
82
+ * Load welcome content
83
+ * */
84
+ protected function isMigrationAvailable(){
85
+ $migration = new Migration();
86
+ $has_migration = $migration->getMigrationInfoOf('has_migration', null);
87
+ if($has_migration){
88
+ $skipped_migration = $migration->getMigrationInfoOf('skipped_migration', 0);
89
+ $migration_completed = $migration->getMigrationInfoOf('migration_completed', 0);
90
+ if($skipped_migration || $migration_completed){
91
+ return false;
92
+ }
93
+ return true;
94
+ }
95
+
96
+ return false;
97
+ }
98
+
99
+ /**
100
+ * Get all available languages
101
+ * @return mixed|void
102
+ */
103
+ function getAvailableLanguages()
104
+ {
105
+ $language_helper_object = self::$language_helper;
106
+ $available_languages = $language_helper_object::getAvailableLanguages();
107
+ $processed_languages = array();
108
+ if (!empty($available_languages)) {
109
+ foreach ($available_languages as $key => $lang) {
110
+ $native_name = isset($lang['native_name']) ? $lang['native_name'] : NULL;
111
+ $processed_languages[$key] = $native_name;
112
+ }
113
+ } else {
114
+ $default_language = self::$language_helper->getDefaultLanguage();
115
+ $processed_languages[$default_language] = self::$language_helper->getLanguageLabel($default_language);
116
+ }
117
+ return $processed_languages;
118
+ }
119
+ }
v2/App/Controllers/Admin/Tabs/GeneralSettings.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs;
3
+ use http\Params;
4
+ use Wdr\App\Controllers\Configuration;
5
+ use Wdr\App\Controllers\DiscountCalculator;
6
+ use Wdr\App\Helpers\Helper;
7
+ use Wdr\App\Helpers\Migration;
8
+ use Wdr\App\Helpers\Rule;
9
+
10
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
11
+
12
+ class GeneralSettings extends Base
13
+ {
14
+ public $priority = 20;
15
+ protected $tab = 'settings';
16
+
17
+ /**
18
+ * GeneralSettings constructor.
19
+ */
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->title = __('Settings', WDR_TEXT_DOMAIN);
24
+ }
25
+
26
+ /**
27
+ * Render settings page
28
+ * @param null $page
29
+ * @return mixed|void
30
+ */
31
+ public function render($page = NULL)
32
+ {
33
+ $reset_migration = $this->input->get('reset_migration', '');
34
+ if(!empty($reset_migration) && $reset_migration == 1){
35
+ $this->resetMigration();
36
+ }
37
+ $rule_helper = new Rule();
38
+ $available_rules_for_customizer = $rule_helper->getAvailableRules($this->getAvailableConditions());
39
+ $params=array(
40
+ 'woocommerce' => self::$woocommerce_helper,
41
+ 'configuration' => new Configuration(),
42
+ 'is_pro' => Helper::hasPro(),
43
+ 'discount_calculator' => new DiscountCalculator($available_rules_for_customizer),
44
+ 'template_helper' => self::$template_helper,
45
+ 'base' => $this,
46
+ );
47
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/settings.php')->setData($params)->display();
48
+ }
49
+
50
+ /**
51
+ * Reset migration
52
+ * */
53
+ protected function resetMigration(){
54
+ $migration = new Migration();
55
+ $data['migration_completed'] = 0;
56
+ $data['v1_last_migrated_price_rule_id'] = 0;
57
+ $data['v1_last_migrated_cart_rule_id'] = 0;
58
+ $data['skipped_migration'] = 0;
59
+ $migration->updateMigrationInfo($data);
60
+ }
61
+ }
v2/App/Controllers/Admin/Tabs/Help.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs;
3
+
4
+ if (!defined('ABSPATH')) exit;
5
+
6
+ class Help extends Base
7
+ {
8
+ public $priority = 50;
9
+ protected $tab = 'help';
10
+
11
+ /**
12
+ * Help constructor.
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->title = __('Read Documentation', WDR_TEXT_DOMAIN);
18
+ }
19
+
20
+ /**
21
+ * Render Read documents page
22
+ * @param null $page
23
+ * @return mixed|void
24
+ */
25
+ public function render($page = NULL)
26
+ {
27
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/help.php')->display();
28
+ }
29
+ }
v2/App/Controllers/Admin/Tabs/ImportExport.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs;
3
+
4
+ use Wdr\App\Helpers\Rule;
5
+
6
+ if (!defined('ABSPATH')) exit;
7
+
8
+ class ImportExport extends Base
9
+ {
10
+ public $priority = 40;
11
+ protected $tab = 'importexport';
12
+
13
+ /**
14
+ * GeneralSettings constructor.
15
+ */
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->title = __('Export', WDR_TEXT_DOMAIN);
20
+ }
21
+
22
+ /**
23
+ * Render Import Export page
24
+ * @param null $page
25
+ * @return mixed|void
26
+ */
27
+ public function render($page = NULL)
28
+ {
29
+ $rule_helper = new Rule();
30
+ $params = array(
31
+ 'rules' => $rule_helper->exportRuleByName('all'),
32
+ );
33
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/ImportExport.php')->setData($params)->display();
34
+ }
35
+ }
v2/App/Controllers/Admin/Tabs/Reports/Base.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers\Admin\Tabs\Reports;
4
+
5
+ use Wdr\App\Controllers\Base as BaseController;
6
+
7
+ if (!defined('ABSPATH')) exit;
8
+
9
+ abstract class Base extends BaseController
10
+ {
11
+ /**
12
+ * Base constructor.
13
+ */
14
+ function __construct()
15
+ {
16
+ parent::__construct();
17
+ }
18
+
19
+ /**
20
+ * @return string
21
+ */
22
+ abstract function get_title();
23
+
24
+ /**
25
+ * @return string
26
+ */
27
+ abstract function get_subtitle();
28
+
29
+ /**
30
+ * @return string
31
+ */
32
+ abstract function get_type();
33
+
34
+ /**
35
+ * @param array $params
36
+ *
37
+ * @return array
38
+ */
39
+ abstract function get_data( $params );
40
+ }
v2/App/Controllers/Admin/Tabs/Reports/RuleAmount.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs\Reports;
3
+
4
+ use Wdr\App\Models\DBTable;
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+
11
+ class RuleAmount extends Base {
12
+
13
+ public function get_title() {
14
+ return __( 'Rule amount data without cart adjustments', WDR_TEXT_DOMAIN );
15
+ }
16
+
17
+ public function get_subtitle() {
18
+ return __( 'TOP 5', WDR_TEXT_DOMAIN );
19
+ }
20
+
21
+ public function get_type() {
22
+ return 'line';
23
+ }
24
+
25
+ public function get_data( $params ) {
26
+
27
+ $params = $this->prepare_params( $params );
28
+
29
+ $rule_amount_stats = $this->load_raw_data( $params );
30
+
31
+ $rules = array_unique( array_column( $rule_amount_stats, 'title' ) );
32
+ $columns = array_merge( array( __( 'Date', WDR_TEXT_DOMAIN ) ), $rules );
33
+
34
+ $rows = array();
35
+ $dates = $this->get_dates( $params['from'], $params['to'] );
36
+ foreach ( $dates as $date ) {
37
+ $rows[ $date ] = array_fill( 0, count( $columns ), 0.0 );
38
+ $rows[ $date ][0] = $date;
39
+
40
+ }
41
+ foreach ( $rule_amount_stats as $rule_amount_item ) {
42
+ $date = date( 'Y-m-d', strtotime( $rule_amount_item->date_rep ) );
43
+ if ( ! isset( $rows[ $date ] ) ) {
44
+ continue;
45
+ }
46
+
47
+ $column_key = array_search( $rule_amount_item->title, $columns );
48
+ if ( false === $column_key ) {
49
+ continue;
50
+ }
51
+
52
+ $rows[ $date ][ $column_key ] = (float) $rule_amount_item->value;
53
+ }
54
+
55
+ $ret = $this->prepare_data( $columns, $rows );
56
+
57
+ return $ret;
58
+ }
59
+
60
+ protected function prepare_data( $columns, $rows ) {
61
+ $ret = array(
62
+ 'title' => $this->get_title(),
63
+ 'subtitle' => $this->get_subtitle(),
64
+ 'type' => $this->get_type(),
65
+ 'columns' => $columns,
66
+ 'rows' => $rows,
67
+ );
68
+
69
+ return $ret;
70
+ }
71
+
72
+ protected function load_raw_data( $params ) {
73
+ $rule_amount_stats = DBTable::get_rules_rows_summary( $params );
74
+ if ( empty( $rule_amount_stats ) ) {
75
+ $rule_amount_stats = array();
76
+ }
77
+
78
+ return $rule_amount_stats;
79
+ }
80
+
81
+ protected function prepare_params( $params ) {
82
+ return array(
83
+ 'from' => $params['from'],
84
+ 'to' => $params['to'],
85
+ 'limit' => 5,
86
+ 'include_amount' => true,
87
+ //'include_gifted_amount' => true,
88
+ );
89
+ }
90
+
91
+ protected function get_dates( $from, $to ) {
92
+ $ret = array();
93
+
94
+ $to = strtotime( $to );
95
+ for ( $current = strtotime( $from ); $current <= $to; $current += 60 * 60 * 24 ) {
96
+ $ret[] = date( 'Y-m-d', $current );
97
+ }
98
+
99
+ return $ret;
100
+ }
101
+ }
v2/App/Controllers/Admin/Tabs/Reports/RuleAmountWithCartDiscount.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Controllers\Admin\Tabs\Reports;
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit; // Exit if accessed directly
6
+ }
7
+
8
+ class RuleAmountWithCartDiscount extends RuleAmount {
9
+ public function get_title() {
10
+ return __( 'Rule amount data with cart discounts', WDR_TEXT_DOMAIN );
11
+ }
12
+
13
+ public function get_subtitle() {
14
+ return __( 'TOP 5', WDR_TEXT_DOMAIN );
15
+ }
16
+
17
+ protected function prepare_params( $params ) {
18
+ $params['include_cart_discount'] = true;
19
+
20
+ return $params;
21
+ }
22
+ }
v2/App/Controllers/Admin/Tabs/Statistics.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers\Admin\Tabs;
4
+
5
+ use Wdr\App\Controllers\Configuration;
6
+ use Wdr\App\Helpers\Rule;
7
+ use Wdr\App\Controllers\Admin\Tabs\Reports;
8
+
9
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
+
11
+ class Statistics extends Base
12
+ {
13
+ public $priority = 30;
14
+ protected $tab = 'statistics';
15
+ protected $reports;
16
+
17
+ /**
18
+ * GeneralSettings constructor.
19
+ */
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->title = __('Reports', WDR_TEXT_DOMAIN);
24
+
25
+ $this->reports = array(
26
+ 'rule_amount' => array(
27
+ 'handler' => new Reports\RuleAmount(),
28
+ 'label' => __( 'Rule amount', WDR_TEXT_DOMAIN ),
29
+ 'group' => __( 'Rule', WDR_TEXT_DOMAIN ),
30
+ ),
31
+ 'rule_amount_extra' => array(
32
+ 'handler' => new Reports\RuleAmountWithCartDiscount(),
33
+ 'label' => __( 'Rule amount with cart discount', WDR_TEXT_DOMAIN ),
34
+ 'group' => __( 'Rule', WDR_TEXT_DOMAIN ),
35
+ ),
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Render settings page
41
+ * @param null $page
42
+ * @return mixed|void
43
+ */
44
+ public function render($page = NULL)
45
+ {
46
+
47
+ $charts = array();
48
+ foreach ( $this->reports as $k => $item ) {
49
+ $group = $item['group'];
50
+ if ( ! isset( $charts[ $group ] ) ) {
51
+ $charts[ $group ] = array();
52
+ }
53
+ $charts[ $group ][ $k ] = $item['label'];
54
+ }
55
+
56
+ $params = array(
57
+ 'charts' => $charts,
58
+ );
59
+ self::$template_helper->setPath(WDR_PLUGIN_PATH . 'App/Views/Admin/Tabs/Statistics.php')->setData($params)->display();
60
+ }
61
+
62
+ /**
63
+ * Get chart data for analytics
64
+ */
65
+ protected function ajax_get_chart_data() {
66
+ parse_str( $_POST['params'], $params );
67
+ $type = $params['type'];
68
+ if ( isset( $this->reports[ $type ] ) ) {
69
+ $handler = $this->reports[ $type ]['handler'];
70
+ $data = $handler->get_data( $params );
71
+ wp_send_json_success( $data );
72
+ } else {
73
+ wp_send_json_error();
74
+ }
75
+ }
76
+
77
+ }
v2/App/Controllers/Admin/WDRAjax.php ADDED
@@ -0,0 +1,529 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers\Admin;
4
+
5
+ use WC_Data_Store;
6
+ use Wdr\App\Controllers\Base;
7
+ use Wdr\App\Controllers\Configuration;
8
+ use Wdr\App\Controllers\ManageDiscount;
9
+ use Wdr\App\Controllers\OnSaleShortCode;
10
+ use Wdr\App\Helpers\Helper;
11
+ use Wdr\App\Helpers\Migration;
12
+ use Wdr\App\Helpers\Rule;
13
+ use Wdr\App\Helpers\Woocommerce;
14
+
15
+ if (!defined('ABSPATH')) exit;
16
+
17
+ class WDRAjax extends Base
18
+ {
19
+ public static $wdr_rules_table;
20
+ public $search_result_limit = 20;
21
+
22
+ /**
23
+ * WDRAjax constructor.
24
+ */
25
+ public function __construct()
26
+ {
27
+ parent::__construct();
28
+ self::$wdr_rules_table = (isset(self::$wdr_rules_table) && !empty(self::$wdr_rules_table)) ? self::$wdr_rules_table : WDR_PLUGIN_PREFIX.'rules';
29
+ $this->search_result_limit = apply_filters('advanced_woo_discount_rules_select_search_limit', $this->search_result_limit);
30
+ }
31
+
32
+ /**
33
+ * Ajax Controller
34
+ */
35
+ public function wdr_ajax_requests()
36
+ {
37
+ $result = null;
38
+ $method = $this->input->post('method', '');
39
+ $method_name = 'wdr_ajax_' . $method;
40
+ if (method_exists($this, $method_name)) {
41
+ $result = $this->$method_name();
42
+ }
43
+ wp_send_json_success($result);
44
+ }
45
+
46
+ /**
47
+ * Process v1 to v2 migration
48
+ * */
49
+ public function wdr_ajax_do_v1_v2_migration(){
50
+ $status = \Wdr\App\Helpers\Migration::init();
51
+ wp_send_json_success($status);
52
+ }
53
+
54
+ public function wdr_ajax_rebuild_onsale_list(){
55
+ $shortcode_manager = new OnSaleShortCode();
56
+ $rules = $this->input->post('rules', array());
57
+ $status = $shortcode_manager->rebuildOnSaleList($rules);
58
+ wp_send_json_success($status);
59
+ }
60
+
61
+ /**
62
+ * Process v1 to v2 migration
63
+ * */
64
+ public function wdr_ajax_skip_v1_v2_migration(){
65
+ $migration = new Migration();
66
+ $migration->updateMigrationInfo(array('skipped_migration' => 1));
67
+ wp_send_json_success(true);
68
+ }
69
+
70
+ /**
71
+ * Get discount price for a product
72
+ * */
73
+ public function awdr_get_discount_of_a_product(){
74
+ $product_id = $this->input->post('product_id', '');
75
+ $quantity = $this->input->post('qty', '');
76
+ $product = Woocommerce::getProduct($product_id);
77
+ $price = Woocommerce::getProductPrice($product);
78
+ $custom_price = $this->input->post('custom_price', '');
79
+ $result = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $price, $product, $quantity, $custom_price, 'all');
80
+ if(!empty($result)){
81
+ $result = Helper::formatAllPrices($result);
82
+ }
83
+ wp_send_json_success($result);
84
+ }
85
+
86
+ /**
87
+ * search Product
88
+ * @return array
89
+ * @throws \Exception
90
+ */
91
+ public function wdr_ajax_products()
92
+ {
93
+ $query = $this->input->post('query', '');
94
+ $data_store = WC_Data_Store::load('product');
95
+ $ids = $data_store->search_products($query, '', true, false, $this->search_result_limit);
96
+ return array_values(array_map( function ( $post_id ) {
97
+ return array(
98
+ 'id' => (string) $post_id,
99
+ 'text' => '#' . $post_id . ' ' . get_the_title( $post_id ),
100
+ );
101
+ }, array_filter( $ids ) ));
102
+ }
103
+
104
+ /**
105
+ * search product category
106
+ * @return array
107
+ */
108
+ public function wdr_ajax_product_category()
109
+ {
110
+ $taxonomy = apply_filters('advanced_woo_discount_rules_category_taxonomies', array('product_cat'));
111
+ if(!is_array($taxonomy)){
112
+ $taxonomy = array('product_cat');
113
+ }
114
+ $query = $this->input->post('query', '');
115
+ $terms = get_terms(array('taxonomy' => $taxonomy, 'name__like' => $query, 'hide_empty' => false, 'number' => $this->search_result_limit));
116
+ return array_map(function ($term) {
117
+ return array(
118
+ 'id' => (string)$term->term_id,
119
+ 'text' => $term->name,
120
+ );
121
+ }, $terms);
122
+ }
123
+
124
+ /**
125
+ * search product tags
126
+ * @return array
127
+ */
128
+ public function wdr_ajax_product_tags()
129
+ {
130
+
131
+ $query = $this->input->post('query', '');
132
+ $terms = get_terms(array('taxonomy' => 'product_tag', 'name__like' => $query, 'hide_empty' => false, 'number' => $this->search_result_limit));
133
+ return array_map(function ($term) {
134
+ return array(
135
+ 'id' => (string)$term->term_id,
136
+ 'text' => $term->name,
137
+ );
138
+ }, $terms);
139
+ }
140
+
141
+ /**
142
+ * search taxonomies product
143
+ * @return array
144
+ */
145
+ public function wdr_ajax_product_taxonomies()
146
+ {
147
+
148
+ $query = $this->input->post('query', '');
149
+ $taxonomy_name = $this->input->post('taxonomy', '');
150
+ $terms = get_terms(array('taxonomy' => $taxonomy_name,
151
+ 'name__like' => $query,
152
+ 'hide_empty' => false,
153
+ 'number' => $this->search_result_limit,
154
+ ));
155
+ return array_map(function ($term) {
156
+ return array(
157
+ 'id' => (string)$term->term_id,
158
+ 'text' => $term->name,
159
+ );
160
+ }, $terms);
161
+ }
162
+
163
+ /**
164
+ * search product sku
165
+ * @return array
166
+ */
167
+ public function wdr_ajax_product_sku()
168
+ {
169
+ global $wpdb;
170
+ $query = $this->input->post('query', '');
171
+ $results = $wpdb->get_results("
172
+ SELECT DISTINCT meta_value
173
+ FROM $wpdb->postmeta
174
+ WHERE meta_key = '_sku' AND meta_value like '%$query%'
175
+ ");
176
+ return array_map(function ($result) {
177
+ return array(
178
+ 'id' => (string)$result->meta_value,
179
+ 'text' => 'SKU: ' . $result->meta_value,
180
+ );
181
+ }, $results);
182
+ }
183
+
184
+ /**
185
+ * search product attributes
186
+ * @return array
187
+ */
188
+ public function wdr_ajax_product_attributes()
189
+ {
190
+ global $wc_product_attributes, $wpdb;
191
+ //return $wc_product_attributes;
192
+ $query = $this->input->post('query', '');
193
+ $taxonomies = array_map(function ($item) {
194
+ return "'$item'";
195
+ }, array_keys($wc_product_attributes));
196
+ $taxonomies = implode(', ', $taxonomies);
197
+ $items = $wpdb->get_results("
198
+ SELECT $wpdb->terms.term_id, $wpdb->terms.name, taxonomy
199
+ FROM $wpdb->term_taxonomy INNER JOIN $wpdb->terms USING (term_id)
200
+ WHERE taxonomy in ($taxonomies)
201
+ AND $wpdb->terms.name like '%$query%'
202
+ ");
203
+ return array_map(function ($term) use ($wc_product_attributes) {
204
+ $attribute = $wc_product_attributes[$term->taxonomy]->attribute_label;
205
+ return array(
206
+ 'id' => (string)$term->term_id,
207
+ 'text' => $attribute . ': ' . $term->name,
208
+ );
209
+ }, $items);
210
+ }
211
+
212
+ /**
213
+ * search user list
214
+ * @return array
215
+ */
216
+ public function wdr_ajax_users_list()
217
+ {
218
+ $query = $this->input->post('query', '');
219
+ $query = "*$query*";
220
+ $users = get_users(array('fields' => array('ID', 'user_nicename'), 'search' => $query, 'orderby' => 'user_nicename'));
221
+ return array_map(function ($user) {
222
+ return array(
223
+ 'id' => (string)$user->ID,
224
+ 'text' => $user->user_nicename,
225
+ );
226
+ }, $users);
227
+ }
228
+
229
+ /**
230
+ * search coupon
231
+ * @return array
232
+ */
233
+ public function wdr_ajax_cart_coupon()
234
+ {
235
+ $posts_raw = get_posts(array(
236
+ 'posts_per_page' => '-1',
237
+ 'post_type' => 'shop_coupon',
238
+ 'post_status' => array('publish'),
239
+ 'fields' => 'ids',
240
+ ));
241
+ $items = array_map(function ($post_id) {
242
+ $code = get_the_title($post_id);
243
+ return array(
244
+ 'id' => strtolower($code),
245
+ 'text' => $code
246
+ );
247
+ }, $posts_raw);
248
+ $query = $this->input->post('query');
249
+ if (!empty($query)) {
250
+ $items = array_filter($items, function ($item) use ($query) {
251
+ return stripos($item['text'], $query) !== FALSE;
252
+ });
253
+ }
254
+ return array_values($items);
255
+ }
256
+
257
+ /**
258
+ * save settings
259
+ * @return array
260
+ */
261
+ public function wdr_ajax_save_configuration()
262
+ {
263
+ $save_config = $this->input->post();
264
+ $save_config['modify_price_at_shop_page'] = $this->input->post('modify_price_at_shop_page', 0);
265
+ $save_config['modify_price_at_product_page'] = $this->input->post('modify_price_at_product_page', 0);
266
+ $save_config['modify_price_at_category_page'] = $this->input->post('modify_price_at_category_page', 0);
267
+ $save_config['customize_bulk_table_title'] = $this->input->post('customize_bulk_table_title', 0);
268
+ $save_config['customize_bulk_table_discount'] = $this->input->post('customize_bulk_table_discount', 1);
269
+ $save_config['customize_bulk_table_range'] = $this->input->post('customize_bulk_table_range', 2);
270
+ $save_config['table_title_column'] = $this->input->post('table_title_column', 0);
271
+ $save_config['table_discount_column'] = $this->input->post('table_discount_column', 0);
272
+ $save_config['table_range_column'] = $this->input->post('table_range_column', 0);
273
+ $save_config['awdr_banner_editor'] = (isset($_POST['banner_content'])) ? stripslashes($_POST['banner_content']) : '';
274
+ $save_config['on_sale_badge_html'] = (isset($_POST['on_sale_badge_html'])) ? stripslashes($_POST['on_sale_badge_html']) : '';
275
+ //echo "<pre>"; print_r($save_config); echo "</pre>";
276
+ $save_alert = $this->input->post('customizer_save_alert', 0) ;
277
+ if($save_alert == "1"){
278
+ $save_alert = "alert_in_popup";
279
+ }
280
+ else{
281
+ $save_alert = "alert_in_normal";
282
+ }
283
+ return array('result' => Configuration::saveConfig($save_config), 'save_popup' => $save_alert);
284
+ }
285
+
286
+ /**
287
+ * save rules
288
+ */
289
+ public function wdr_ajax_save_rule()
290
+ {
291
+ $rule_helper = new Rule();
292
+ $post = $this->input->post();
293
+ $post['title'] = (isset($_POST['title'])) ? stripslashes(sanitize_text_field($_POST['title'])) : '';
294
+ $rule_id = $rule_helper->save($post);
295
+ if(isset($rule_id['coupon_exists'])){
296
+ $coupon_message = $rule_id['coupon_exists'];
297
+ wp_send_json( array('coupon_message' => $coupon_message ));
298
+ die;
299
+ }
300
+ $redirect_url = false;
301
+ if (!empty($this->input->post('wdr_save_close', ''))) {
302
+ $redirect_url = admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules')));
303
+ } elseif (empty($this->input->post('edit_rule', ''))) {
304
+ $redirect_url = admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_id)));
305
+ }
306
+ $build_index = array();
307
+ if($rule_id){
308
+ $build_index = OnSaleShortCode::getOnPageReBuildOption($rule_id);
309
+ }
310
+ wp_send_json(array('rule_id' => $rule_id, 'redirect' => $redirect_url, 'build_index' => $build_index));
311
+ }
312
+
313
+ /**
314
+ * Delete rule
315
+ */
316
+ public function wdr_ajax_delete_rule()
317
+ {
318
+ global $wpdb;
319
+ $deleted = 'failed';
320
+ $row_id = $this->input->post('rowid', '');
321
+ if (!empty($row_id)) {
322
+ $deleted = $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
323
+ array(
324
+ 'deleted' => 1
325
+ ),
326
+ array(
327
+ 'id' => $row_id
328
+ ),
329
+ array(
330
+ '%d'
331
+ ),
332
+ array(
333
+ '%d'
334
+ )
335
+ );
336
+ }
337
+ wp_send_json($deleted);
338
+ }
339
+
340
+ /**
341
+ * Duplicate rule
342
+ */
343
+ public function wdr_ajax_duplicate_rule()
344
+ {
345
+ global $wpdb;
346
+ $duplicated_id = 'failed';
347
+ $row_id = $this->input->post('rowid', '');
348
+ if (!empty($row_id)) {
349
+ $rule_title = $wpdb->get_row("SELECT title FROM " . $wpdb->prefix . self::$wdr_rules_table . " WHERE id=" . $row_id);
350
+ $rule_priority = $wpdb->get_row("SELECT max(priority) as priority FROM " . $wpdb->prefix . self::$wdr_rules_table);
351
+ $priority = 1;
352
+ if (!empty($rule_priority) && $rule_priority->priority) {
353
+ $priority = intval($rule_priority->priority) + 1;
354
+ }
355
+ $rule_title = !empty($rule_title) && isset($rule_title->title) ? $rule_title->title : '';
356
+ $sql = "INSERT INTO " . $wpdb->prefix . self::$wdr_rules_table . " (enabled, exclusive, title, priority, filters, conditions, product_adjustments, cart_adjustments, buy_x_get_x_adjustments, buy_x_get_y_adjustments, bulk_adjustments, set_adjustments, other_discounts, date_from, date_to, usage_limits, rule_language, additional, max_discount_sum, advanced_discount_message, discount_type, used_coupons )
357
+ SELECT 0, exclusive, '" . $rule_title . " - copy'," . $priority . ", filters, conditions, product_adjustments, cart_adjustments, buy_x_get_x_adjustments, buy_x_get_y_adjustments, bulk_adjustments, set_adjustments, other_discounts, date_from, date_to, usage_limits, rule_language, additional, max_discount_sum, advanced_discount_message, discount_type, used_coupons
358
+ FROM " . $wpdb->prefix . self::$wdr_rules_table . "
359
+ WHERE id = " . $row_id;
360
+ $wpdb->query($sql);
361
+ $duplicated_id = $wpdb->insert_id;
362
+ }
363
+ wp_send_json($duplicated_id);
364
+ }
365
+
366
+ /**
367
+ * Disable rule
368
+ */
369
+ public function wdr_ajax_manage_status()
370
+ {
371
+ global $wpdb;
372
+ $rule_status = 'failed';
373
+ $row_id = $this->input->post('rowid', '');
374
+ $status = $this->input->post('changeto', 0);
375
+ if (!empty($row_id) && ($status == 1 || $status == 0)) {
376
+ $rule_status = $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
377
+ array(
378
+ 'enabled' => $status
379
+ ),
380
+ array(
381
+ 'id' => $row_id
382
+ ),
383
+ array(
384
+ '%d'
385
+ ),
386
+ array(
387
+ '%d'
388
+ )
389
+ );
390
+ }
391
+ wp_send_json($rule_status);
392
+ }
393
+
394
+ /**
395
+ * bulk action
396
+ * @return bool|mixed
397
+ */
398
+ public function wdr_ajax_bulk_action()
399
+ {
400
+ global $wpdb;
401
+ $action_type = $this->input->post('wdr_bulk_action', '');
402
+ $saved_rules = $this->input->post('saved_rules', '');
403
+ if ($action_type == 'enable') {
404
+ if (!empty($saved_rules) && is_array($saved_rules)) {
405
+ foreach ($saved_rules as $saved_rule_id) {
406
+ $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
407
+ array(
408
+ 'enabled' => 1
409
+ ),
410
+ array(
411
+ 'id' => $saved_rule_id
412
+ ),
413
+ array(
414
+ '%d'
415
+ ),
416
+ array(
417
+ '%d'
418
+ )
419
+ );
420
+ }
421
+ }
422
+ wp_send_json(
423
+ array(
424
+ 'delete' => '',
425
+ 'disable' => '',
426
+ 'enable' => 'enabled'
427
+ )
428
+ );
429
+ } elseif ($action_type == 'disable') {
430
+ if (!empty($saved_rules) && is_array($saved_rules)) {
431
+ foreach ($saved_rules as $saved_rule_id) {
432
+ $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
433
+ array(
434
+ 'enabled' => 0
435
+ ),
436
+ array(
437
+ 'id' => $saved_rule_id
438
+ ),
439
+ array(
440
+ '%d'
441
+ ),
442
+ array(
443
+ '%d'
444
+ )
445
+ );
446
+ }
447
+ }
448
+ wp_send_json(
449
+ array(
450
+ 'delete' => '',
451
+ 'disable' => 'disabled',
452
+ 'enable' => ''
453
+ )
454
+ );
455
+ } elseif ($action_type == 'delete') {
456
+ if (!empty($saved_rules) && is_array($saved_rules)) {
457
+ foreach ($saved_rules as $saved_rule_id) {
458
+ $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
459
+ array(
460
+ 'deleted' => 1
461
+ ),
462
+ array(
463
+ 'id' => $saved_rule_id
464
+ ),
465
+ array(
466
+ '%d'
467
+ ),
468
+ array(
469
+ '%d'
470
+ )
471
+ );
472
+ }
473
+ wp_send_json(
474
+ array(
475
+ 'delete' => 'deleted',
476
+ 'disable' => '',
477
+ 'enable' => ''
478
+ )
479
+ );
480
+ }
481
+ } else {
482
+ return false;
483
+ }
484
+ return $this->input->post();
485
+ }
486
+
487
+ /**
488
+ * drag & drop priority
489
+ */
490
+ public function wdr_ajax_update_priority_order()
491
+ {
492
+ global $wpdb;
493
+ $new_priority_order = $this->input->post('position', '');
494
+ $priority = 1;
495
+ $priority_updated = false;
496
+ foreach ($new_priority_order as $key => $value) {
497
+ $priority_updated = $wpdb->update($wpdb->prefix . self::$wdr_rules_table,
498
+ array(
499
+ 'priority' => $priority
500
+ ),
501
+ array(
502
+ 'id' => $value
503
+ ),
504
+ array(
505
+ '%d'
506
+ ),
507
+ array(
508
+ '%d'
509
+ )
510
+ );
511
+ $priority++;
512
+ }
513
+ wp_send_json($priority_updated);
514
+ }
515
+
516
+ /**
517
+ * Update discounted price when update quantity in product page
518
+ */
519
+ public function wdr_ajax_get_price_html()
520
+ {
521
+ $manage_discount = new ManageDiscount();
522
+ $product = $this->input->post('product_id', '');
523
+ $product_qty = $this->input->post('qty', '');
524
+ $product = self::$woocommerce_helper->getProduct($product);
525
+ $price_html = "<div class='price'></div>";
526
+ $price_html = $manage_discount->getPriceHtml($price_html, $product, $product_qty, true);
527
+ wp_send_json(array('price_html'=>$price_html));
528
+ }
529
+ }
v2/App/Controllers/Base.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ use Wdr\App\Helpers\Helper;
6
+ use Wdr\App\Helpers\Language;
7
+ use Wdr\App\Helpers\Template;
8
+ use Wdr\App\Helpers\Woocommerce;
9
+ use Wdr\App\Helpers\Input;
10
+ use Wdr\App\Models\DBTable;
11
+
12
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
13
+
14
+ class Base
15
+ {
16
+ public static $db, $config, $woocommerce_helper, $template_helper, $language_helper;
17
+ public $default_rule = NULL, $input, $filter_types = array(), $discount_types = array(), $available_conditions = array();
18
+
19
+ /**
20
+ * Base constructor.
21
+ */
22
+ function __construct()
23
+ {
24
+ self::$db = (!empty(self::$db)) ? self::$db : new DBTable();
25
+ self::$config = (empty(self::$config)) ? new Configuration() : self::$config;
26
+ self::$woocommerce_helper = (empty(self::$woocommerce_helper)) ? new Woocommerce() : self::$woocommerce_helper;
27
+ $this->filter_types = (!empty($this->filter_types)) ? $this->filter_types : $this->filtersTypes();
28
+ $this->available_conditions = (!empty($this->available_conditions)) ? $this->available_conditions : $this->getAvailableConditions();
29
+ $this->discount_types = (!empty($this->discount_types)) ? $this->discount_types : $this->discountElements();
30
+ self::$template_helper = (!empty(self::$template_helper)) ? self::$template_helper : new Template();
31
+ self::$language_helper = (!empty(self::$language_helper)) ? self::$language_helper : new Language();
32
+ $this->input = new Input();
33
+ }
34
+
35
+ /**
36
+ * Product filter types
37
+ * @return mixed
38
+ */
39
+ function filtersTypes()
40
+ {
41
+ $this->filter_types['all_products'] = array(
42
+ 'label' => __('All Products', WDR_TEXT_DOMAIN),
43
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
44
+ 'template' => WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Filters/AllProducts.php',
45
+ );
46
+ $this->filter_types['products'] = array(
47
+ 'label' => __('Products', WDR_TEXT_DOMAIN),
48
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
49
+ 'template' => WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Filters/Products.php',
50
+ );
51
+
52
+ $this->filter_types = apply_filters( 'advanced_woo_discount_rules_filters', $this->filter_types);
53
+ return $this->filter_types;
54
+ }
55
+
56
+ /**
57
+ * get template content
58
+ * @return array
59
+ */
60
+ function getFilterTemplatesContent()
61
+ {
62
+ $templates = array_map(function ($item) {
63
+ ob_start();
64
+ if(isset($item['template']) && !empty($item['template'])){
65
+ include $item['template'];
66
+ }
67
+ $content = ob_get_clean();
68
+ return $content;
69
+ }, $this->filter_types);
70
+ return $templates;
71
+ }
72
+
73
+ /**
74
+ * get filter type array
75
+ * @return array
76
+ */
77
+ function getProductFilterTypes()
78
+ {
79
+ $ret = array();
80
+ foreach ($this->filter_types as $filter_key => $filter_item) {
81
+ $group = $filter_item['group'];
82
+ $ret[$group][$filter_key] = $filter_item;
83
+ }
84
+ return $ret;
85
+ }
86
+
87
+ /**
88
+ * availableConditions elements
89
+ * @return array
90
+ */
91
+ public function getAvailableConditions()
92
+ {
93
+ //Read the conditions directory and create condition object
94
+ if (file_exists(WDR_PLUGIN_PATH . 'App/Conditions/')) {
95
+ $conditions_list = array_slice(scandir(WDR_PLUGIN_PATH . 'App/Conditions/'), 2);
96
+ if (!empty($conditions_list)) {
97
+ foreach ($conditions_list as $condition) {
98
+ $class_name = basename($condition, '.php');
99
+ if (!in_array($class_name, array('Base'))) {
100
+ $condition_class_name = 'Wdr\App\Conditions\\' . $class_name;
101
+ if (class_exists($condition_class_name)) {
102
+ $condition_object = new $condition_class_name();
103
+ if ($condition_object instanceof \Wdr\App\Conditions\Base) {
104
+ $rule_name = $condition_object->name();
105
+ if (!empty($rule_name)) {
106
+ $this->available_conditions[$rule_name] = array(
107
+ 'object' => $condition_object,
108
+ 'label' => $condition_object->label,
109
+ 'group' => $condition_object->group,
110
+ 'template' => $condition_object->template,
111
+ 'extra_params' => $condition_object->extra_params,
112
+ );
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ $this->available_conditions = apply_filters( 'advanced_woo_discount_rules_conditions', $this->available_conditions);
121
+ return $this->available_conditions;
122
+ }
123
+
124
+ /**
125
+ * get conditions template content
126
+ * @return array
127
+ */
128
+ public function getConditionsTemplatesContent()
129
+ {
130
+ $condition_templates = array();
131
+ if (!empty($this->available_conditions)) {
132
+ foreach ($this->available_conditions as $item) {
133
+ $extra_params['render_saved_condition'] = false;
134
+ $extra_params = isset($item['extra_params']) && is_array($item['extra_params']) ? $item['extra_params'] : array();
135
+ $extra_params['render_saved_condition'] = false;
136
+ if(isset($item['template']) && !empty($item['template'])){
137
+ $condition_templates[] = self::$template_helper->setData($extra_params)->setPath($item['template'])->render();
138
+ }
139
+ }
140
+ }
141
+ return $condition_templates;
142
+ }
143
+
144
+ /**
145
+ * get filter type array
146
+ * @return array
147
+ */
148
+ public function getProductConditionsTypes()
149
+ {
150
+ $sortedConditionsTypes = $cart_item_condition = $billing = $customer = array();
151
+ $ruleConditionsTypes = array();
152
+ foreach ($this->available_conditions as $condition_key => $condition_item) {
153
+ $group = $condition_item['group'];
154
+ $ruleConditionsTypes[$group][$condition_key] = $condition_item;
155
+ }
156
+ foreach ($ruleConditionsTypes as $key => $options){
157
+ if(!empty($options) && is_array($options)) {
158
+ if ($key === "Cart") {
159
+ $default_first = $options['cart_subtotal'];
160
+ $default_second = $options['cart_items_quantity'];
161
+ $default_thired = $options['cart_coupon'];
162
+ $default_last = $options['cart_line_items_count'];
163
+ unset($options['cart_subtotal'], $options['cart_items_quantity'], $options['cart_coupon'], $options['cart_line_items_count']);
164
+ $options = array(
165
+ 'cart_subtotal' => $default_first,
166
+ 'cart_items_quantity' => $default_second,
167
+ 'cart_coupon' => $default_thired,
168
+ )+$options+array('cart_line_items_count' => $default_last);
169
+ $cart_item_condition[$key] = $options;
170
+ } elseif ($key === "Billing"){
171
+ $billing[$key] = $options;
172
+ } elseif ($key === "Customer"){
173
+ $customer[$key] = $options;
174
+ } else {
175
+ $sortedConditionsTypes[$key] = $options;
176
+ }
177
+ }
178
+ }
179
+ $sortedConditionsTypes = $cart_item_condition+$sortedConditionsTypes+$billing+$customer;
180
+ return $sortedConditionsTypes;
181
+ }
182
+
183
+ /**
184
+ * Available Discount elements
185
+ */
186
+ function discountElements()
187
+ {
188
+ $this->discount_types['wdr_simple_discount'] = array(
189
+ 'class' => '',
190
+ 'label' => __('Product Adjustment', WDR_TEXT_DOMAIN),
191
+ 'group' => __('Simple Discount', WDR_TEXT_DOMAIN),
192
+ 'template' => WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Discounts/simple.php',
193
+ );
194
+ $this->discount_types['wdr_cart_discount'] = array(
195
+ 'class' => '',
196
+ 'label' => __('Cart Adjustment', WDR_TEXT_DOMAIN),
197
+ 'group' => __('Simple Discount', WDR_TEXT_DOMAIN),
198
+ 'template' => WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Discounts/Cart.php',
199
+ );
200
+ $this->discount_types['wdr_bulk_discount'] = array(
201
+ 'class' => '',
202
+ 'label' => __('Bulk Discount', WDR_TEXT_DOMAIN),
203
+ 'group' => __('Bulk Discount', WDR_TEXT_DOMAIN),
204
+ 'template' => WDR_PLUGIN_PATH . 'App/Views/Admin/Rules/Discounts/Bulk.php',
205
+ );
206
+
207
+ $this->discount_types = apply_filters('advanced_woo_discount_rules_adjustment_type', $this->discount_types);
208
+
209
+ return $this->discount_types;
210
+ }
211
+
212
+ /**
213
+ * get discount template content
214
+ * @return array
215
+ */
216
+ function getDiscountTemplatesContent()
217
+ {
218
+ $discount_templates = array_map(function ($item) {
219
+ ob_start();
220
+ if(isset($item['template']) && !empty($item['template'])){
221
+ include $item['template'];
222
+ }
223
+ $content = ob_get_clean();
224
+ return $content;
225
+ }, $this->discount_types);
226
+ return $discount_templates;
227
+ }
228
+
229
+ /**
230
+ * get filter type array
231
+ * @return array
232
+ */
233
+ function getDiscountTypes()
234
+ {
235
+ $processed_discount_types = array();
236
+ foreach ($this->discount_types as $discount_key => $discount_item) {
237
+ $group = $discount_item['group'];
238
+ $processed_discount_types[$group][$discount_key] = $discount_item;
239
+ }
240
+ return $processed_discount_types;
241
+ }
242
+ }
v2/App/Controllers/Configuration.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class Configuration
8
+ {
9
+ /**
10
+ * settings constant
11
+ * @var string
12
+ */
13
+ const DEFAULT_OPTION = 'woo-discount-config-v2';
14
+
15
+ public static $instance;
16
+
17
+ /**
18
+ * Contains all the configuration details
19
+ * @var array
20
+ */
21
+ private static $config = array(), $default_config = array(
22
+ 'modify_price_at_product_page' => 1,//0,1
23
+ 'modify_price_at_category_page' => 1,//0,1
24
+ 'modify_price_at_shop_page' => 1,//0,1
25
+ 'apply_product_discount_to' => 'biggest_discount',//first,biggest_discount,lowest_discount,all
26
+ 'apply_cart_discount_to' => 'biggest_discount',//biggest_discount,lowest_discount,first,all
27
+ 'calculate_discount_from' => 'sale_price',//sale_price,regular_price
28
+ 'show_on_sale_badge' => 'disabled',//when_condition_matches,at_least_has_any_rules,disabled
29
+ 'show_strikeout_on_cart' => 1,//1,0
30
+ 'show_applied_rules_message_on_cart' => 0,//1,0
31
+ 'free_shipping_title' => 'free shipping',
32
+ 'apply_cart_discount_as' => 'fee',//coupon,fee
33
+ 'combine_all_cart_discounts' => 0,//0,1
34
+ 'discount_label_for_combined_discounts' => 'Cart Discount',//show when "combine_all_cart_discounts" is 1
35
+ 'applied_rule_message' => 'Discount <strong>{{title}}</strong> has been applied to your cart.',
36
+ 'you_saved_text' => 'You saved {{total_discount}}',
37
+ 'display_saving_text' => 'disabled',
38
+ 'show_bulk_table' => 0,//0,1
39
+ 'table_column_header' => 1,//0,1
40
+ 'table_title_column' => 1,//0,1
41
+ 'table_discount_column' => 1,//0,1
42
+ 'table_range_column' => 1,//0,1
43
+ 'suppress_other_discount_plugins' => 0,//1,0
44
+ 'show_sale_badge_only_on_condition_passed' => 0,//1,0
45
+ 'position_to_show_bulk_table' => 'woocommerce_before_add_to_cart_form',//woocommerce_product_meta_end,woocommerce_product_meta_start,woocommerce_after_add_to_cart_form,woocommerce_before_add_to_cart_form,woocommerce_after_single_product,woocommerce_before_single_product,woocommerce_after_single_product_summary,woocommerce_before_single_product_summary
46
+ 'position_to_show_discount_bar' => 'woocommerce_before_add_to_cart_form',//woocommerce_product_meta_end,woocommerce_product_meta_start,woocommerce_after_add_to_cart_form,woocommerce_before_add_to_cart_form,woocommerce_after_single_product,woocommerce_before_single_product,woocommerce_after_single_product_summary,woocommerce_before_single_product_summary
47
+ 'customize_bulk_table_title' => 0,
48
+ 'customize_bulk_table_discount' => 2,
49
+ 'customize_bulk_table_range' => 1,
50
+ 'apply_discount_subsequently' => 0, //0,1
51
+ 'show_table_discount_column_value' => 1, //0,1
52
+ 'table_title_column_name' => 'Title', //Title
53
+ 'table_discount_column_name' => 'Discount', //Discount
54
+ 'table_range_column_name' => 'Range', //Range
55
+ 'apply_cart_discount_subsequently' => 0,//1,0
56
+ 'awdr_banner_editer' => 0, //false
57
+ 'display_banner_text' => 0, //0
58
+ 'show_strikeout_when' => 'show_when_matched', //show_after_matched, show_dynamically
59
+ 'disable_coupon_when_rule_applied' => 'run_both', //run_both, disable_coupon, disable_rules
60
+ 'customize_on_sale_badge' => '',
61
+ 'force_override_on_sale_badge' => '',
62
+ 'on_sale_badge_html' => '<span class="onsale">Sale!</span>',
63
+ 'licence_key' => '',
64
+ );
65
+
66
+ /**
67
+ * To create instance
68
+ * */
69
+ public static function getInstance()
70
+ {
71
+ if (!self::$instance)
72
+ {
73
+ self::$instance = new self();
74
+ }
75
+
76
+ return self::$instance;
77
+ }
78
+
79
+ /**
80
+ * Save the configuration
81
+ * @param $data
82
+ * @return bool
83
+ */
84
+ static function saveConfig($data)
85
+ {
86
+ return update_option(self::DEFAULT_OPTION, $data);
87
+ }
88
+
89
+ /**
90
+ * @param $key - what configuration need to get
91
+ * @param string $default - default value if config value not found
92
+ * @return string - configuration value
93
+ */
94
+ function getConfig($key, $default = '')
95
+ {
96
+
97
+ if (empty(self::$config)) {
98
+ $this->setConfig();
99
+ }
100
+ if (isset(self::$config[$key])) {
101
+ return self::$config[$key];
102
+ } elseif (isset(self::$default_config[$key])) {
103
+ //Check config found in default config
104
+ return self::$default_config[$key];
105
+ } else {
106
+ return $default;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Set rule configuration to static variable
112
+ */
113
+ function setConfig()
114
+ {
115
+ self::$config = get_option(self::DEFAULT_OPTION);
116
+ }
117
+ }
v2/App/Controllers/DiscountCalculator.php ADDED
@@ -0,0 +1,842 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ use Wdr\App\Helpers\Helper;
6
+ use Wdr\App\Helpers\Woocommerce;
7
+
8
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
9
+
10
+ class DiscountCalculator extends Base
11
+ {
12
+ public static $rules, $applied_rules = array(), $total_discounts = array(), $cart_adjustments = array(), $price_discount_apply_as_cart_discount = array(), $tax_display_type = NULL;
13
+ public $is_cart = false;
14
+
15
+ /**
16
+ * Initialize the cart calculator with rule list
17
+ * @param $rules
18
+ */
19
+ function __construct($rules)
20
+ {
21
+ parent::__construct();
22
+ self::$rules = $rules;
23
+ }
24
+
25
+ /**
26
+ * calculate price of product
27
+ * @param $product
28
+ * @param $quantity
29
+ * @param bool $is_cart
30
+ * @param bool $ajax_price
31
+ * @return array|bool
32
+ */
33
+ function getProductPriceToDisplay($product, $quantity, $is_cart = false, $ajax_price = false, $cart_item = array())
34
+ {
35
+
36
+ $this->is_cart = $is_cart;
37
+ if (!is_a($product, 'WC_Product')) {
38
+ if (is_integer($product)) {
39
+ $product = self::$woocommerce_helper->getProduct($product);
40
+ } else {
41
+ return false;
42
+ }
43
+ }
44
+ if (!$product) {
45
+ return false;
46
+ }
47
+ return $this->mayApplyPriceDiscount($product, $quantity, $custom_price = 0, $ajax_price, $cart_item, $is_cart);
48
+ }
49
+
50
+ /**
51
+ * get default layout messages by rules to display discount table
52
+ * @param $product
53
+ * @return array
54
+ */
55
+ function getDefaultLayoutMessagesByRules($product)
56
+ {
57
+ $response_ranges = array();
58
+ if ((!empty(self::$rules) && !empty($product))) {
59
+ $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
60
+ if ($calculate_discount_from == 'regular_price') {
61
+ $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
62
+ if (empty($product_price)) {
63
+ $variable_product = self::$woocommerce_helper->productTypeIs($product, 'variable');
64
+ if ($variable_product) {
65
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
66
+ }
67
+ }
68
+ } else {
69
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
70
+ }
71
+
72
+ $language_helper_object = self::$language_helper;
73
+ $discount_calculator = $this;
74
+ foreach (self::$rules as $rule) {
75
+ $rule_id = $rule->getId();
76
+ $hide_bulk_table = apply_filters('advanced_woo_discount_rules_hide_specific_rules_in_bulk_table', false, $rule_id, $rule);
77
+ if ($hide_bulk_table) {
78
+ continue;
79
+ }
80
+ $chosen_languages = $rule->getLanguages();
81
+ if (!empty($chosen_languages)) {
82
+ $current_language = $language_helper_object::getCurrentLanguage();
83
+ if (!in_array($current_language, $chosen_languages)) {
84
+ continue;
85
+ }
86
+ }
87
+ $rule_id = $rule->getId();
88
+ $has_bulk_discount = $rule->hasBulkDiscount();
89
+ if ($has_bulk_discount) {
90
+ if ($rule->isFilterPassed($product, true)) {
91
+ $bulk_adjustments = $rule->getBulkAdjustments();
92
+ if (isset($bulk_adjustments) && !empty($bulk_adjustments) && isset($bulk_adjustments->ranges) && !empty($bulk_adjustments->ranges)) {
93
+ foreach ($bulk_adjustments->ranges as $range) {
94
+ if (isset($range->value) && !empty($range->value)) {
95
+ $discount_type = (isset($range->type) && !empty($range->type)) ? $range->type : 0;
96
+ $from = intval((isset($range->from) && !empty($range->from)) ? $range->from : 0);
97
+ $to = intval((isset($range->to) && !empty($range->to)) ? $range->to : 0);
98
+ if ((empty($to) && empty($from)) || empty($discount_type)) {
99
+ continue;
100
+ } else {
101
+ $discount_price = $rule->calculator($discount_type, $product_price, $range->value);
102
+ $discounted_price = $product_price - $discount_price;
103
+ if ($discounted_price < 0) {
104
+ $discounted_price = 0;
105
+ }
106
+ $discounted_price = $this->mayHaveTax($product, $discounted_price);
107
+ $rule_title = isset($range->label) && !empty($range->label) ? $range->label : $rule->getTitle();
108
+ $discount_value = $range->value;
109
+ $discount_method = 'bulk';
110
+ $this->defaultLayoutRowDataFormation($response_ranges, $from, $to, $rule_id, $discount_method, $discount_type, $discount_value, $discount_price, $discounted_price, $rule_title);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ $response_ranges = apply_filters('advanced_woo_discount_rules_bulk_table_range_based_on_rule', $response_ranges, $rule, $discount_calculator, $product, $product_price);
118
+ }
119
+ }
120
+ $response_ranges = apply_filters('advanced_woo_discount_rules_bulk_table_ranges', $response_ranges, self::$rules, $product);
121
+ if (!empty($response_ranges)) {
122
+ $response_ranges['layout']['type'] = 'default';
123
+ }
124
+ return $response_ranges;
125
+ }
126
+
127
+ /**
128
+ * @param $response_ranges
129
+ * @param $from
130
+ * @param $to
131
+ * @param $rule_id
132
+ * @param $discount_method
133
+ * @param $discount_type
134
+ * @param $discount_value
135
+ * @param $discount_price
136
+ * @param $discounted_price
137
+ * @param $rule_title
138
+ * @param $conditions
139
+ */
140
+ function defaultLayoutRowDataFormation(&$response_ranges, $from, $to, $rule_id, $discount_method, $discount_type, $discount_value, $discount_price, $discounted_price, $rule_title)
141
+ {
142
+ $response_ranges[] = array(
143
+ 'from' => $from,
144
+ 'to' => $to,
145
+ 'rule_id' => $rule_id,
146
+ 'discount_method' => $discount_method,
147
+ 'discount_type' => $discount_type,
148
+ 'discount_value' => $discount_value,
149
+ 'discount_price' => $discount_price,
150
+ 'discounted_price' => $discounted_price,
151
+ 'rule_title' => $rule_title
152
+ );
153
+ }
154
+
155
+ /**
156
+ * get default layout messages by rules to display discount table
157
+ * @param $product
158
+ * @return array
159
+ */
160
+ function getAdvancedLayoutMessagesByRules($product)
161
+ {
162
+ $advanced_layout = array();
163
+ if (!empty(self::$rules) && !empty($product)) {
164
+ $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
165
+ if ($calculate_discount_from == 'regular_price') {
166
+ $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
167
+ if (empty($product_price)) {
168
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
169
+ }
170
+ } else {
171
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
172
+ }
173
+ $language_helper_object = self::$language_helper;
174
+ $discount_calculator = $this;
175
+ foreach (self::$rules as $rule) {
176
+ $discounted_title_text = $rule->getTitle();
177
+ $chosen_languages = $rule->getLanguages();
178
+ if (!empty($chosen_languages)) {
179
+ $current_language = $language_helper_object::getCurrentLanguage();
180
+ if (!in_array($current_language, $chosen_languages)) {
181
+ continue;
182
+ }
183
+ }
184
+ $has_product_discount = $rule->hasProductDiscount();
185
+ $has_bulk_discount = $rule->hasBulkDiscount();
186
+ $has_cart_discount = $rule->hasCartDiscount();
187
+ $skip_rule = $rule->getAdvancedDiscountMessage('display', 0);
188
+ $discount_type = $rule->getRuleDiscountType();
189
+ if (empty($skip_rule)) {
190
+ continue;
191
+ }
192
+ $html_content = $rule->getAdvancedDiscountMessage('badge_text');
193
+ //if ($has_product_discount || $has_bulk_discount || $has_set_discount || $has_cart_discount) {
194
+ if ($rule->isFilterPassed($product, true) && !empty($html_content)) {
195
+ if ($has_product_discount) {
196
+ $product_adjustments = $rule->getProductAdjustments();
197
+ if (is_object($product_adjustments) && !empty($product_adjustments) && !empty($product_adjustments->value)) {
198
+ $discount_method = "product_discount";
199
+ $discount_price = $rule->calculator($product_adjustments->type, $product_price, $product_adjustments->value);
200
+ $value = (isset($product_adjustments->value) && !empty($product_adjustments->value)) ? $product_adjustments->value : 0;
201
+ $badge_bg_color = $rule->getAdvancedDiscountMessage('badge_color_picker', '#ffffff');
202
+ $badge_text_color = $rule->getAdvancedDiscountMessage('badge_text_color_picker', '#000000');
203
+ $this->advancedLayoutTextFormation($advanced_layout, $rule, $product_adjustments->type, $discount_method, $product_price, $value, $discount_price, $discounted_title_text, $html_content, $badge_bg_color, $badge_text_color);
204
+ }
205
+ }
206
+ if ($has_cart_discount) {
207
+ $cart_discount = $rule->getCartAdjustments();
208
+ if (!empty($cart_discount)) {
209
+ if (is_object($cart_discount) && !empty($cart_discount) && !empty($cart_discount->value)) {
210
+ $discount_method = "cart_discount";
211
+ $discount_price = $rule->calculator($cart_discount->type, $product_price, $cart_discount->value);
212
+ $value = (isset($cart_discount->value) && !empty($cart_discount->value)) ? $cart_discount->value : 0;
213
+ $badge_bg_color = $rule->getAdvancedDiscountMessage('badge_color_picker', '#ffffff');
214
+ $badge_text_color = $rule->getAdvancedDiscountMessage('badge_text_color_picker', '#000000');
215
+ $this->advancedLayoutTextFormation($advanced_layout, $rule, $cart_discount->type, $discount_method, $product_price, $value, $discount_price, $discounted_title_text, $html_content, $badge_bg_color, $badge_text_color);
216
+ }
217
+ }
218
+ }
219
+ if ($has_bulk_discount) {
220
+ $bulk_adjustments = $rule->getBulkAdjustments();
221
+ if (isset($bulk_adjustments) && is_object($bulk_adjustments) && !empty($bulk_adjustments) && isset($bulk_adjustments->ranges) && !empty($bulk_adjustments->ranges)) {
222
+ foreach ($bulk_adjustments->ranges as $range) {
223
+ if (isset($range->value) && !empty($range->value)) {
224
+ $min = intval(isset($range->from) ? $range->from : 0);
225
+ $max = intval(isset($range->to) ? $range->to : 0);
226
+ if (empty($min) && empty($max)) {
227
+ continue;
228
+ } else {
229
+ $discount_method = "bulk_discount";
230
+ $discount_type = isset($range->type)? $range->type: 'percentage';
231
+ $discount_price = $rule->calculator($discount_type, $product_price, $range->value);
232
+ $value = (isset($range->value) && !empty($range->value)) ? $range->value : 0;
233
+ $badge_bg_color = $rule->getAdvancedDiscountMessage('badge_color_picker', '#ffffff');
234
+ $badge_text_color = $rule->getAdvancedDiscountMessage('badge_text_color_picker', '#000000');
235
+ $this->advancedLayoutTextFormation($advanced_layout, $rule, $discount_type, $discount_method, $product_price, $value, $discount_price, $discounted_title_text, $html_content, $badge_bg_color, $badge_text_color, $min, $max);
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ if($discount_type == 'wdr_free_shipping' || $discount_type == 'wdr_buy_x_get_x_discount' || $discount_type == 'wdr_buy_x_get_y_discount'){
242
+ $discount_method = "free_shipping";
243
+ $badge_bg_color = $rule->getAdvancedDiscountMessage('badge_color_picker', '#ffffff');
244
+ $badge_text_color = $rule->getAdvancedDiscountMessage('badge_text_color_picker', '#000000');
245
+ $this->advancedLayoutTextFormation($advanced_layout, $rule, 'free_shipping', $discount_method, $product_price, '0', '0', $discounted_title_text, $html_content, $badge_bg_color, $badge_text_color, 0, 0);
246
+ }
247
+ }
248
+ //}
249
+ $advanced_layout = apply_filters('advanced_woo_discount_rules_advance_table_based_on_rule', $advanced_layout, $rule, $discount_calculator, $product, $product_price, $html_content);
250
+ }
251
+ }
252
+ if (!empty($advanced_layout)) {
253
+ $advanced_layout['layout']['type'] = 'advanced';
254
+ }
255
+ return $advanced_layout;
256
+ }
257
+
258
+ /**
259
+ * get advanced message format
260
+ * @param $type
261
+ * @param $product_price
262
+ * @param $value
263
+ * @param $discount_price
264
+ * @param $min
265
+ * @param $advanced_layout
266
+ * @param $rule
267
+ * @param $discounted_title_text
268
+ * @param $html_content
269
+ * @param $badge_bg_color
270
+ * @param $badge_text_color
271
+ * @param $discount_method
272
+ * @param $max
273
+ */
274
+ function advancedLayoutTextFormation(&$advanced_layout, $rule, $type, $discount_method, $product_price, $value, $discount_price, $discounted_title_text, $html_content, $badge_bg_color, $badge_text_color, $min = 0, $max = 0)
275
+ {
276
+ $discount_text = '';
277
+ $discounted_price_text = '';
278
+ switch ($type) {
279
+ case 'fixed_price':
280
+ if (!empty($value)) {
281
+ if($value < 0){
282
+ $value = 0;
283
+ }
284
+ $discount = $product_price - $value;
285
+ $discount_text = Woocommerce::formatPrice($discount);
286
+ $discounted_price_text = Woocommerce::formatPrice($value);
287
+ }
288
+ break;
289
+ case 'fixed_set_price':
290
+ if (!empty($value) && !empty($min)) {
291
+ $discounted_price = $value / $min;
292
+ if($discounted_price < 0){
293
+ $discounted_price = 0;
294
+ }
295
+ $discount = $product_price - $discounted_price;
296
+ $discount_text = Woocommerce::formatPrice($discount);
297
+ $discounted_price_text = Woocommerce::formatPrice($discounted_price);
298
+ }
299
+ break;
300
+ case 'percentage':
301
+ if (!empty($value) && !empty($discount_price)) {
302
+ $discount = $product_price - $discount_price;
303
+ if($discount < 0){
304
+ $discount = 0;
305
+ }
306
+ $discount_text = $value . '%';
307
+ $discounted_price_text = Woocommerce::formatPrice($discount);
308
+ }
309
+ break;
310
+ case 'free_shipping':
311
+ //code is poetry
312
+ break;
313
+ default:
314
+ case 'flat':
315
+ if (!empty($value)) {
316
+ $discount = $product_price - $value;
317
+ if($discount < 0){
318
+ $discount = 0;
319
+ }
320
+ $discount_text = Woocommerce::formatPrice($value);
321
+ $discounted_price_text = Woocommerce::formatPrice($discount);
322
+ }
323
+ break;
324
+ }
325
+ //if (!empty($discount_text) && !empty($discounted_price_text)) {
326
+ $dont_allow_duplicate = true;
327
+ if ($discount_method == "bulk_discount") {
328
+ $searchForReplace = array('{{title}}');//, '{{min_quantity}}', '{{max_quantity}}', '{{discount}}', '{{discounted_price}}'
329
+ $string_to_replace = array($discounted_title_text); //, $min, $max, $discount_text, $discounted_price_text
330
+ $html_content = str_replace($searchForReplace, $string_to_replace, $html_content);
331
+ } elseif ($discount_method == "set_discount") {
332
+ $searchForReplace = array('{{title}}'); //, '{{min_quantity}}', '{{discount}}', '{{discounted_price}}'
333
+ $string_to_replace = array($discounted_title_text);//, $min, $discount_text, $discounted_price_text
334
+ $html_content = str_replace($searchForReplace, $string_to_replace, $html_content);
335
+ $searchForRemove = array('/{{max_quantity}}/');
336
+ $replacements = array('');
337
+ $html_content = preg_replace($searchForRemove, $replacements, $html_content);
338
+ } else if($discount_method == 'free_shipping'){
339
+ $searchForReplace = array('{{title}}');
340
+ $string_to_replace = array($discounted_title_text);
341
+ $html_content = str_replace($searchForReplace, $string_to_replace, $html_content);
342
+ $searchForRemove = array('/{{min_quantity}}/', '/{{max_quantity}}/', '/{{discount}}/', '/{{discounted_price}}/');
343
+ $replacements = array('', '');
344
+ $html_content = preg_replace($searchForRemove, $replacements, $html_content);
345
+ }else {
346
+ $searchForReplace = array('{{title}}');//, '{{discount}}', '{{discounted_price}}'
347
+ $string_to_replace = array($discounted_title_text);//, $discount_text, $discounted_price_text
348
+ $html_content = str_replace($searchForReplace, $string_to_replace, $html_content);
349
+ $searchForRemove = array('/{{min_quantity}}/', '/{{max_quantity}}/');
350
+ $replacements = array('', '');
351
+ $html_content = preg_replace($searchForRemove, $replacements, $html_content);
352
+ }
353
+ if (!empty($advanced_layout)) {
354
+ foreach ($advanced_layout as $layout_options) {
355
+ $check_exists = array($layout_options['badge_text']);
356
+ if (in_array($html_content, $check_exists)) {
357
+ $dont_allow_duplicate = false;
358
+ break;
359
+ }
360
+ }
361
+ }
362
+ if ($dont_allow_duplicate) {
363
+ $advanced_layout[] = array(
364
+ 'badge_bg_color' => $badge_bg_color,
365
+ 'badge_text_color' => $badge_text_color,
366
+ 'badge_text' => $html_content,
367
+ 'rule_id' => $rule->rule->id,
368
+ );
369
+ }
370
+ //}
371
+ }
372
+
373
+ /**
374
+ * check the product has the price discount
375
+ * @param $product
376
+ * @param $quantity
377
+ * @param $custom_price
378
+ * @param $ajax_price
379
+ * @param $is_cart
380
+ * @param $cart_item
381
+ * @return array|bool
382
+ */
383
+ function mayApplyPriceDiscount($product, $quantity, $custom_price = 0, $ajax_price = false, $cart_item = array(), $is_cart=true)
384
+ {
385
+ if (!empty(self::$rules) && !empty($product)) {
386
+ $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
387
+ if (empty($custom_price)) {
388
+ if ($calculate_discount_from == 'regular_price') {
389
+ $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
390
+ } else {
391
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
392
+ }
393
+ } else {
394
+ $product_price = $custom_price;
395
+ }
396
+
397
+ $original_product_price = $product_price;
398
+ $product_price = apply_filters('advanced_woo_discount_rules_product_price_on_before_calculate_discount', $product_price, $product, $quantity, $cart_item);
399
+
400
+ $exclusive_rules = $discounts = $exclude_products = array();
401
+ $cart = self::$woocommerce_helper->getCart();
402
+ $product_id = self::$woocommerce_helper->getProductId($product);
403
+ $language_helper_object = self::$language_helper;
404
+ $apply_rule_to = self::$config->getConfig('apply_product_discount_to', 'biggest_discount');
405
+ $price_display_condition = self::$config->getConfig('show_strikeout_when', 'show_when_matched');
406
+ $apply_discount_subsequently = false;
407
+ $price_as_cart_discount = array();
408
+ foreach (self::$rules as $rule) {
409
+ $discount_type = $rule->getRuleDiscountType();
410
+ if ($ajax_price) {
411
+ if (!$rule->isEnabled()) {
412
+ continue;
413
+ }
414
+ }
415
+ $chosen_languages = $rule->getLanguages();
416
+ if (!empty($chosen_languages)) {
417
+ $current_language = $language_helper_object::getCurrentLanguage();
418
+ if (!in_array($current_language, $chosen_languages)) {
419
+ continue;
420
+ }
421
+ }
422
+ $rule_id = $rule->getId();
423
+
424
+ $has_additional_rules = ($rule->hasProductDiscount() || $rule->hasCartDiscount() || $rule->hasBulkDiscount());
425
+ $has_additional_rules = apply_filters('advanced_woo_discount_rules_has_any_discount', $has_additional_rules, $rule);
426
+ $filter_passed = false;
427
+ $discounted_price = 0;
428
+ if ($has_additional_rules) {
429
+ if ($rule->isFilterPassed($product)) {
430
+ $filter_passed = true;
431
+ if ($rule->hasConditions()) {
432
+ if (!$rule->isCartConditionsPassed($cart)) {
433
+ continue;
434
+ }
435
+ }
436
+ $rule::$set_discounts = $rule::$simple_discounts = $rule::$bulk_discounts = array();
437
+ if ($discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart)) {
438
+ $cart_discounted_price = 0;
439
+ $discount_label = '';
440
+ if(!is_array($discounted_price)){
441
+ $cart_discounted_price = $discounted_price * $quantity;
442
+ }else{
443
+ $discount_label = (isset($discounted_price[0]['label']) && !empty($discounted_price[0]['label'])) ? $discounted_price[0]['label'] : '';
444
+ $discounted_price_array = $discounted_price;
445
+ $discounted_price = (isset($discounted_price[0]['discount_fee']) && !empty($discounted_price[0]['discount_fee'])) ? $discounted_price[0]['discount_fee'] : 0;
446
+ if(isset($discounted_price_array[0]['discount_type'])){
447
+ if($discounted_price_array[0]['discount_type'] != "flat_in_subtotal"){
448
+ $discounted_price = $discounted_price * $quantity;
449
+ }
450
+ }
451
+ }
452
+ if($apply_rule_to == "all"){
453
+ $apply_discount_subsequently = self::$config->getConfig('apply_discount_subsequently', 0);
454
+ }
455
+ if ($apply_discount_subsequently && !empty($apply_discount_subsequently)) {
456
+ if (isset(self::$total_discounts[$rule_id][$product_id]['product_price']) && !empty(self::$total_discounts[$rule_id][$product_id]['product_price'])) {
457
+ $product_price = self::$total_discounts[$rule_id][$product_id]['product_price'];
458
+ } else {
459
+ $product_price = $product_price - $discounted_price;
460
+ self::$total_discounts[$rule_id][$product_id]['product_price'] = $product_price;
461
+ }
462
+ }
463
+ if(!empty($cart_item)) {
464
+ $this_apply_as_cart_rule = false;
465
+ switch ($discount_type) {
466
+ case 'wdr_simple_discount':
467
+ if ($simple_discount = $rule->getProductAdjustments()) {
468
+ if (isset($simple_discount->apply_as_cart_rule) && !empty($simple_discount->apply_as_cart_rule)) {
469
+ $this_apply_as_cart_rule = true;
470
+ $price_as_cart_discount[$rule_id][$product_id] = array(
471
+ 'discount_type' => 'wdr_simple_discount',
472
+ 'discount_label' => $simple_discount->cart_label,
473
+ 'discount_value' => $simple_discount->value,
474
+ 'discounted_price' => $cart_discounted_price,
475
+ 'rule_name' => $rule->getTitle(),
476
+ 'cart_item_key' => isset($cart_item['key']) ? $cart_item['key'] : '',
477
+ 'product_id' => isset($cart_item['product_id']) ? $cart_item['product_id'] : '',
478
+ );
479
+ $discounts[$rule_id] = $discounted_price;
480
+ }
481
+ }
482
+ break;
483
+ case 'wdr_cart_discount':
484
+ if ($cart_discount = $rule->getCartAdjustments()) {
485
+ $this_apply_as_cart_rule = true;
486
+ $price_as_cart_discount[$rule_id][$product_id] = array(
487
+ 'discount_type' => 'wdr_cart_discount',
488
+ 'apply_type' => $cart_discount->type,
489
+ 'discount_label' => $discount_label,
490
+ 'discount_value' => $cart_discount->value,
491
+ 'discounted_price' => $discounted_price,
492
+ 'rule_name' => $rule->getTitle(),
493
+ 'cart_item_key' => isset($cart_item['key']) ? $cart_item['key'] : '',
494
+ 'product_id' => isset($cart_item['product_id']) ? $cart_item['product_id'] : '',
495
+ 'rule_id' => $rule_id,
496
+ );
497
+ $discounts[$rule_id] = (isset($discounted_price_array[0]['discount_fee']) && !empty($discounted_price_array[0]['discount_fee'])) ? $discounted_price_array[0]['discount_fee'] : 0;
498
+ }
499
+ break;
500
+ case 'wdr_bulk_discount':
501
+ if ($bulk_discount = $rule->getBulkAdjustments()) {
502
+ if (isset($bulk_discount->apply_as_cart_rule) && !empty($bulk_discount->apply_as_cart_rule)) {
503
+ $this_apply_as_cart_rule = true;
504
+ $price_as_cart_discount[$rule_id][$product_id] = array(
505
+ 'discount_type' => 'wdr_bulk_discount',
506
+ 'discount_label' => $bulk_discount->cart_label,
507
+ 'discount_value' => 0,
508
+ 'discounted_price' => $cart_discounted_price,
509
+ 'rule_name' => $rule->getTitle(),
510
+ 'cart_item_key' => isset($cart_item['key']) ? $cart_item['key'] : '',
511
+ 'product_id' => isset($cart_item['product_id']) ? $cart_item['product_id'] : '',
512
+ );
513
+ $discounts[$rule_id] = $discounted_price;
514
+ }
515
+ }
516
+ break;
517
+ default:
518
+ $apply_discount_in_cart = apply_filters('advanced_woo_discount_rules_apply_the_discount_as_fee_in_cart', false, $rule);
519
+ if($apply_discount_in_cart === true){
520
+ $this_apply_as_cart_rule = true;
521
+ $price_as_cart_discount = apply_filters('advanced_woo_discount_rules_fee_values', $price_as_cart_discount, $rule, $cart_discounted_price, $product_id, $cart_item);
522
+ $discounts[$rule_id] = $discounted_price;
523
+ }
524
+ break;
525
+ }
526
+ if( $this_apply_as_cart_rule === true){
527
+ continue;
528
+ }
529
+ }
530
+ if($discount_type === 'wdr_cart_discount'){
531
+ continue;
532
+ }
533
+ $set_discounts = $rule::$set_discounts;
534
+ $simple_discounts = $rule::$simple_discounts;
535
+ $bulk_discounts = $rule::$bulk_discounts;
536
+ if ($ajax_price) {
537
+ self::$total_discounts['ajax_product'][$rule_id]['set_discount'] = isset($set_discounts[$product_id]) ? $set_discounts[$product_id] : 0;
538
+ self::$total_discounts['ajax_product'][$rule_id]['bulk_discount'] = isset($bulk_discounts[$product_id]) ? $bulk_discounts[$product_id] : 0;
539
+ self::$total_discounts['ajax_product'][$rule_id]['simple_discount'] = isset($simple_discounts[$product_id]) ? $simple_discounts[$product_id] : 0;
540
+ }else{
541
+ self::$total_discounts[$product_id][$rule_id]['set_discount'] = isset($set_discounts[$product_id]) ? $set_discounts[$product_id] : 0;
542
+ self::$total_discounts[$product_id][$rule_id]['bulk_discount'] = isset($bulk_discounts[$product_id]) ? $bulk_discounts[$product_id] : 0;
543
+ self::$total_discounts[$product_id][$rule_id]['simple_discount'] = isset($simple_discounts[$product_id]) ? $simple_discounts[$product_id] : 0;
544
+ }
545
+ }
546
+ } else {
547
+ $process_discount = apply_filters('advanced_woo_discount_rules_process_discount_for_product_which_do_not_matched_filters', false, $product, $rule, $cart_item);
548
+ if($process_discount){
549
+ $discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart);
550
+ }
551
+ }
552
+ if($discounted_price > 0){
553
+ if ($ajax_price) {
554
+ self::$total_discounts['ajax_product'][$rule_id] = apply_filters('advanced_woo_discount_rules_calculated_discounts_of_each_rule_for_ajax_price', self::$total_discounts['ajax_product'][$rule_id], $product_id, $rule_id, $filter_passed, $cart_item, $is_cart);
555
+ $ajax_discounts[] = $discounted_price;
556
+ }else{
557
+ if(!isset(self::$total_discounts[$product_id][$rule_id])){
558
+ self::$total_discounts[$product_id][$rule_id] = array();
559
+ }
560
+ self::$total_discounts[$product_id][$rule_id] = apply_filters('advanced_woo_discount_rules_calculated_discounts_of_each_rule', self::$total_discounts[$product_id][$rule_id], $product_id, $rule_id, $filter_passed, $cart_item, $is_cart);
561
+ if ($rule->isExclusive()) {
562
+ array_push($exclusive_rules, $rule_id);
563
+ }
564
+ $discounts[$rule_id] = $discounted_price;
565
+ }
566
+ }
567
+ }
568
+ }
569
+ $product_price = $original_product_price;
570
+ if (isset($ajax_discounts) && !empty($ajax_discounts)) {
571
+ $discounted_price = array_sum($ajax_discounts);
572
+ if ($discounted_price < 0) {
573
+ $discounted_price = 0;
574
+ }
575
+ return array(
576
+ 'initial_price' => $product_price,
577
+ 'discounted_price' => $discounted_price,
578
+ 'initial_price_with_tax' => $this->mayHaveTax($product, $product_price),
579
+ 'discounted_price_with_tax' => $this->mayHaveTax($product, $discounted_price),
580
+ 'total_discount_details' => self::$total_discounts['ajax_product'],
581
+ );
582
+ }
583
+ if (empty($discounts)) {
584
+ return false;
585
+ }
586
+ //If exclusive rules is not empty then apply only exclusive rule
587
+
588
+ $rules = $this->pickRule($exclusive_rules, $discounts, $apply_rule_to);
589
+ $discount_price = 0;
590
+ $valid_discounts = array();
591
+ if (isset($rules) && !empty($rules) && !empty($discounts)) {
592
+ foreach ($rules as $rule_id) {
593
+ if(isset(self::$total_discounts[$product_id]) && isset(self::$total_discounts[$product_id][$rule_id])){
594
+ $valid_discounts[$product_id][$rule_id] = self::$total_discounts[$product_id][$rule_id];
595
+ }
596
+ if(!empty($price_as_cart_discount) && isset($price_as_cart_discount[$rule_id])){
597
+ if(isset(self::$price_discount_apply_as_cart_discount[$rule_id])){
598
+ self::$price_discount_apply_as_cart_discount[$rule_id] = array_merge(self::$price_discount_apply_as_cart_discount[$rule_id], $price_as_cart_discount[$rule_id]);
599
+ } else {
600
+ self::$price_discount_apply_as_cart_discount[$rule_id] = $price_as_cart_discount[$rule_id];
601
+ }
602
+ }else{
603
+ if (isset(self::$rules[$rule_id]) && isset($discounts[$rule_id])) {
604
+ if(!empty($discounts[$rule_id])){
605
+ $discount_price += $discounts[$rule_id];
606
+ }
607
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
608
+ }
609
+ }
610
+ }
611
+ }
612
+ if(!empty($valid_discounts)){
613
+ unset(self::$total_discounts[$product_id]);
614
+ self::$total_discounts[$product_id] = $valid_discounts[$product_id];
615
+ }
616
+ $discounted_price = $product_price - $discount_price;
617
+ if ($discounted_price < 0 ) {
618
+ $discounted_price = 0;
619
+ }
620
+ $discount_prices = array(
621
+ 'initial_price' => $product_price,
622
+ 'discounted_price' => $discounted_price,
623
+ 'initial_price_with_tax' => $this->mayHaveTax($product, $product_price),
624
+ 'discounted_price_with_tax' => $this->mayHaveTax($product, $discounted_price),
625
+ 'total_discount_details' => self::$total_discounts,
626
+ 'cart_discount_details' => $this->getCartDiscountPrices($cart, true),
627
+ );
628
+ return apply_filters('advanced_woo_discount_rules_discount_prices_of_product', $discount_prices, $product, $quantity, $cart_item);
629
+ }
630
+ return false;
631
+ }
632
+
633
+ /**
634
+ * Calculate tax for products
635
+ * @param $product
636
+ * @param $price
637
+ * @param $quantity
638
+ * @return float
639
+ */
640
+ function mayHaveTax($product, $price, $quantity = 1)
641
+ {
642
+ if (empty($product) || empty($price) || empty($quantity)) {
643
+ return $price;
644
+ }
645
+ if ($this->is_cart) {
646
+ self::$tax_display_type = get_option('woocommerce_tax_display_cart');
647
+ } else {
648
+ self::$tax_display_type = get_option('woocommerce_tax_display_shop');
649
+ }
650
+ if (self::$tax_display_type === 'excl') {
651
+ return self::$woocommerce_helper->getExcludingTaxPrice($product, $price, $quantity);
652
+ } else {
653
+ return self::$woocommerce_helper->getIncludingTaxPrice($product, $price, $quantity);
654
+ }
655
+ }
656
+
657
+ /**
658
+ * Sale badge display or not
659
+ * @param $product
660
+ * @param $sale_badge
661
+ * @return bool
662
+ */
663
+ function saleBadgeDisplayChecker($product, $sale_badge)
664
+ {
665
+ if (!empty(self::$rules)) {
666
+ $language_helper_object = self::$language_helper;
667
+ foreach (self::$rules as $rule) {
668
+ $chosen_languages = $rule->getLanguages();
669
+ if (!empty($chosen_languages)) {
670
+ $current_language = $language_helper_object::getCurrentLanguage();
671
+ if (!in_array($current_language, $chosen_languages)) {
672
+ continue;
673
+ }
674
+ }
675
+ if ($rule->isFilterPassed($product, $sale_badge)) {
676
+ return true;
677
+ }
678
+ }
679
+ }
680
+ return false;
681
+ }
682
+
683
+ /**
684
+ * calculate the cart discount prices
685
+ * @param $cart
686
+ * @param bool $discount_calculation_call
687
+ * @return array
688
+ */
689
+ function getCartDiscountPrices($cart, $discount_calculation_call = false)
690
+ {
691
+ $cart_discount_arr = array();
692
+ $apply_as_cart_fee_details = self::$price_discount_apply_as_cart_discount;
693
+ if (!empty($apply_as_cart_fee_details) && !empty($cart)) {
694
+ foreach ($apply_as_cart_fee_details as $rule_id => $product_id){
695
+ $discount_value = 0;
696
+ foreach ($product_id as $detail) {
697
+ $discount_value += $detail['discounted_price'];
698
+ $label = (isset($detail['discount_label']) && !empty($detail['discount_label'])) ? $detail['discount_label'] : $detail['rule_name'];
699
+ $value = (isset($detail['discount_value']) && !empty($detail['discount_value'])) ? $detail['discount_value'] : 0;
700
+ }
701
+ self::$cart_adjustments[$rule_id]['cart_discount'] = isset($value) ? $value : '';
702
+ self::$cart_adjustments[$rule_id]['cart_shipping'] = 'no';
703
+ self::$cart_adjustments[$rule_id]['cart_discount_label'] = isset($label) ? $label : '';
704
+ }
705
+ array_push($cart_discount_arr, $apply_as_cart_fee_details);
706
+ if ($discount_calculation_call) {
707
+ return self::$cart_adjustments;
708
+ }
709
+ }
710
+ return $cart_discount_arr;
711
+ }
712
+
713
+ /**
714
+ * check freeshipping if available using cart
715
+ * @param $cart
716
+ * @return array
717
+ */
718
+ public static function getFreeshippingMethod(){
719
+ foreach (self::$rules as $rule) {
720
+ $language_helper_object = self::$language_helper;
721
+ $chosen_languages = $rule->getLanguages();
722
+ if (!empty($chosen_languages)) {
723
+ $current_language = $language_helper_object::getCurrentLanguage();
724
+ if (!in_array($current_language, $chosen_languages)) {
725
+ continue;
726
+ }
727
+ }
728
+ //$rule_id = $rule->getId();
729
+ $discount_type = $rule->getRuleDiscountType();
730
+ $cart_items = self::$woocommerce_helper->getCart();
731
+ $rule_id = $rule->rule->id;
732
+ if ($discount_type == "wdr_free_shipping") {
733
+ foreach ($cart_items as $cart_item){
734
+ //if ($rule->isFilterPassed($cart_item['data'])) {
735
+ if ($rule->hasConditions()) {
736
+ if (!$rule->isCartConditionsPassed($cart_items)) {
737
+ continue;
738
+ }
739
+ }
740
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
741
+ return array('free_shipping'=>1);
742
+ //}
743
+ }
744
+ }
745
+ }
746
+ return array();
747
+ }
748
+
749
+
750
+ /**
751
+ * Pick the applicable rule
752
+ * @param $exclusive_rules
753
+ * @param $matched_rules
754
+ * @param $pick
755
+ * @return array
756
+ */
757
+ function pickRule($exclusive_rules, $matched_rules, $pick)
758
+ {
759
+ $rules = array();
760
+ if (!empty($exclusive_rules)) {
761
+ if (isset($exclusive_rules[0])) {
762
+ $rule_id = $exclusive_rules[0];
763
+ $rules[] = $rule_id;
764
+ if (isset(self::$rules[$rule_id])) {
765
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
766
+ }
767
+ }
768
+ } else {
769
+ switch ($pick) {
770
+ case 'all':
771
+ if (!empty($matched_rules)) {
772
+ foreach ($matched_rules as $rule_id => $discount) {
773
+ $rules[] = $rule_id;
774
+ if (isset(self::$rules[$rule_id])) {
775
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
776
+ }
777
+ }
778
+ }
779
+ break;
780
+ case 'biggest_discount':
781
+ $rule_id_list = array_keys($matched_rules, max($matched_rules));
782
+ $rule_id = reset($rule_id_list);
783
+ $rules[] = $rule_id;
784
+ if (isset(self::$rules[$rule_id])) {
785
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
786
+ }
787
+ break;
788
+ case 'lowest_discount':
789
+ $rule_id_list = array_keys($matched_rules, min($matched_rules));
790
+ $rule_id = reset($rule_id_list);
791
+ $rules[] = $rule_id;
792
+ if (isset(self::$rules[$rule_id])) {
793
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
794
+ }
795
+ break;
796
+ default:
797
+ case 'first':
798
+ reset($matched_rules);
799
+ $rule_id = key($matched_rules);
800
+ $rules[] = $rule_id;
801
+ if (isset(self::$rules[$rule_id])) {
802
+ self::$applied_rules[$rule_id] = self::$rules[$rule_id];
803
+ }
804
+ break;
805
+ }
806
+ }
807
+ return $rules;
808
+ }
809
+
810
+ static public function getUsedCoupons(){
811
+ $all_used_coupons = array();
812
+ foreach (self::$rules as $rule) {
813
+ $used_coupons_per_rule = $rule->hasUsedCoupons();
814
+ if($used_coupons_per_rule && !empty($used_coupons_per_rule)){
815
+ $all_used_coupons = array_merge($all_used_coupons,$used_coupons_per_rule);
816
+ }
817
+ }
818
+ $all_used_coupons = array_unique($all_used_coupons);
819
+ return $all_used_coupons;
820
+ }
821
+
822
+ public static function getFilterBasedCartQuantities($condition_type, $rule){
823
+ $filter_calculate_values = 0;
824
+ $cart_items = self::$woocommerce_helper->getCart(true);
825
+ foreach ($cart_items as $cart_item){
826
+ if(Helper::isCartItemConsideredForCalculation(true, $cart_item, "qty_based_on_filters")){
827
+ if ($rule->isFilterPassed($cart_item['data'])) {
828
+ if($condition_type == 'cart_subtotal'){
829
+ $filter_calculate_values += self::$woocommerce_helper->getCartLineItemSubtotal($cart_item);
830
+ }elseif ($condition_type == 'cart_quantities'){
831
+ $filter_calculate_values += intval((isset($cart_item['quantity'])) ? $cart_item['quantity'] : 0);
832
+ }elseif ($condition_type == 'cart_line_items_count'){
833
+ $filter_calculate_values += 1;
834
+ }else{
835
+ return 0;
836
+ }
837
+ }
838
+ }
839
+ }
840
+ return $filter_calculate_values;
841
+ }
842
+ }
v2/App/Controllers/ManageDiscount.php ADDED
@@ -0,0 +1,1553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ use Wdr\App\Helpers\Helper;
6
+ use Wdr\App\Helpers\Rule;
7
+ use Wdr\App\Helpers\Woocommerce;
8
+ use Wdr\App\Models\DBTable;
9
+
10
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
11
+
12
+ class ManageDiscount extends Base
13
+ {
14
+ public static $available_rules = array(), $calculator, $on_sale_products = array(), $calculated_cart_item_discount = array(), $calculated_cart_discount = array(), $calculated_product_discount = array(), $cart_discounts = array(), $set_total_quantity = 0, $categories_slug = array(), $cart_tot_qty = array();
15
+ public $free_shipping = false, $shipping_obj;
16
+
17
+ /**
18
+ * ManageDiscount constructor.
19
+ */
20
+ function __construct()
21
+ {
22
+ parent::__construct();
23
+ // set available rules to static variables
24
+ $this->getDiscountRules();
25
+ }
26
+
27
+ /**
28
+ * get available rules
29
+ * @return array|object|null
30
+ */
31
+ function getDiscountRules()
32
+ {
33
+ if (empty(self::$available_rules)) {
34
+ $rule_helper = new Rule();
35
+ self::$available_rules = $rule_helper->getAvailableRules($this->getAvailableConditions());
36
+ }
37
+ self::$calculator = new DiscountCalculator(self::$available_rules);
38
+ return self::$available_rules;
39
+ }
40
+
41
+ /**
42
+ * load required styles and scripts needed for site
43
+ */
44
+ function loadAssets()
45
+ {
46
+ $ajax_update_price = self::$config->getConfig('show_strikeout_when', 'show_when_matched');
47
+ wp_enqueue_style(WDR_SLUG . '-customize-table-ui-css', WDR_PLUGIN_URL . 'Assets/Css/customize-table.css');
48
+ wp_enqueue_script('awdr-main', WDR_PLUGIN_URL . 'Assets/Js/site_main.js', array('jquery'));
49
+ $awdr_front_end_script = array(
50
+ 'ajaxurl' => admin_url('admin-ajax.php'),
51
+ 'enable_update_price_with_qty' => $ajax_update_price,
52
+ 'js_init_trigger' => apply_filters('advanced_woo_discount_rules_update_discount_price_init_trigger', ""),
53
+ );
54
+ wp_enqueue_script('awdr-dynamic-price', WDR_PLUGIN_URL . 'Assets/Js/awdr-dynamic-price.js', array('jquery'));
55
+ wp_localize_script('awdr-main', 'awdr_params', $awdr_front_end_script);
56
+ }
57
+
58
+ /**
59
+ * Check the product is in sale
60
+ * @param $on_sale
61
+ * @param $product
62
+ * @return bool
63
+ */
64
+ function isProductInSale($on_sale, $product)
65
+ {
66
+ //Need to check if conditions also passed
67
+ $show_on_sale_badge = self::$config->getConfig('show_on_sale_badge', 'disabled');
68
+ if ($show_on_sale_badge == 'when_condition_matches') {
69
+ if (self::$woocommerce_helper->productTypeIs($product, 'variable')) {
70
+ $price_html = $this->getVariablePriceHtml('', $product);
71
+ } else {
72
+ // pass empty string as first argument in 'woocommerce_get_price_html' method to check if rule has been applied
73
+ // empty result means that price was not change
74
+ $price_html = $this->getPriceHtml('', $product);
75
+ }
76
+ } else {
77
+ $price_html = self::$calculator->saleBadgeDisplayChecker($product, true);
78
+ }
79
+ if($price_html !== '' && $price_html === false){
80
+ $product_id = Woocommerce::getProductId($product);
81
+ self::updateProductsAsOnSale($product_id);
82
+ }
83
+
84
+ return $on_sale OR $price_html;
85
+ }
86
+
87
+ /**
88
+ * Set product is on sale in static variable for avoid multiple run
89
+ * This helps for sale badge text override
90
+ * */
91
+ protected static function updateProductsAsOnSale($product_id){
92
+ if(!empty(self::$on_sale_products)){
93
+ if(!in_array($product_id, self::$on_sale_products)){
94
+ self::$on_sale_products[] = $product_id;
95
+ }
96
+ } else {
97
+ self::$on_sale_products[] = $product_id;
98
+ }
99
+
100
+ }
101
+
102
+ /**
103
+ * Is product on sale through our plugin
104
+ * This helps for sale badge text override
105
+ * */
106
+ protected static function isProductOnSale($product_id){
107
+ if(!in_array($product_id, self::$on_sale_products)){
108
+ return true;
109
+ }
110
+
111
+ return false;
112
+ }
113
+
114
+ /**
115
+ * Replace sale tag text
116
+ * */
117
+ public function replaceSaleTagText($html, $post, $_product){
118
+ $use_sale_badge_customize = apply_filters('advanced_woo_discount_rules_use_sale_badge_customization', false, $post, $_product);
119
+ $product_id = Woocommerce::getProductId($_product);
120
+ if(self::isProductOnSale($product_id) || $use_sale_badge_customize){
121
+ $on_sale_badge_html = self::$config->getConfig('on_sale_badge_html', '<span class="onsale">Sale!</span>');
122
+ $html = __($on_sale_badge_html, WDR_TEXT_DOMAIN);
123
+ $html = apply_filters('advanced_woo_discount_rules_on_sale_badge_html', $html, $post, $_product);
124
+ }
125
+
126
+
127
+ return $html;
128
+ }
129
+
130
+ /**
131
+ * get product sale price
132
+ * @param $value
133
+ * @param $product
134
+ * @return mixed
135
+ */
136
+ function getProductSalePrice($value, $product)
137
+ {
138
+ $prices = self::calculateInitialAndDiscountedPrice($product, 1);
139
+ if (!empty($prices['discounted_price_with_tax']))
140
+ $value = $prices['discounted_price_with_tax'];
141
+ return $value;
142
+ }
143
+
144
+ /**
145
+ * get product regular price
146
+ * @param $value
147
+ * @param $product
148
+ * @return mixed
149
+ */
150
+ function getProductRegularPrice($value, $product)
151
+ {
152
+ $prices = self::calculateInitialAndDiscountedPrice($product, 1);
153
+ if (!empty($prices['initial_price_with_tax']))
154
+ $value = $prices['initial_price_with_tax'];
155
+ return $value;
156
+ }
157
+
158
+ /**
159
+ * Modify the product's price when discount applicable.
160
+ * @param $price_html
161
+ * @param $product
162
+ * @param int $quantity
163
+ * @param boolean $ajax_price
164
+ * @return mixed
165
+ */
166
+ function getPriceHtml($price_html, $product, $quantity = 1, $ajax_price = false)
167
+ {
168
+ if ($ajax_price) {
169
+ $calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
170
+ if ($calculate_discount_from == 'regular_price') {
171
+ $product_price = self::$woocommerce_helper->getProductRegularPrice($product);
172
+ } else {
173
+ $product_price = self::$woocommerce_helper->getProductPrice($product);
174
+ }
175
+ $price_html = self::$woocommerce_helper->formatPrice($product_price);
176
+ $price_html = $price_html.Woocommerce::getProductPriceSuffix($product, $product_price);
177
+ if(!$price_html || empty($product_price) || !$product_price){
178
+ return false;
179
+ }
180
+ }
181
+
182
+ if (empty(self::$available_rules)) {
183
+ return $price_html;
184
+ }
185
+
186
+ $modify_price = apply_filters('advanced_woo_discount_rules_modify_price_html', true, $price_html, $product, $quantity);
187
+ if (!$modify_price) {
188
+ return $price_html;
189
+ }
190
+ if (is_product() && empty(self::$config->getConfig('modify_price_at_product_page', 1))) {
191
+ return $price_html;
192
+ }
193
+ if (is_shop() && empty(self::$config->getConfig('modify_price_at_shop_page', 1))) {
194
+ return $price_html;
195
+ }
196
+ if (is_product_category() && empty(self::$config->getConfig('modify_price_at_category_page', 1))) {
197
+ return $price_html;
198
+ }
199
+
200
+ //Check the product object is from WC_Product Class
201
+ if (is_a($product, 'WC_Product')) {
202
+ if(!$ajax_price) {
203
+ if (self::$woocommerce_helper->productTypeIs($product, array('variable'))) {
204
+ return $price_html;
205
+ }
206
+ }
207
+ $product_id = Woocommerce::getProductId($product);
208
+ //Calculate the product price
209
+ $prices = self::calculateInitialAndDiscountedPrice($product, $quantity, $is_cart = false, $ajax_price);
210
+ if($ajax_price){
211
+ $discount_details = (isset($prices['total_discount_details'])) ? $prices['total_discount_details'] : false;
212
+ if($discount_details) {
213
+ $initial_price = (isset($prices['initial_price_with_tax'])) ? $prices['initial_price_with_tax'] : 0;
214
+ $discounted_price = (isset($prices['discounted_price_with_tax'])) ? $prices['discounted_price_with_tax'] : 0;
215
+ if(empty($initial_price) || empty($discounted_price) || empty($discount_details)){
216
+ return $price_html;
217
+ }
218
+ return $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product, $price_html = true, $quantity, $ajax_price);
219
+ }
220
+ }else {
221
+ if (!$prices) {
222
+ return $price_html;
223
+ }
224
+ self::$calculated_product_discount[$product_id] = $prices;
225
+ $price_html = $this->getStrikeoutPrice($prices['initial_price_with_tax'], $prices['discounted_price_with_tax']);
226
+ $price_html = $price_html.Woocommerce::getProductPriceSuffix($product, $prices['discounted_price_with_tax'], $prices);
227
+ }
228
+
229
+ }
230
+
231
+ return $price_html;
232
+ }
233
+
234
+ /**
235
+ * Modify the product's price before modified by our plugin to adjust sale price.
236
+ *
237
+ * @param $price_html
238
+ * @param $product
239
+ * @param int $quantity
240
+ * @return mixed
241
+ * */
242
+ function getPriceHtmlSalePriceAdjustment($price_html, $product, $quantity = 1)
243
+ {
244
+ $modify_price = apply_filters('advanced_woo_discount_rules_modify_sale_price_adjustment_html', true, $price_html, $product, $quantity);
245
+ if (!$modify_price) {
246
+ return $price_html;
247
+ }
248
+ $excluded_product_type = apply_filters('advanced_woo_discount_rules_exclude_product_type_for_sale_price_strikeout_adjustment', array('variable', 'subscription_variation', 'variable-subscription', 'grouped', 'composite'), $product);
249
+ if (is_array($excluded_product_type) && !empty($excluded_product_type)) {
250
+ if (!Woocommerce::productTypeIs($product, $excluded_product_type)) {
251
+ $sale_price = Woocommerce::getProductSalePrice($product);
252
+ $regular_price = Woocommerce::getProductRegularPrice($product);
253
+ if ($sale_price <= 0) {
254
+ $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? Woocommerce::getExcludingTaxPrice($product, 1, $regular_price) : Woocommerce::getIncludingTaxPrice($product, 1, $regular_price);
255
+ $price_to_display = Woocommerce::formatPrice($regular_price);
256
+ $price_html = (($price_to_display) . Woocommerce::getProductPriceSuffix($product));
257
+ return $price_html;
258
+ }
259
+ }
260
+ }
261
+ return $price_html;
262
+ }
263
+
264
+ /**
265
+ * Remove duplicate strikeout price
266
+ * */
267
+ function removeDuplicateStrikeoutPrice($item_price){
268
+ $del_pattern = "/<del>(.*?)<\/del>/s";
269
+ preg_match($del_pattern, $item_price, $matches);
270
+ $del_content = isset($matches[1]) ? $matches[1] : '';
271
+ $del_content = trim(strip_tags($del_content));
272
+ $ins_pattern = "/<ins>(.*?)<\/ins>/s";
273
+ preg_match($ins_pattern, $item_price, $matches);
274
+ $ins_content_org = isset($matches[1]) ? $matches[1] : '';
275
+ $ins_content = trim(strip_tags($ins_content_org));
276
+
277
+ if(!empty($del_content) && !empty($ins_content)){
278
+ if($del_content == $ins_content){
279
+ $item_price = $ins_content_org;
280
+ }
281
+ }
282
+
283
+ return $item_price;
284
+ }
285
+
286
+ /**
287
+ * Variable product
288
+ *
289
+ * @param $price_html
290
+ * @param $product
291
+ * @param int $quantity
292
+ * @return mixed|string
293
+ */
294
+ function getVariablePriceHtml($price_html, $product, $quantity = 1)
295
+ {
296
+ if (empty(self::$available_rules)) {
297
+ return $price_html;
298
+ }
299
+ $modify_price = apply_filters('advanced_woo_discount_rules_modify_price_html', true, $price_html, $product, $quantity);
300
+ if (!$modify_price) {
301
+ return $price_html;
302
+ }
303
+ $original_prices_list = $discount_prices_lists = array();
304
+ $variations = Woocommerce::getProductChildren($product);
305
+
306
+ if (!empty($variations)) {
307
+ foreach ($variations as $variation_id) {
308
+ if (empty($variation_id)) {
309
+ continue;
310
+ }
311
+ $variation = Woocommerce::getProduct($variation_id);
312
+ $prices = self::calculateInitialAndDiscountedPrice($variation, $quantity);
313
+ if (!isset($prices['initial_price_with_tax']) || !isset($prices['discounted_price_with_tax'])) {
314
+ return $this->removeDuplicateStrikeoutPrice($price_html);
315
+ }
316
+ $original_prices_list[] = $prices['initial_price_with_tax'];
317
+ $discount_prices_lists[] = $prices['discounted_price_with_tax'];
318
+ }
319
+ }
320
+ $discount_prices_lists = array_unique($discount_prices_lists);
321
+ $original_prices_list = array_unique($original_prices_list);
322
+ $min_price = min($discount_prices_lists);
323
+ $max_price = max($discount_prices_lists);
324
+ $min_original_price = min($original_prices_list);
325
+ $max_original_price = max($original_prices_list);
326
+ $price_range_suffix = self::$woocommerce_helper->getProductPriceSuffix($product);
327
+ if ($min_original_price == $max_original_price) {
328
+ $price_html = self::$woocommerce_helper->formatPrice($min_original_price) . $price_range_suffix;
329
+ } elseif ($min_original_price < $max_original_price) {
330
+ $price_html = self::$woocommerce_helper->formatPriceRange($min_original_price, $max_original_price) . $price_range_suffix;
331
+ }
332
+
333
+ if ($min_price == $max_price) {
334
+ $price_html_discounted = self::$woocommerce_helper->formatPrice($min_price) . $price_range_suffix;
335
+ return $this->getStrikeoutPrice($price_html, $price_html_discounted, false, true);
336
+ } elseif ($min_price < $max_price) {
337
+ $price_html_discounted = self::$woocommerce_helper->formatPriceRange($min_price, $max_price) . $price_range_suffix;
338
+ return $this->getStrikeoutPrice($price_html, $price_html_discounted, false, true);
339
+ }
340
+
341
+ return $price_html;
342
+ }
343
+
344
+ /**
345
+ * override original price html with discounted price html
346
+ * @param $original_price
347
+ * @param $discounted_price
348
+ * @param $format_price
349
+ * @param $is_variable_product
350
+ * @return string
351
+ */
352
+ function getStrikeoutPrice($original_price, $discounted_price, $format_price = true, $is_variable_product = false)
353
+ {
354
+ if ($original_price == $discounted_price) {
355
+ if ($format_price) {
356
+ $discounted_price = self::$woocommerce_helper->formatPrice($discounted_price);
357
+ }
358
+ $html = '<ins>' . $discounted_price . '</ins>';
359
+ } else {
360
+ if ($format_price) {
361
+ $original_price = self::$woocommerce_helper->formatPrice($original_price);
362
+ $discounted_price = self::$woocommerce_helper->formatPrice($discounted_price);
363
+ }
364
+ $separator = ($is_variable_product) ? '<br>' : '&nbsp;';
365
+ $html = '<del>' . $original_price . '</del>' . $separator . '<ins>' . $discounted_price . '</ins>';
366
+ }
367
+ return apply_filters('advanced_woo_discount_rules_strikeout_price_html', $html, $original_price, $discounted_price);
368
+ }
369
+
370
+ /**
371
+ * override original price html with set discounted price html
372
+ *
373
+ * @param int $original_price
374
+ * @param array $partially_qualified_sets
375
+ * @param $other_discounts
376
+ * @param $total_discount
377
+ * @param $total_quantity
378
+ * @param $product_obj
379
+ * @param $return_html
380
+ * @param $current_product_quantity
381
+ * @param $discount_operator
382
+ * @param $partially_qualified_set_amount_duplicate
383
+ * @return bool|string
384
+ */
385
+ function getSetStrikeoutPrice($original_price, $partially_qualified_sets, $total_discount, $other_discounts, $total_quantity = 0, $product_obj, $return_html = true, $current_product_quantity, $discount_operator, $partially_qualified_set_amount_duplicate, $multi_strikeout)
386
+ {
387
+ $discounted_price = null;
388
+ if (!empty($original_price) && is_array($partially_qualified_sets) && !empty($partially_qualified_sets) && !empty($total_quantity)) {
389
+ $counts = count($partially_qualified_sets);
390
+ if (!empty($partially_qualified_set_amount_duplicate)) {
391
+ $duplicate_counts = count($partially_qualified_set_amount_duplicate);
392
+ $total_counts = $counts + $duplicate_counts;
393
+ $counts = $total_counts;
394
+ $total_counts_inc = $total_counts;
395
+ $partially_qualified_set = array();
396
+ foreach ($partially_qualified_sets as $amount_key => $quantity_key) {
397
+ $total_counts_inc++;
398
+ $partially_qualified_set[$amount_key . '-' . $total_counts_inc] = $quantity_key;
399
+ }
400
+ $partially_qualified_sets = array_merge($partially_qualified_set_amount_duplicate, $partially_qualified_set);
401
+ }
402
+ asort($partially_qualified_sets);
403
+
404
+ $price_html = '';
405
+ $calculate_product_price = array();
406
+ $applied_quantity = $discounted_price_for_set = $not_applied = $total_applied = 0;
407
+ $calculator = self::$calculator;
408
+ for ($i = 1; $i <= $counts; $i++) {
409
+ if (is_array($partially_qualified_sets) && !empty($partially_qualified_sets)) {
410
+ //get smallest discount quantity
411
+ $min_applied_quantity = min($partially_qualified_sets);
412
+ //calculate next smallest quantity
413
+ if (!empty($applied_quantity)) {
414
+ $last_applied = $min_applied_quantity - $applied_quantity;
415
+ } else {
416
+ $last_applied = $min_applied_quantity;
417
+ }
418
+ $applied_quantity = $min_applied_quantity;
419
+ //calculate total applied quantity
420
+ $total_applied += $last_applied;
421
+ //Discount price calculation for set
422
+ if ($i == 1) {
423
+ $discounted_price = $original_price - $total_discount;
424
+ } else {
425
+ foreach ($partially_qualified_sets as $price => $quantity) {
426
+ if (!empty($partially_qualified_set_amount_duplicate)) {
427
+ $price_array = explode("-", $price);
428
+ $price = $price_array[0];
429
+ }
430
+ $discounted_price_for_set += $price;
431
+ }
432
+ $discounted_price = ($original_price - ($discounted_price_for_set + $other_discounts));
433
+ }
434
+ if ($discounted_price <= 0) {
435
+ $discounted_price = 0;
436
+ }
437
+ $discounted_price = $calculator->mayHaveTax($product_obj, $discounted_price);
438
+ if (!empty($discounted_price)) {
439
+ $calculate_product_price[] = $discounted_price * $last_applied;
440
+ }
441
+ $price_suffix = Woocommerce::getProductPriceSuffix($product_obj, $discounted_price);
442
+ $price_html .= '<del>' . self::$woocommerce_helper->formatPrice($original_price) . '</del>&nbsp;<ins>' . self::$woocommerce_helper->formatPrice($discounted_price) .$price_suffix. '&nbsp;x&nbsp;' . $last_applied . '</ins><br/>';
443
+ //remove calculated set
444
+ $min_applied_range_keys = array_keys($partially_qualified_sets, $min_applied_quantity);
445
+ foreach ($min_applied_range_keys as $key) {
446
+ unset($partially_qualified_sets[$key]);
447
+ }
448
+ }
449
+ }
450
+
451
+ //get original price quantity
452
+ if ($discount_operator === 'total_qty_in_cart') {
453
+ $total_quantity = $current_product_quantity;
454
+ }
455
+ $not_applied = (int)$total_quantity - (int)$total_applied;
456
+
457
+ //calculate original price quantities discount.
458
+ if (!empty($other_discounts)) {
459
+ $discounted_price = $original_price - $other_discounts;
460
+ $discounted_price = $calculator->mayHaveTax($product_obj, $discounted_price);
461
+ if ($discounted_price < 0) {
462
+ $discounted_price = 0;
463
+ }
464
+ $calculate_product_price[] = $discounted_price * $not_applied;
465
+ $price_suffix = Woocommerce::getProductPriceSuffix($product_obj, $discounted_price);
466
+ $price_html .= '<del>' . self::$woocommerce_helper->formatPrice($original_price) . '</del>&nbsp;<ins>' . self::$woocommerce_helper->formatPrice($discounted_price) .$price_suffix. '&nbsp;x&nbsp;' . $not_applied . '</ins>';
467
+ } else {
468
+ $price_suffix = Woocommerce::getProductPriceSuffix($product_obj, $original_price);
469
+ $calculate_product_price[] = $original_price * $not_applied;
470
+ $price_html .= '<ins>' . self::$woocommerce_helper->formatPrice($original_price) .$price_suffix. '&nbsp;x&nbsp;' . $not_applied . '</ins>';
471
+ }
472
+ if ($return_html) {
473
+ return apply_filters('advanced_woo_discount_rules_strikeout_for_set_discount_price_html', $price_html, $original_price, $discounted_price, $total_discount, $other_discounts, $not_applied);
474
+ } else {
475
+ $total_product_price = array_sum($calculate_product_price);
476
+ $single_product_price = $total_product_price / $total_quantity;
477
+
478
+ return $single_product_price;
479
+ }
480
+ }
481
+ return false;
482
+ }
483
+
484
+ /**
485
+ * Apply cart discount fees
486
+ * @param $cart
487
+ */
488
+ function applyCartDiscount($cart)
489
+ {
490
+ $discount_apply_type = self::$config->getConfig('apply_cart_discount_as', 'fee');
491
+ $combine_all_discounts = self::$config->getConfig('combine_all_cart_discounts', 0);
492
+ $total_combined_discounts = 0;
493
+ $apply_as_cart_fee_details = DiscountCalculator::$price_discount_apply_as_cart_discount;
494
+ //echo "<pre>"; print_r($apply_as_cart_fee_details); echo "</pre>"; die;
495
+ $flat_in_subtotal = array();
496
+ if(!empty($apply_as_cart_fee_details)){
497
+ foreach ($apply_as_cart_fee_details as $rule_id => $product_id){
498
+ $discount_value = 0;
499
+ foreach ($product_id as $detail) {
500
+ if($detail['discount_type'] == 'wdr_cart_discount' && $detail['apply_type'] == 'flat_in_subtotal'){
501
+ if(!isset($flat_in_subtotal[$rule_id])){
502
+ $flat_in_subtotal[$rule_id]['value'] = $detail['discounted_price'];
503
+ $flat_in_subtotal[$rule_id]['label'] = $detail['discount_label'];
504
+ }
505
+ }else{
506
+ $discount_value += $detail['discounted_price'];
507
+ $label = (isset($detail['discount_label']) && !empty($detail['discount_label'])) ? $detail['discount_label'] : $detail['rule_name'];
508
+ }
509
+ }
510
+ if ($discount_value > 0) {
511
+ if (empty($combine_all_discounts)) {
512
+ $discount_value = -1 * $discount_value;
513
+ Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $discount_value, $cart));
514
+ }else{
515
+ $total_combined_discounts += $discount_value;
516
+ }
517
+ self::$calculated_cart_discount['discount'][] = array('price' => $discount_value, 'label' => $label);
518
+ }
519
+ }
520
+ }
521
+ if (!empty($flat_in_subtotal)) {
522
+ foreach ($flat_in_subtotal as $discount){
523
+ if(empty($combine_all_discounts)){
524
+ $discount_value = -1 * $discount['value'];
525
+ $label = $discount['label'];
526
+ Woocommerce::addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $discount_value, $cart));
527
+ }else{
528
+ $total_combined_discounts += $discount['value'];
529
+ }
530
+ }
531
+ }
532
+
533
+ //Combine all discounts and add as single discounts
534
+ if (!empty($total_combined_discounts) && !empty($combine_all_discounts)) {
535
+ $label = self::$config->getConfig('discount_label_for_combined_discounts', __('cart discount', WDR_TEXT_DOMAIN));
536
+ if ($discount_apply_type == 'fee') {
537
+ $total_combined_discounts = -1 * $total_combined_discounts;
538
+ self::$woocommerce_helper->addCartFee($cart, apply_filters('advanced_woo_discount_rules_additional_fee_label', $label, $cart), apply_filters('advanced_woo_discount_rules_additional_fee_value', $total_combined_discounts, $cart));
539
+ }
540
+ }
541
+ }
542
+
543
+ /**
544
+ * change the coupon label
545
+ * @param $label
546
+ * @param $coupon
547
+ * @return mixed
548
+ */
549
+ function overwriteCouponLabel($label, $coupon)
550
+ {
551
+ $coupon_code = self::$woocommerce_helper->getCouponCode($coupon);
552
+ if (!empty($coupon_code) && isset(self::$calculated_cart_discount['discount'][$coupon_code]['label'])) {
553
+ return self::$calculated_cart_discount['discount'][$coupon_code]['label'];
554
+ }
555
+ return $label;
556
+ }
557
+
558
+ /**
559
+ * Manage the virtual coupon provided for cart
560
+ * @param $response
561
+ * @param $coupon_code
562
+ * @return array
563
+ */
564
+ function manageVirtualCoupon($response, $coupon_code)
565
+ {
566
+ if (isset(self::$calculated_cart_discount['discount'][$coupon_code])) {
567
+ return array(
568
+ 'id' => 321123 . rand(2, 9),
569
+ 'amount' => self::$calculated_cart_discount['discount'][$coupon_code]['price'],
570
+ 'individual_use' => false,
571
+ 'product_ids' => array(),
572
+ 'exclude_product_ids' => array(),
573
+ 'usage_limit' => '',
574
+ 'usage_limit_per_user' => '',
575
+ 'limit_usage_to_x_items' => '',
576
+ 'usage_count' => '',
577
+ 'expiry_date' => '',
578
+ 'apply_before_tax' => 'yes',
579
+ 'free_shipping' => false,
580
+ 'product_categories' => array(),
581
+ 'exclude_product_categories' => array(),
582
+ 'exclude_sale_items' => false,
583
+ 'minimum_amount' => '',
584
+ 'maximum_amount' => '',
585
+ 'customer_email' => '',
586
+ 'discount_type' => (self::$calculated_cart_discount['discount'][$coupon_code]['type'] == 'flat') ? 'fixed_cart' : 'percent'
587
+ );
588
+ }
589
+ return $response;
590
+ }
591
+
592
+ /**
593
+ * Apply the custom coupon for create coupon condition
594
+ * @param $response
595
+ * @param $coupon_code
596
+ * @return array
597
+ */
598
+ function checkCouponToApply($response, $coupon_code)
599
+ {
600
+ $rule_helper = new Rule();
601
+ $available_coupons = $rule_helper->getAllDynamicCoupons();
602
+ if (in_array($coupon_code, $available_coupons)) {
603
+ $amount = 0;
604
+ $coupon = array(
605
+ 'id' => time() . rand(2, 9),
606
+ 'amount' => $amount,
607
+ 'individual_use' => false,
608
+ 'product_ids' => array(),
609
+ 'exclude_product_ids' => array(),
610
+ 'usage_limit' => '',
611
+ 'usage_limit_per_user' => '',
612
+ 'limit_usage_to_x_items' => '',
613
+ 'usage_count' => '',
614
+ 'expiry_date' => '',
615
+ 'apply_before_tax' => 'yes',
616
+ 'free_shipping' => false,
617
+ 'product_categories' => array(),
618
+ 'exclude_product_categories' => array(),
619
+ 'exclude_sale_items' => false,
620
+ 'minimum_amount' => '',
621
+ 'maximum_amount' => '',
622
+ 'customer_email' => '',
623
+ 'discount_type' => 'percent'
624
+ );
625
+ return $coupon;
626
+ }
627
+ return $response;
628
+ }
629
+
630
+ /**
631
+ * Has third party coupon
632
+ *
633
+ * @return boolean
634
+ * */
635
+ function isCartContainsAnyThirdPartyCoupon(){
636
+ $has_third_party_coupon = false;
637
+ $used_coupons = DiscountCalculator::getUsedCoupons();
638
+ $applied_coupons = Woocommerce::getAppliedCoupons();
639
+ if(!empty($applied_coupons) && is_array($applied_coupons) && !empty($used_coupons)){
640
+ $used_coupons = array_map('\Wdr\App\Helpers\Woocommerce::formatStringToLower', $used_coupons);
641
+ foreach ($applied_coupons as $applied_coupon){
642
+ if(!in_array($applied_coupon, $used_coupons)){
643
+ $has_third_party_coupon = true;
644
+ break;
645
+ }
646
+ }
647
+ }
648
+
649
+ return $has_third_party_coupon;
650
+ }
651
+
652
+ /**
653
+ * Remove third party coupon when rule applied
654
+ *
655
+ * @param $calculated_cart_item_discount array
656
+ * @param $processed_rule boolean
657
+ * */
658
+ function removeThirdPartyCouponIfRequired($calculated_cart_item_discount, $processed_rule){
659
+ if($processed_rule === true){
660
+ $disable_coupon_when_rule_applied = self::$config->getConfig('disable_coupon_when_rule_applied', 'run_both');//run_both, disable_coupon, disable_rules
661
+ if($disable_coupon_when_rule_applied == 'disable_coupon'){
662
+ $used_coupons = DiscountCalculator::getUsedCoupons();
663
+ $applied_coupons = Woocommerce::getAppliedCoupons();
664
+
665
+ if(!empty($applied_coupons) && is_array($applied_coupons)){
666
+ if(!empty($used_coupons)){
667
+ $used_coupons = array_map('\Wdr\App\Helpers\Woocommerce::formatStringToLower', $used_coupons);
668
+ }
669
+ foreach ($applied_coupons as $applied_coupon){
670
+ if(empty($used_coupons) || !in_array($applied_coupon, $used_coupons)){
671
+ $this->removeAppliedCoupon($applied_coupon);
672
+ }
673
+ }
674
+ }
675
+ }
676
+ }
677
+ }
678
+
679
+ /**
680
+ * Remove applied coupon
681
+ *
682
+ * @param $coupon_code string
683
+ * */
684
+ function removeAppliedCoupon($coupon_code){
685
+ $msg = sprintf(__('Sorry, it is not possible to apply coupon <b>"%s"</b> as you already have a discount applied in cart.', WDR_TEXT_DOMAIN), $coupon_code);
686
+
687
+ $msg = apply_filters('advanced_woo_discount_rules_notice_on_remove_coupon_while_having_a_discount', $msg, $coupon_code);
688
+
689
+ //Remove message: Coupon code applied successfully.
690
+ $this->removeCouponAppliedMessage();
691
+
692
+ //Display coupon cannot apply message in cart and checkout
693
+ add_action('woocommerce_before_cart', function() use ($msg, $coupon_code){
694
+ Woocommerce::printNotice( $msg, 'notice' );
695
+ Woocommerce::remove_coupon($coupon_code);
696
+ }, 10);
697
+ add_action('woocommerce_before_checkout_form', function() use ($msg, $coupon_code){
698
+ Woocommerce::printNotice( $msg, 'notice' );
699
+ Woocommerce::remove_coupon($coupon_code);
700
+ }, 10);
701
+ }
702
+
703
+ /**
704
+ * Remove message: Coupon code applied successfully.
705
+ * */
706
+ function removeCouponAppliedMessage(){
707
+ $msg = __( 'Coupon code applied successfully.', 'woocommerce' );
708
+ $msg = apply_filters('advanced_woo_discount_rules_remove_coupon_applied_message_text', $msg);
709
+ Woocommerce::removeSpecificNoticeFromSession($msg);
710
+ }
711
+
712
+ /**
713
+ * Do apply discounts
714
+ *
715
+ * @return boolean
716
+ * */
717
+ function doApplyDiscount(){
718
+ $run_rule = true;
719
+ $disable_coupon_when_rule_applied = self::$config->getConfig('disable_coupon_when_rule_applied', 'run_both');//run_both, disable_coupon, disable_rules
720
+ if($disable_coupon_when_rule_applied == 'disable_rules'){
721
+ $has_third_party_coupon = $this->isCartContainsAnyThirdPartyCoupon();
722
+ if($has_third_party_coupon === true){
723
+ $run_rule = false;
724
+ }
725
+ }
726
+
727
+ return apply_filters('advanced_woo_discount_rules_run_discount_rules', $run_rule);
728
+ }
729
+
730
+ /**
731
+ * Apply discount for the products in cart
732
+ * @param $cart_object
733
+ * @return boolean
734
+ */
735
+ function applyCartProductDiscount($cart_object)
736
+ {
737
+ remove_action('woocommerce_cart_calculate_fees', array($this, 'applyCartDiscount'));
738
+ $do_apply_discount = $this->doApplyDiscount();
739
+ if($do_apply_discount){
740
+ $this->calculateCartPageDiscounts();
741
+ $processed_rule = false;
742
+ if (!empty(self::$calculated_cart_item_discount)) {
743
+ if (isset($cart_object->cart_contents) && !empty($cart_object->cart_contents)) {
744
+ foreach ($cart_object->cart_contents as $key => $cart_item) {
745
+ if (array_key_exists($key, self::$calculated_cart_item_discount)) {
746
+ $processed_rule = true;
747
+ $product_id = isset($cart_item['product_id']) ? $cart_item['product_id'] : 0;
748
+ if (empty($product_id)) {
749
+ return false;
750
+ }
751
+ if (isset($cart_item['variation_id']) && !empty($cart_item['variation_id'])) {
752
+ $product_id = $cart_item['variation_id'];
753
+ }
754
+ $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
755
+ $item_quantity = isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
756
+ //product price
757
+ $initial_price = self::$calculated_cart_item_discount[$key]['initial_price_with_tax'];
758
+ $discounted_price = self::$calculated_cart_item_discount[$key]['discounted_price_with_tax'];
759
+ $calculator = self::$calculator;
760
+ $total_discounts = $calculator::$total_discounts;
761
+ //get discount details per product
762
+ $discount_details = (isset($total_discounts[$product_id])) ? $total_discounts[$product_id] : array();
763
+ $item_price = $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product_obj, $price_html = false, $item_quantity);
764
+ if ($item_price) {
765
+ $price = $item_price;
766
+ } else {
767
+ $price = self::$calculated_cart_item_discount[$key]['discounted_price'];
768
+ }
769
+ $price = apply_filters('advanced_woo_discount_rules_discounted_price_of_cart_item', $price, $cart_item, $cart_object, self::$calculated_cart_item_discount[$key]);
770
+
771
+ self::$woocommerce_helper->setCartProductPrice($product_obj, $price);
772
+
773
+ }
774
+ }
775
+ }
776
+ }
777
+
778
+ // Disable third party coupon when rule applied
779
+ $this->removeThirdPartyCouponIfRequired(self::$calculated_cart_item_discount, $processed_rule);
780
+
781
+ do_action('advanced_woo_discount_rules_after_apply_discount', $cart_object, self::$calculated_cart_item_discount);
782
+ }
783
+ add_action('woocommerce_cart_calculate_fees', array($this, 'applyCartDiscount'));
784
+ }
785
+
786
+ /**
787
+ * Calculate cart discounts
788
+ * @return bool
789
+ */
790
+ function calculateCartPageDiscounts()
791
+ {
792
+ $cart_items = self::$woocommerce_helper->getCart();
793
+ if (!empty($cart_items)) {
794
+ foreach ($cart_items as $cart_key => $cart_item) {
795
+ $product_id = self::$woocommerce_helper->getProductId(isset($cart_item['data']) ? $cart_item['data'] : $cart_item);
796
+ $product = self::$woocommerce_helper->getProductFromCartItem($cart_item, $product_id);
797
+ $quantity = $cart_item['quantity'];
798
+ $calculate_discount_for_item = apply_filters('advanced_woo_discount_rules_calculate_discount_for_cart_item', true, $cart_item);
799
+ if($calculate_discount_for_item){
800
+ $prices = self::calculateInitialAndDiscountedPrice($product, $quantity, true, false, $cart_item);
801
+ if ($prices) {
802
+ //add the cart quantity
803
+ //Here discounts are calculated for per item
804
+ $prices['cart_quantity'] = $quantity;
805
+ $prices['product_id'] = $product_id;
806
+ $apply_discount = $this->didAppliedDiscountAlready($cart_key, $prices);
807
+ if ($apply_discount) {
808
+ self::$calculated_cart_item_discount[$cart_key] = apply_filters('advanced_woo_discount_rules_cart_item_discount_prices', $prices, $cart_item, $product);
809
+ }
810
+ }
811
+ }
812
+
813
+ }
814
+ }
815
+ return true;
816
+ }
817
+
818
+ /**
819
+ * Did applied discount already
820
+ *
821
+ * @param $cart_key string
822
+ * @param $prices array
823
+ * @return boolean
824
+ * */
825
+ public function didAppliedDiscountAlready($cart_key, $prices)
826
+ {
827
+ $apply_discount = true;
828
+ if (isset(self::$calculated_cart_item_discount[$cart_key])) {
829
+ if (isset(self::$calculated_cart_item_discount[$cart_key]['discounted_price'])) {
830
+ if (self::$calculated_cart_item_discount[$cart_key]['discounted_price'] > $prices['discounted_price']) {
831
+ $apply_discount = false;
832
+ }
833
+ }
834
+ }
835
+ return apply_filters('advanced_woo_discount_rules_did_discount_applied_already', $apply_discount, self::$calculated_cart_item_discount, $cart_key, $prices);
836
+ }
837
+
838
+ /**
839
+ * Show the bulk table discount message
840
+ */
841
+ function showBulkTableInPosition()
842
+ {
843
+ global $product;
844
+ if (!empty($product)) {
845
+ $bulk_discounts_ranges = self::$calculator->getDefaultLayoutMessagesByRules($product);
846
+ $override_path = get_theme_file_path('advanced_woo_discount_rules/discount_table.php');
847
+ $bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
848
+ if (file_exists($override_path)) {
849
+ $bulk_table_template_path = $override_path;
850
+ }
851
+ self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper, 'base' => $this))->display();
852
+ }
853
+ }
854
+
855
+ /**
856
+ * Show the advanced table discount message
857
+ */
858
+ function showAdvancedTableInPosition()
859
+ {
860
+ global $product;
861
+ if (!empty($product)) {
862
+ $bulk_discounts_ranges = self::$calculator->getAdvancedLayoutMessagesByRules($product);
863
+ $bulk_table_template_path = WDR_PLUGIN_PATH . 'App/Views/Templates/discount_table.php';
864
+ self::$template_helper->setPath($bulk_table_template_path)->setData(array('ranges' => $bulk_discounts_ranges, 'woocommerce' => self::$woocommerce_helper))->display();
865
+ }
866
+ }
867
+
868
+ /**
869
+ * save discounts of order for future
870
+ *
871
+ * @param $order_id
872
+ * @param $items
873
+ * @return bool
874
+ */
875
+ function orderItemsSaved($order_id, $items)
876
+ {
877
+ $model = new DBTable();
878
+ $applied_rules = array();
879
+ if (!empty(self::$calculated_cart_item_discount)) {
880
+ foreach (self::$calculated_cart_item_discount as $discount) {
881
+ $product_id = isset($discount['product_id']) ? $discount['product_id'] : 0;
882
+ if (empty($product_id)) {
883
+ return false;
884
+ }
885
+ $initial_price = floatval(isset($discount['initial_price_with_tax']) ? $discount['initial_price_with_tax'] : 0);
886
+ $discounted_price = floatval(isset($discount['discounted_price_with_tax']) ? $discount['discounted_price_with_tax'] : 0);
887
+ $cart_quantity = floatval(isset($discount['cart_quantity']) ? $discount['cart_quantity'] : 0);
888
+ $total_discount_details = isset($discount['total_discount_details']) ? $discount['total_discount_details'] : array();
889
+ $cart_discount_details = isset($discount['cart_discount_details']) ? $discount['cart_discount_details'] : array();
890
+ if (!empty($total_discount_details)) {
891
+ $save_order_item_discounts_array = $total_discount_details[$product_id];
892
+ } else {
893
+ $save_order_item_discounts_array = $cart_discount_details;
894
+ }
895
+ if (!empty($save_order_item_discounts_array)) {
896
+ foreach ($save_order_item_discounts_array as $key => $value) {
897
+ $rule_id = $key;
898
+ $applied_rules[] = $rule_id;
899
+ $cart_discount = isset($cart_discount_details[$rule_id]['cart_discount']) ? $cart_discount_details[$rule_id]['cart_discount'] : '0';
900
+ $cart_shipping = (isset($cart_discount_details[$rule_id]['cart_shipping']) && !empty($cart_discount_details[$rule_id]['cart_shipping'])) ? $cart_discount_details[$rule_id]['cart_shipping'] : 'no';
901
+ $cart_discount_label = isset($cart_discount_details[$rule_id]['cart_discount_label']) ? $cart_discount_details[$rule_id]['cart_discount_label'] : '';
902
+ $simple_discount = isset($value['simple_discount']) ? $value['simple_discount'] : 0;
903
+ $bulk_discount = isset($value['bulk_discount']) ? $value['bulk_discount'] : 0;
904
+ $set_discount = isset($value['set_discount']['discount_value']) ? $value['set_discount']['discount_value'] : 0;
905
+ $discount_price = $simple_discount + $bulk_discount + $set_discount;
906
+ if ($discount_price < 0) {
907
+ $discount_price = 0;
908
+ }
909
+ $model::saveOrderItemDiscounts($order_id, $product_id, $initial_price, $discounted_price, $discount_price, $cart_quantity, $rule_id, $simple_discount, $bulk_discount, $set_discount, $cart_discount, $cart_discount_label, $cart_shipping);
910
+ }
911
+ if (!empty($cart_discount_details)) {
912
+ foreach ($cart_discount_details as $key => $value) {
913
+ if (!in_array($key, $applied_rules)) {
914
+ $rule_id = $key;
915
+ $cart_discount = isset($cart_discount_details[$rule_id]['cart_discount']) ? $cart_discount_details[$rule_id]['cart_discount'] : '';
916
+ $cart_shipping = (isset($cart_discount_details[$rule_id]['cart_shipping']) && !empty($cart_discount_details[$rule_id]['cart_shipping'])) ? $cart_discount_details[$rule_id]['cart_shipping'] : 'no';
917
+ $cart_discount_label = isset($cart_discount_details[$rule_id]['cart_discount_label']) ? $cart_discount_details[$rule_id]['cart_discount_label'] : '';
918
+ $model::saveOrderItemDiscounts($order_id, 0, 0, $discount_price, 0, 0, $rule_id, $simple_discount, $bulk_discount, $set_discount, $cart_discount, $cart_discount_label, $cart_shipping);
919
+ }
920
+ }
921
+ }
922
+ }
923
+ }
924
+ } else {
925
+ $cart = self::$woocommerce_helper->getCart();
926
+ $cart_discount_details = self::$calculator->getCartDiscountPrices($cart, true);
927
+ $simple_discount = $bulk_discount = $set_discount = $discount_price = 0;
928
+ foreach ($cart_discount_details as $key => $value) {
929
+ $rule_id = $key;
930
+ $cart_discount = isset($cart_discount_details[$rule_id]['cart_discount']) ? $cart_discount_details[$rule_id]['cart_discount'] : '';
931
+ $cart_shipping = (isset($cart_discount_details[$rule_id]['cart_shipping']) && !empty($cart_discount_details[$rule_id]['cart_shipping'])) ? $cart_discount_details[$rule_id]['cart_shipping'] : 'no';
932
+ $cart_discount_label = isset($cart_discount_details[$rule_id]['cart_discount_label']) ? $cart_discount_details[$rule_id]['cart_discount_label'] : '';
933
+ $model::saveOrderItemDiscounts($order_id, 0, 0, $discount_price, 0, 0, $rule_id, $simple_discount, $bulk_discount, $set_discount, $cart_discount, $cart_discount_label, $cart_shipping);
934
+ }
935
+ }
936
+ $calc = self::$calculator;
937
+ $applied_rules = $calc::$applied_rules;
938
+ if (!empty($applied_rules)) {
939
+ foreach ($applied_rules as $rule) {
940
+ $used_limits = intval($rule->getUsedLimits()) + 1;
941
+ $model::updateRuleUsedCount($rule->getId(), $used_limits);
942
+ }
943
+ }
944
+ if (!empty(self::$calculated_cart_discount)) {
945
+ if (isset(self::$calculated_cart_discount["discount"]) && !empty(self::$calculated_cart_discount["discount"])) {
946
+ $discount_details = json_encode(self::$calculated_cart_discount["discount"]);
947
+ $free_shipping = 'no';
948
+ self::$calculated_cart_discount["free_shipping"] = apply_filters('advanced_woo_discount_rules_isset_free_shipping','no');
949
+ if (isset(self::$calculated_cart_discount["free_shipping"]) && self::$calculated_cart_discount["free_shipping"] == 'yes') {
950
+ $order = self::$woocommerce_helper->getOrder($order_id);
951
+ if (!empty($order)) {
952
+ if (self::$woocommerce_helper->orderHasShippingMethod($order, 'wdr_free_shipping')) {
953
+ $free_shipping = 'yes';
954
+ }
955
+ }
956
+ }
957
+ $model::saveOrderDiscounts($order_id, $free_shipping, $discount_details);
958
+ }
959
+ }
960
+ }
961
+
962
+ /**
963
+ * Show the discount promotion message
964
+ */
965
+ function showAppliedRulesMessages()
966
+ {
967
+ $message = self::$config->getConfig('applied_rule_message', 'Discount <strong>"{{title}}"</strong> has been applied to your cart.');
968
+ $calc = self::$calculator;
969
+ $applied_rules = $calc::$applied_rules;
970
+ if (!empty($applied_rules)) {
971
+ foreach ($applied_rules as $rule) {
972
+ $title = $rule->getTitle();
973
+ $message_to_display = str_replace('{{title}}', $title, $message);
974
+ $message_to_display = apply_filters('advanced_woo_discount_rules_message_to_display_when_rules_applied', $message_to_display, $rule);
975
+ self::$woocommerce_helper->printNotice($message_to_display, 'success');
976
+ }
977
+ }
978
+ }
979
+
980
+ /**
981
+ * Display promotional message in check out while processing order review
982
+ * */
983
+ public function displayPromotionMessagesInCheckout(){
984
+ echo "<div id='awdr_checkout_promotion_messages_data'>";
985
+ $this->showAppliedRulesMessages();
986
+ echo "</div>";
987
+ echo "<script>";
988
+ echo "jQuery('#awdr_checkout_promotion_messages').html(jQuery('#awdr_checkout_promotion_messages_data').html());jQuery('#awdr_checkout_promotion_messages_data').remove()";
989
+ echo "</script>";
990
+ }
991
+
992
+ /**
993
+ * Load outer div for displaying promotional message in check out
994
+ * */
995
+ public function displayPromotionMessagesInCheckoutContainer(){
996
+ echo "<div id='awdr_checkout_promotion_messages'>";
997
+ echo "</div>";
998
+ }
999
+
1000
+ /**
1001
+ * Show the modified price on cart
1002
+ * @param $item_price
1003
+ * @param $cart_item
1004
+ * @param $cart_item_key
1005
+ * @return mixed|void
1006
+ */
1007
+ function getCartProductPriceHtml($item_price, $cart_item, $cart_item_key)
1008
+ {
1009
+ $original_price_html = $item_price;
1010
+ if (isset(self::$calculated_cart_item_discount[$cart_item_key])) {
1011
+ $discounted_price = self::$calculated_cart_item_discount[$cart_item_key]['discounted_price_with_tax'];
1012
+ $show_strikeout_on_cart = self::$config->getConfig('show_strikeout_on_cart', 1);
1013
+ if (!empty($show_strikeout_on_cart)) {
1014
+ $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
1015
+ $cart_item_qty = isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
1016
+ $product_id = self::$woocommerce_helper->getProductId($product_obj);
1017
+ //product price
1018
+ $initial_price = self::$calculated_cart_item_discount[$cart_item_key]['initial_price_with_tax'];
1019
+ $calculator = self::$calculator;
1020
+ $total_discounts = $calculator::$total_discounts;
1021
+ //get discount details per product
1022
+ $discount_details = (isset($total_discounts[$product_id])) ? $total_discounts[$product_id] : array();
1023
+ $price = $this->getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product_obj, $price_html = true, $cart_item_qty);
1024
+ if ($price) {
1025
+ $item_price = $price;
1026
+ } else {
1027
+ $item_price = $this->getStrikeoutPrice($initial_price, $discounted_price);
1028
+ }
1029
+ } else {
1030
+ $item_price = self::$woocommerce_helper->formatPrice($discounted_price);
1031
+ }
1032
+ }
1033
+ return apply_filters('advanced_woo_discount_rules_cart_strikeout_price_html', $item_price, $original_price_html, $cart_item, $cart_item_key);
1034
+ }
1035
+
1036
+ /**
1037
+ * Show the modified price on cart
1038
+ * @param $item_subtotal_price
1039
+ * @param $cart_item
1040
+ * @param $cart_item_key
1041
+ * @return string
1042
+ */
1043
+ function getCartProductSubtotalPriceHtml($item_subtotal_price, $cart_item, $cart_item_key)
1044
+ {
1045
+ if (isset(self::$calculated_cart_item_discount[$cart_item_key]) && !empty(self::$calculated_cart_item_discount[$cart_item_key])) {
1046
+ $discount = $this->getDiscountPerItem(self::$calculated_cart_item_discount[$cart_item_key]);
1047
+ if($discount > 0){
1048
+ $total_discount = self::$woocommerce_helper->formatPrice($discount);
1049
+ $subtotal_additional_text = '<br>' . $this->getYouSavedText($total_discount);
1050
+ $item_subtotal_price .= apply_filters('advanced_woo_discount_rules_line_item_subtotal_saved_text', $subtotal_additional_text, $total_discount, $discount);
1051
+ }
1052
+ }
1053
+ return $item_subtotal_price;
1054
+ }
1055
+
1056
+ /**
1057
+ * get You saved text
1058
+ * @param $discount
1059
+ * @return string|null
1060
+ */
1061
+ function getYouSavedText($discount)
1062
+ {
1063
+ if (!empty($discount)) {
1064
+ $text = self::$config->getConfig('you_saved_text');
1065
+ $message = str_replace('{{total_discount}}', $discount, $text);
1066
+ return '<div class="awdr-you-saved-text" style="color: green">' . $message . '</div>';
1067
+ }
1068
+ return NULL;
1069
+ }
1070
+
1071
+ /**
1072
+ * Get the discount per item
1073
+ * @param $discount_details
1074
+ * @return float|int
1075
+ */
1076
+ function getDiscountPerItem($discount_details)
1077
+ {
1078
+ $discounted_price = isset($discount_details['discounted_price_with_tax']) ? $discount_details['discounted_price_with_tax'] : 0;
1079
+ $initial_price = isset($discount_details['initial_price_with_tax']) ? $discount_details['initial_price_with_tax'] : 0;
1080
+ $cart_quantity = isset($discount_details['cart_quantity']) ? $discount_details['cart_quantity'] : 0;
1081
+ $total_discount_per_quantity = $initial_price - $discounted_price;
1082
+ if ($discounted_price >= 0 && $total_discount_per_quantity > 0) {
1083
+ if (empty($total_discount_per_quantity)) {
1084
+ $total_discount_per_quantity = $initial_price;
1085
+ }
1086
+ $total_discount_per_quantity = $total_discount_per_quantity * $cart_quantity;
1087
+ return $total_discount_per_quantity;
1088
+ }
1089
+ return 0;
1090
+ }
1091
+
1092
+ /**
1093
+ * Show the modified price on cart
1094
+ * @param $cart_total_price
1095
+ * @return string
1096
+ */
1097
+ function getCartTotalPriceHtml($cart_total_price)
1098
+ {
1099
+ if (!empty(self::$calculated_cart_item_discount)) {
1100
+ $total_discount = 0;
1101
+ foreach (self::$calculated_cart_item_discount as $discount_details) {
1102
+ if (!empty($discount_details)) {
1103
+ $total_discount += $this->getDiscountPerItem($discount_details);
1104
+ }
1105
+ }
1106
+ if (empty($total_discount)) {
1107
+ return $cart_total_price;
1108
+ }
1109
+ $total_discount = self::$woocommerce_helper->formatPrice($total_discount);
1110
+ $cart_total_price .= '<br>' . $this->getYouSavedText($total_discount);
1111
+ }
1112
+ return $cart_total_price;
1113
+ }
1114
+
1115
+ /**
1116
+ * Adding the discount per order item in item meta
1117
+ * @param $item
1118
+ * @param $cart_item_key
1119
+ * @param $values
1120
+ * @param $order
1121
+ */
1122
+ function onCreateWoocommerceOrderLineItem($item, $cart_item_key, $values, $order)
1123
+ {
1124
+ if (isset(self::$calculated_cart_item_discount[$cart_item_key])) {
1125
+ self::$woocommerce_helper->setOrderItemMeta($item, '_advanced_woo_discount_item_total_discount', self::$calculated_cart_item_discount[$cart_item_key]);
1126
+ }
1127
+ }
1128
+
1129
+ /**
1130
+ * Calculate the product's initial and discount price
1131
+ * @param $product
1132
+ * @param $quantity
1133
+ * @param $is_cart
1134
+ * @param $ajax_price
1135
+ * @return array|bool
1136
+ */
1137
+ static function calculateInitialAndDiscountedPrice($product, $quantity, $is_cart = false, $ajax_price = false, $cart_item = array())
1138
+ {
1139
+ return self::$calculator->getProductPriceToDisplay($product, $quantity, $is_cart, $ajax_price, $cart_item);
1140
+ }
1141
+
1142
+ /**
1143
+ * Re-calculate cart total
1144
+ * */
1145
+ public static function reCalculateCartTotal()
1146
+ {
1147
+ WC()->cart->calculate_totals();
1148
+ }
1149
+
1150
+ /**
1151
+ * @param $discount_details
1152
+ * @param $initial_price
1153
+ * @param $discounted_price
1154
+ * @param $product_obj
1155
+ * @param $price_html
1156
+ * @param $cart_item_qty
1157
+ * @param $ajax_price
1158
+ * @return bool|string
1159
+ */
1160
+ function getSetDiscountItemPriceHtml($discount_details, $initial_price, $discounted_price, $product_obj, $price_html, $cart_item_qty=0, $ajax_price = false)
1161
+ {
1162
+ if (is_array($discount_details) && !empty($discount_details)) {
1163
+ $other_discounts = $total_discount_price = $total_quantity = $current_product_quantity = $discount_operator = 0;
1164
+ $partially_qualified_set = array();
1165
+ $partially_qualified_set_amount_duplicate = array();
1166
+ $apply_full_set = false;
1167
+ $int_increment = 0;
1168
+ foreach ($discount_details as $detail_key => $detail) {
1169
+ $bogo_cheapest_discount = $bogo_cheapest_quantity = 0;
1170
+ //BOGO cheapest discount
1171
+ $bogo_cheap_in_cart = isset($detail['buy_x_get_y_cheapest_in_cart_discount']) ? $detail['buy_x_get_y_cheapest_in_cart_discount'] : '';
1172
+ $bogo_cheap_in_products = isset($detail['buy_x_get_y_cheapest_from_products_discount']) ? $detail['buy_x_get_y_cheapest_from_products_discount'] : '';
1173
+ $bogo_cheap_in_category = isset($detail['buy_x_get_y_cheapest_from_categories_discount']) ? $detail['buy_x_get_y_cheapest_from_categories_discount'] : '';
1174
+ $bogo_auto_add = isset($detail['buy_x_get_y_discount']) ? $detail['buy_x_get_y_discount'] : '';
1175
+ $bogo_getx = isset($detail['buy_x_get_x_discount']) ? $detail['buy_x_get_x_discount'] : '';
1176
+
1177
+ if(!empty($bogo_cheap_in_cart)){
1178
+ $bogo_cheapest_discount = isset($bogo_cheap_in_cart['discount_price_per_quantity']) ? $bogo_cheap_in_cart['discount_price_per_quantity'] : 0;
1179
+ $bogo_cheapest_quantity = isset($bogo_cheap_in_cart['discount_quantity']) ? $bogo_cheap_in_cart['discount_quantity'] : 0;
1180
+ }elseif(!empty($bogo_cheap_in_products)){
1181
+ $bogo_cheapest_discount = isset($bogo_cheap_in_products['discount_price_per_quantity']) ? $bogo_cheap_in_products['discount_price_per_quantity'] : 0;
1182
+ $bogo_cheapest_quantity = isset($bogo_cheap_in_products['discount_quantity']) ? $bogo_cheap_in_products['discount_quantity'] : 0;
1183
+ }elseif (!empty($bogo_cheap_in_category)){
1184
+ $bogo_cheapest_discount = isset($bogo_cheap_in_category['discount_price_per_quantity']) ? $bogo_cheap_in_category['discount_price_per_quantity'] : 0;
1185
+ $bogo_cheapest_quantity = isset($bogo_cheap_in_category['discount_quantity']) ? $bogo_cheap_in_category['discount_quantity'] : 0;
1186
+ }elseif(!empty($bogo_auto_add)){
1187
+ $bogo_cheapest_discount = isset($bogo_auto_add['discount_price_per_quantity']) ? $bogo_auto_add['discount_price_per_quantity'] : 0;
1188
+ $bogo_cheapest_quantity = isset($bogo_auto_add['discount_quantity']) ? $bogo_auto_add['discount_quantity'] : 0;
1189
+ }else{
1190
+ $bogo_cheapest_discount = isset($bogo_getx['discount_price_per_quantity']) ? $bogo_getx['discount_price_per_quantity'] : 0;
1191
+ $bogo_cheapest_quantity = isset($bogo_getx['discount_quantity']) ? $bogo_getx['discount_quantity'] : 0;
1192
+ }
1193
+ $bogo_partial_set = '';
1194
+ if(!empty($bogo_cheapest_quantity) && $bogo_cheapest_quantity < $cart_item_qty){
1195
+ $bogo_partial_set = 'yes';
1196
+ }elseif($bogo_cheapest_quantity == $cart_item_qty){
1197
+ $bogo_cheapest_full_matched_set = $bogo_cheapest_discount;
1198
+ }
1199
+
1200
+ $int_increment++;
1201
+ //per product quantity for set discount
1202
+ $fully_qualified_set = $discounted_price_per_set = $bogo_cheapest_full_matched_set = 0;
1203
+ $total_quantity = $cart_item_qty;
1204
+ $current_product_quantity = $cart_item_qty;
1205
+ if(!empty($detail['set_discount'])){
1206
+ $total_quantity = isset($detail['set_discount']['total_quantity']) ? $detail['set_discount']['total_quantity'] : 0;
1207
+ $discount_operator = isset($detail['set_discount']['discount_operator']) ? $detail['set_discount']['discount_operator'] : "";
1208
+ //original price quantity for set discount
1209
+ $original_price_quantity = isset($detail['set_discount']['original_price_quantity']) ? $detail['set_discount']['original_price_quantity'] : 0;
1210
+ //min set quantity
1211
+ $discounted_price_quantity = isset($detail['set_discount']['discounted_price_quantity']) ? $detail['set_discount']['discounted_price_quantity'] : 0;
1212
+ //set discounted price
1213
+ $discounted_price_per_set = isset($detail['set_discount']['discount_value']) ? $detail['set_discount']['discount_value'] : 0;
1214
+ $discounted_price_quantities = isset($detail['set_discount']['discounted_price_quantity']) ? $detail['set_discount']['discounted_price_quantity'] : 0;
1215
+ if (!empty($total_quantity)) {
1216
+ self::$set_total_quantity = $total_quantity;
1217
+ }
1218
+ if (empty($total_quantity)) {
1219
+ $total_quantity = self::$set_total_quantity;
1220
+ }
1221
+ }
1222
+
1223
+ //simple discounted price
1224
+ $simple_discount = isset($detail['simple_discount']) ? $detail['simple_discount'] : 0;
1225
+ //bulk discounted price
1226
+ $bulk_discounts = isset($detail['bulk_discount']) ? $detail['bulk_discount'] : 0;
1227
+
1228
+ //set discounted price quantity
1229
+ $total_discount_price += $discounted_price_per_set + $simple_discount + $bulk_discounts + $bogo_cheapest_discount;
1230
+ if (empty($original_price_quantity) && empty($discounted_price_quantity) && empty($bogo_partial_set)) {
1231
+ if (!empty($discounted_price_per_set)) {
1232
+ $fully_qualified_set = $discounted_price_per_set;
1233
+ }
1234
+ } else {
1235
+ if(!empty($detail['set_discount']) && !empty($discounted_price_per_set) && !empty($discounted_price_quantities)){
1236
+ if (isset($partially_qualified_set[$discounted_price_per_set]) && !empty($partially_qualified_set[$discounted_price_per_set])) {
1237
+ $partially_qualified_set_amount_duplicate[$discounted_price_per_set . '-' . $int_increment] = $discounted_price_quantities;
1238
+ } else {
1239
+ $partially_qualified_set[$discounted_price_per_set] = $discounted_price_quantities;
1240
+ }
1241
+ $multi_strikeout['set_strickout'] = true;
1242
+ }
1243
+ if(!empty($bogo_partial_set)){
1244
+ $int_increment++;
1245
+ if (isset($partially_qualified_set[$bogo_cheapest_discount]) && !empty($partially_qualified_set[$bogo_cheapest_discount])) {
1246
+ $partially_qualified_set_amount_duplicate[$bogo_cheapest_discount . '-' . $int_increment] = $bogo_cheapest_quantity;
1247
+ } else {
1248
+ $partially_qualified_set[$bogo_cheapest_discount] = $bogo_cheapest_quantity;
1249
+ }
1250
+ $multi_strikeout['bogo_strickout'] = true;
1251
+ }
1252
+
1253
+ }
1254
+ $other_discounts += $simple_discount + $bulk_discounts + $fully_qualified_set + $bogo_cheapest_full_matched_set;
1255
+ }
1256
+ if (empty($partially_qualified_set) || $apply_full_set == true) {
1257
+ if ($price_html) {
1258
+ if($ajax_price){
1259
+ $discounted_price = $initial_price - $discounted_price;
1260
+ if($discounted_price < 0){
1261
+ $discounted_price = 0;
1262
+ }
1263
+ $item_price = $this->getStrikeoutPrice($initial_price, $discounted_price);
1264
+ return $item_price.Woocommerce::getProductPriceSuffix($product_obj, $discounted_price);
1265
+ }
1266
+ $item_price = $this->getStrikeoutPrice($initial_price, $discounted_price);
1267
+ return $item_price.Woocommerce::getProductPriceSuffix($product_obj, $discounted_price);
1268
+ } else {
1269
+ return false;
1270
+ }
1271
+ } else {
1272
+ $original_item_price_html = $this->getSetStrikeoutPrice($initial_price, $partially_qualified_set, $total_discount_price, $other_discounts, $total_quantity, $product_obj, $price_html, $current_product_quantity, $discount_operator, $partially_qualified_set_amount_duplicate, $multi_strikeout);
1273
+ return $original_item_price_html;
1274
+ }
1275
+ } else {
1276
+ return false;
1277
+ }
1278
+ }
1279
+
1280
+ /**
1281
+ * Calculate discount for product or calculate discount from custom price
1282
+ * @param $price
1283
+ * @param $product
1284
+ * @param int $quantity
1285
+ * @param int $custom_price
1286
+ * @param string $get_only
1287
+ * @return bool
1288
+ */
1289
+ static function calculateProductDiscountPrice($price, $product, $quantity = 1, $custom_price = 0, $get_only = 'discounted_price')
1290
+ {
1291
+ if (!is_a($product, 'WC_Product')) {
1292
+ if (is_integer($product)) {
1293
+ $product = self::$woocommerce_helper->getProduct($product);
1294
+ } else {
1295
+ return false;
1296
+ }
1297
+ }
1298
+ if (!$product) {
1299
+ return false;
1300
+ }
1301
+ $discounts = self::$calculator->mayApplyPriceDiscount($product, $quantity, $custom_price);
1302
+ if ($discounts) {
1303
+ switch ($get_only) {
1304
+ case 'all':
1305
+ $product_id = self::$woocommerce_helper->getProductId($product);
1306
+ if (isset($discounts['total_discount_details'][$product_id])) {
1307
+ $discounts['total_discount_details'] = $discounts['total_discount_details'][$product_id];
1308
+ }
1309
+ if (isset($discounts['cart_discount_details'])) {
1310
+ unset($discounts['cart_discount_details']);
1311
+ }
1312
+ $price = $discounts;
1313
+ break;
1314
+ default:
1315
+ case 'discounted_price':
1316
+ $price = isset($discounts['discounted_price']) ? $discounts['discounted_price'] : $price;
1317
+ break;
1318
+ }
1319
+ }
1320
+ return $price;
1321
+ }
1322
+
1323
+ /**
1324
+ * Change the default template for sale badge
1325
+ *
1326
+ * @param $located string
1327
+ * @param $template_name string
1328
+ * @param $args array
1329
+ * @param $template_path string
1330
+ * @param $default_path string
1331
+ * @return string
1332
+ * */
1333
+ public static function changeTemplateForSaleTag($located, $template_name, $args, $template_path, $default_path){
1334
+ if($template_name == 'single-product/sale-flash.php'){
1335
+ $located = Helper::getTemplatePath('sale-flash.php', WDR_PLUGIN_PATH . 'App/Views/Templates/single-product/sale-flash.php', 'single-product');
1336
+ } else if($template_name == 'loop/sale-flash.php'){
1337
+ $located = Helper::getTemplatePath('sale-flash.php', WDR_PLUGIN_PATH . 'App/Views/Templates/loop/sale-flash.php', 'loop');
1338
+ }
1339
+
1340
+ return $located;
1341
+ }
1342
+
1343
+ /**
1344
+ * Remove on sale flash except our hooks
1345
+ * */
1346
+ function removeOnSaleFlashEvent(){
1347
+ $allowed_hooks = array(
1348
+ //Filters
1349
+ "woocommerce_sale_flash" => array( "Wdr\App\Controllers\ManageDiscount|replaceSaleTagText" ),
1350
+ );
1351
+
1352
+ $this->removeOtherEvents($allowed_hooks);
1353
+ }
1354
+
1355
+ /**
1356
+ * Suppress third party discount plugins from accessing the discount data
1357
+ */
1358
+ function suppressOtherDiscountPlugins()
1359
+ {
1360
+ $allowed_hooks = array(
1361
+ //Filters
1362
+ "woocommerce_get_price_html" => array("Wdr\App\Controllers\ManageDiscount|getPriceHtml", "Wdr\App\Controllers\ManageDiscount|getPriceHtmlSalePriceAdjustment"),
1363
+ "woocommerce_product_is_on_sale" => array("Wdr\App\Controllers\ManageDiscount|isProductInSale"),
1364
+ "woocommerce_product_get_sale_price" => array(),
1365
+ "woocommerce_product_get_regular_price" => array(),
1366
+ "woocommerce_variable_price_html" => array(),
1367
+ "woocommerce_cart_item_price" => array("Wdr\App\Controllers\ManageDiscount|getCartProductPriceHtml"),
1368
+ "woocommerce_cart_item_subtotal" => array("Wdr\App\Controllers\ManageDiscount|getCartProductSubtotalPriceHtml"),
1369
+ //Actions
1370
+ "woocommerce_checkout_order_processed" => array(),
1371
+ "woocommerce_before_calculate_totals" => array("Wdr\App\Controllers\ManageDiscount|applyCartProductDiscount"), //nothing allowed!
1372
+ );
1373
+ $allowed_hooks = apply_filters('advanced_woo_discount_rules_exclude_hooks_from_removing', $allowed_hooks);
1374
+ $this->removeOtherEvents($allowed_hooks);
1375
+ }
1376
+
1377
+ /**
1378
+ * Remove methods from the event
1379
+ * Exclude from the list
1380
+ *
1381
+ * @param $allowed_hooks array
1382
+ * */
1383
+ function removeOtherEvents($allowed_hooks){
1384
+ global $wp_filter;
1385
+ foreach ($wp_filter as $hook_name => $hook_obj) {
1386
+ if (preg_match('#^woocommerce_#', $hook_name)) {
1387
+ if (isset($allowed_hooks[$hook_name])) {
1388
+ $wp_filter[$hook_name] = $this->removeWrongCallbacks($hook_obj, $allowed_hooks[$hook_name]);
1389
+ }
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ /**
1395
+ * Remove the third party call backs
1396
+ * @param $hook_obj
1397
+ * @param $allowed_hooks
1398
+ * @return mixed
1399
+ */
1400
+ function removeWrongCallbacks($hook_obj, $allowed_hooks)
1401
+ {
1402
+ $new_callbacks = array();
1403
+ foreach ($hook_obj->callbacks as $priority => $callbacks) {
1404
+ $priority_callbacks = array();
1405
+ foreach ($callbacks as $idx => $callback_details) {
1406
+ if ($this->isCallbackMatch($callback_details, $allowed_hooks)) {
1407
+ $priority_callbacks[$idx] = $callback_details;
1408
+ }
1409
+ }
1410
+ if ($priority_callbacks) {
1411
+ $new_callbacks[$priority] = $priority_callbacks;
1412
+ }
1413
+ }
1414
+ $hook_obj->callbacks = $new_callbacks;
1415
+ return $hook_obj;
1416
+ }
1417
+
1418
+ /**
1419
+ * check the call back matched or not
1420
+ * @param $callback_details
1421
+ * @param $allowed_hooks
1422
+ * @return bool
1423
+ */
1424
+ function isCallbackMatch($callback_details, $allowed_hooks)
1425
+ {
1426
+ $result = false;
1427
+ foreach ($allowed_hooks as $callback_name) {
1428
+ list($class_name, $func_name) = explode("|", $callback_name);
1429
+ if(empty($callback_details['function'])){
1430
+ continue;
1431
+ }
1432
+ if (count($callback_details['function']) != 2) {
1433
+ continue;
1434
+ }
1435
+ if ($class_name == get_class($callback_details['function'][0]) AND $func_name == $callback_details['function'][1]) {
1436
+ $result = true;
1437
+ break;// done!
1438
+ }
1439
+ }
1440
+ return $result;
1441
+ }
1442
+
1443
+ /**
1444
+ * Display you saved text in order pages
1445
+ * @param $total
1446
+ * @param $order
1447
+ * @return string
1448
+ */
1449
+ function displayTotalSavingsInOrderAfterOrderTotal($total, $order)
1450
+ {
1451
+ if (!is_object($order)) {
1452
+ if (!empty($order) && is_int($order)) {
1453
+ $order = self::$woocommerce_helper->getOrder($order);
1454
+ }
1455
+ }
1456
+ $items = $order->get_items();
1457
+ $total_discount = $this->getItemTotalDiscount($items);
1458
+ $save_text = NULL;
1459
+ if (!empty($total_discount)) {
1460
+ $total_discounted_price = self::$woocommerce_helper->formatPrice($total_discount, array('currency' => self::$woocommerce_helper->getOrderCurrency($order)));
1461
+ $subtotal_additional_text = $this->getYouSavedText($total_discounted_price);
1462
+ $save_text = apply_filters('advanced_woo_discount_rules_order_saved_text', $subtotal_additional_text, $total_discounted_price, $total_discount);
1463
+ }
1464
+ return $total . $save_text;
1465
+ }
1466
+
1467
+ /**
1468
+ * Calculate items total discount
1469
+ * @param $items
1470
+ * @return float|int
1471
+ */
1472
+ function getItemTotalDiscount($items)
1473
+ {
1474
+ $total_discount = 0;
1475
+ if (!empty($items)) {
1476
+ foreach ($items as $key => $item) {
1477
+ $discount_details = $item->get_meta('_advanced_woo_discount_item_total_discount');
1478
+ if (!empty($discount_details)) {
1479
+ $total_discount += $this->getDiscountPerItem($discount_details);
1480
+ }
1481
+ }
1482
+ }
1483
+ return $total_discount;
1484
+ }
1485
+
1486
+ /**
1487
+ * order line item saved text
1488
+ * @param $subtotal
1489
+ * @param $item
1490
+ * @param $order
1491
+ * @return string
1492
+ */
1493
+ function orderSubTotalDiscountDetails($subtotal, $item, $order)
1494
+ {
1495
+ $discount_details = self::$woocommerce_helper->getOrderItemMeta($item, '_advanced_woo_discount_item_total_discount');
1496
+ if (!empty($discount_details)) {
1497
+ $total_discount = $this->getDiscountPerItem($discount_details);
1498
+ if (!empty($total_discount)) {
1499
+ $total_discounted_price = self::$woocommerce_helper->formatPrice($total_discount, array('currency' => self::$woocommerce_helper->getOrderCurrency($order)));
1500
+ $subtotal_additional_text = $this->getYouSavedText($total_discounted_price);
1501
+ $subtotal .= apply_filters('advanced_woo_discount_rules_order_saved_text', $subtotal_additional_text, $total_discounted_price, $total_discount);
1502
+ }
1503
+ }
1504
+ return $subtotal;
1505
+ }
1506
+
1507
+ /**
1508
+ * Show order discount details
1509
+ * @param $item_id
1510
+ * @param $item
1511
+ * @param $order
1512
+ */
1513
+ public function orderItemMetaDiscountDetails($item_id, $item, $order)
1514
+ {
1515
+ $discount_details = self::$woocommerce_helper->getOrderItemMeta($item, '_advanced_woo_discount_item_total_discount');
1516
+ if (!empty($discount_details)) {
1517
+ $total_discount = $this->getDiscountPerItem($discount_details);
1518
+ if (!empty($total_discount)) {
1519
+ $total_discounted_price = self::$woocommerce_helper->formatPrice($total_discount, array('currency' => self::$woocommerce_helper->getOrderCurrency($order)));
1520
+ $subtotal_additional_text = $this->getYouSavedText($total_discounted_price);
1521
+ echo apply_filters('advanced_woo_discount_rules_order_saved_text', $subtotal_additional_text, $total_discounted_price, $total_discount);
1522
+ }
1523
+ }
1524
+ }
1525
+
1526
+ /**
1527
+ * Hide Zero Coupon Value
1528
+ * @param $coupon_html
1529
+ * @param $coupon
1530
+ * @return mixed
1531
+ */
1532
+ public function hideZeroCouponValue($coupon_html, $coupon)
1533
+ {
1534
+ $hide_zero_value_coupon = apply_filters('advanced_woo_discount_rules_hide_zero_value_coupon', true, $coupon);
1535
+ if ($hide_zero_value_coupon) {
1536
+ $rule_helper = new Rule();
1537
+ $original_coupon_html = $coupon_html;
1538
+ $all_coupon_codes = $rule_helper->getCouponsFromDiscountRules();
1539
+ $coupon_code = self::$woocommerce_helper->getCouponCode($coupon);
1540
+ $virtual_coupon = (isset($all_coupon_codes['custom_coupons']) && !empty($all_coupon_codes['custom_coupons'])) ? $all_coupon_codes['custom_coupons'] : array();
1541
+ $woo_coupons = (isset($all_coupon_codes['woo_coupons'][0]) && !empty($all_coupon_codes['woo_coupons'][0])) ? $all_coupon_codes['woo_coupons'][0] : array();
1542
+ if (!empty($woo_coupons) && in_array($coupon_code, $woo_coupons)) {
1543
+ $zero_price_html = '-' . self::$woocommerce_helper->formatPrice(0);
1544
+ $coupon_html = str_replace($zero_price_html, '', $coupon_html);
1545
+ } else if (!empty($virtual_coupon) && in_array($coupon_code, $virtual_coupon)) {
1546
+ $zero_price_html = '-' . self::$woocommerce_helper->formatPrice(0);
1547
+ $coupon_html = str_replace($zero_price_html, '', $coupon_html);
1548
+ }
1549
+ $coupon_html = apply_filters('advanced_woo_discount_rules_hide_zero_value_coupon_html', $coupon_html, $original_coupon_html, $coupon);
1550
+ }
1551
+ return $coupon_html;
1552
+ }
1553
+ }
v2/App/Controllers/OnSaleShortCode.php ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ use Wdr\App\Helpers\Helper;
6
+ use Wdr\App\Helpers\Rule;
7
+
8
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
9
+
10
+ class OnSaleShortCode extends ManageDiscount
11
+ {
12
+ protected $on_sale_list = array();
13
+ protected static $on_sale_list_key = 'wdr_on_sale_list';
14
+ protected static $required_rebuild_key = 'wdr_on_sale_list_attention_required';
15
+ function __construct()
16
+ {
17
+ parent::__construct();
18
+ }
19
+
20
+ public function getAdditionalFilters($rule, $discount_type){
21
+ $additional_filter = $products = $category = array();
22
+ if($discount_type == 'wdr_buy_x_get_y_discount'){
23
+ $bxgy_adjustment = json_decode($rule->buy_x_get_y_adjustments);
24
+ if($bxgy_adjustment->type == 'bxgy_product'){
25
+ $ranges = $bxgy_adjustment->ranges;
26
+ foreach ($ranges as $range){
27
+ if(!empty($products) && !empty($range->products)){
28
+ $products = array_merge($products, $range->products);
29
+ } else {
30
+ $products = $range->products;
31
+ }
32
+ $parent_products = isset($range->product_variants_for_sale_badge)? $range->product_variants_for_sale_badge: array();
33
+ if(!empty($products) && !empty($parent_products)){
34
+ $products = array_merge($products, $parent_products);
35
+ }
36
+ }
37
+ if(!empty($products)){
38
+ $products = array_unique($products);
39
+ }
40
+ $additional_filter['product'] = $products;
41
+ } else if($bxgy_adjustment->type == 'bxgy_category'){
42
+ $ranges = $bxgy_adjustment->ranges;
43
+ foreach ($ranges as $range){
44
+ if(!empty($category) && !empty($range->categories)){
45
+ $category = array_merge($category, $range->categories);
46
+ } else {
47
+ $category = $range->categories;
48
+ }
49
+ }
50
+ if(!empty($category)){
51
+ $category = array_unique($category);
52
+ }
53
+ $additional_filter['category'] = $category;
54
+ }
55
+ }
56
+
57
+ return $additional_filter;
58
+ }
59
+
60
+ public static function getOnPageReBuildOption($id){
61
+ $option['available'] = false;
62
+ $option['required_rebuild'] = false;
63
+ $is_pro = Helper::hasPro();
64
+ if($is_pro){
65
+ $rules = self::getReBuildOnSaleRules();
66
+ if(!empty($rules)){
67
+ if(is_array($rules) && (in_array("all", $rules) || in_array($id, $rules))){
68
+ $option['available'] = true;
69
+ $option['rule_depend_on_sale_page'] = true;
70
+ $is_required = self::isRequiredRebuild();
71
+ if(!empty($is_required) && $is_required == 1){
72
+ $option['required_rebuild'] = true;
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ return $option;
79
+ }
80
+ public static function updateOnsaleRebuildPageStatus($id){
81
+ $is_pro = Helper::hasPro();
82
+ if($is_pro){
83
+ $rules = self::getReBuildOnSaleRules();
84
+ if(!empty($rules)){
85
+ if(is_array($rules) && (in_array("all", $rules) || in_array($id, $rules))){
86
+ self::setRequiredRebuild();
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ protected function getSelectedRules($rules_ids){
93
+ $rule_helper = new Rule();
94
+ $this->updateRebuildRulesInSettings($rules_ids);
95
+ return $rule_helper->getAvailableRules($this->getAvailableConditions(), $rules_ids);
96
+ }
97
+
98
+ /**
99
+ * Update rebuild rules with settings
100
+ * */
101
+ protected function updateRebuildRulesInSettings($awdr_rebuild_on_sale_rules){
102
+ $config = get_option(Configuration::DEFAULT_OPTION);
103
+ $config['awdr_rebuild_on_sale_rules'] = $awdr_rebuild_on_sale_rules;
104
+ update_option(Configuration::DEFAULT_OPTION, $config);
105
+ }
106
+
107
+ /**
108
+ * get rebuild rules from settings
109
+ * */
110
+ public static function getReBuildOnSaleRules(){
111
+ $config = new Configuration();
112
+ return $config->getConfig("awdr_rebuild_on_sale_rules", null);
113
+ }
114
+
115
+ /**
116
+ * get rebuild rules from settings
117
+ * */
118
+ public static function isRequiredRebuild(){
119
+ return get_option(self::$required_rebuild_key);
120
+ }
121
+
122
+ /**
123
+ * get rebuild rules from settings
124
+ * */
125
+ public static function setRequiredRebuild($val = 1){
126
+ return update_option(self::$required_rebuild_key, $val);
127
+ }
128
+
129
+ public function rebuildOnSaleList($rules_ids){
130
+ $this->on_sale_list = array();
131
+ if(!empty($rules_ids) && is_array($rules_ids)){
132
+ if(!in_array("all", $rules_ids)){
133
+ self::$available_rules = $this->getSelectedRules($rules_ids);
134
+ }
135
+ } else {
136
+ self::getReBuildOnSaleRules();
137
+ $rules_ids = self::getReBuildOnSaleRules();
138
+ if(!empty($rules_ids)){
139
+ if(!in_array("all", $rules_ids)){
140
+ self::$available_rules = $this->getSelectedRules($rules_ids);
141
+ }
142
+ }
143
+ }
144
+ if (!empty(self::$available_rules)) {
145
+ foreach (self::$available_rules as $rule) {
146
+ if($rule->rule->enabled == 1){
147
+ $discount_type = $rule->getRuleDiscountType();
148
+ if($discount_type != 'wdr_free_shipping'){
149
+ $filters = $rule->getFilter();
150
+ $additional_filter = $this->getAdditionalFilters($rule->rule, $discount_type);
151
+ if(!empty($additional_filter)){
152
+ if(isset($additional_filter['product']) && !empty($additional_filter['product'])){
153
+ if(empty($filters)){
154
+ $filters = new \stdClass();
155
+ }
156
+ $filters->bogo = new \stdClass();
157
+ $filters->bogo->type = 'products';
158
+ $filters->bogo->method = 'in_list';
159
+ $filters->bogo->value = $additional_filter['product'];
160
+ $filters->bogo->product_variants = array();
161
+ $filters->bogo->product_variants_for_sale_badge = array();
162
+ }
163
+ if(isset($additional_filter['category']) && !empty($additional_filter['category'])){
164
+ if(empty($filters)){
165
+ $filters = new \stdClass();
166
+ }
167
+ $filters->bogo = new \stdClass();
168
+ $filters->bogo->type = 'product_category';
169
+ $filters->bogo->method = 'in_list';
170
+ $filters->bogo->value = $additional_filter['category'];
171
+ }
172
+ }
173
+ $this->rebuildOnSaleListForARule($rule, $filters, $additional_filter);
174
+ }
175
+ }
176
+ }
177
+ $this->mergeAllRebuildRules();
178
+ self::setRequiredRebuild(0);
179
+ }
180
+ }
181
+
182
+ protected function mergeAllRebuildRules(){
183
+ $final_on_sale_list = array();
184
+ $exclude_list = $include_list = array();
185
+ if(!empty($this->on_sale_list)){
186
+ if(isset($this->on_sale_list['has_store_wide']) && $this->on_sale_list['has_store_wide'] == true){
187
+ $final_on_sale_list['has_store_wide'] = true;
188
+ if(!empty($this->on_sale_list['items'])){
189
+ foreach ($this->on_sale_list['items'] as $rule_id => $items){
190
+ if($items['has_store_wide']){
191
+ if(!empty($exclude_list)){
192
+ if(!empty($items['list'])){
193
+ $exclude_list = array_merge($exclude_list, $items['list']);
194
+ }
195
+ } else {
196
+ $exclude_list = $items['list'];
197
+ }
198
+ } else {
199
+ if(!empty($include_list)){
200
+ if(!empty($items['list'])){
201
+ $include_list = array_merge($include_list, $items['list']);
202
+ }
203
+ } else {
204
+ $include_list = $items['list'];
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if(!empty($exclude_list)){
210
+ $exclude_list = array_unique($exclude_list);
211
+ if(!empty($include_list)){
212
+ $include_list = array_unique($include_list);
213
+ $exclude_list = array_diff($exclude_list, $include_list);
214
+ }
215
+
216
+ $final_on_sale_list['list'] = $exclude_list;
217
+ }
218
+ } else {
219
+ $final_on_sale_list['has_store_wide'] = false;
220
+ if(!empty($this->on_sale_list['items'])){
221
+ foreach ($this->on_sale_list['items'] as $rule_id => $items){
222
+ if(!empty($include_list)){
223
+ if(!empty($items['list'])){
224
+ $include_list = array_merge($include_list, $items['list']);
225
+ }
226
+ } else {
227
+ $include_list = $items['list'];
228
+ }
229
+ }
230
+ }
231
+ if(!empty($include_list)){
232
+ $include_list = array_unique($include_list);
233
+ $final_on_sale_list['list'] = $include_list;
234
+ }
235
+ }
236
+ }
237
+ update_option(self::$on_sale_list_key, $final_on_sale_list);
238
+ }
239
+
240
+ public static function getOnSaleList(){
241
+ return get_option(self::$on_sale_list_key, array());
242
+ }
243
+
244
+ public function rebuildOnSaleListForARule($rule, $filters, $additional_filters = array()){
245
+ $this->processFiltersForRebuildOnSaleList($rule, $filters, $additional_filters);
246
+ }
247
+
248
+ protected function processFiltersForRebuildOnSaleList($rule, $filters, $additional_filters){
249
+ $rule_id = $rule->rule->id;
250
+ $has_store_wide = $this->hasStoreWideDiscount($rule, $filters);
251
+ if($has_store_wide === true){
252
+ $this->on_sale_list['has_store_wide'] = true;
253
+ }
254
+ $generated_filters = $this->generateFilters($rule, $filters, $has_store_wide, $additional_filters);
255
+ $query_args = $this->generateQueryArguments($generated_filters, $has_store_wide);
256
+ $this->on_sale_list['items'][$rule_id]['has_store_wide'] = $has_store_wide;
257
+ if(!empty($query_args)){
258
+ $exclude_ids = $include_id = array();
259
+ if(isset($query_args['post__in'])){
260
+ $include_id = $query_args['post__in'];
261
+ unset($query_args['post__in']);
262
+ }
263
+ if(isset($query_args['post__not_in'])){
264
+ $exclude_ids = $query_args['post__not_in'];
265
+ unset($query_args['post__not_in']);
266
+ }
267
+ if(!empty($query_args)){
268
+ $query_args['post_type'] = 'product';
269
+ $query_args['post_status'] = 'publish';
270
+ $products = new \WP_Query($query_args);
271
+ $post_ids = wp_list_pluck( $products->posts, 'ID' );
272
+ } else {
273
+ $post_ids = array();
274
+ }
275
+
276
+ if(!empty($include_id)){
277
+ if(!empty($post_ids) && is_array($post_ids)){
278
+ $post_ids = array_merge($post_ids, $include_id);
279
+ } else {
280
+ $post_ids = $include_id;
281
+ }
282
+ }
283
+ if(!empty($exclude_ids)){
284
+ if(!empty($post_ids) && is_array($post_ids)){
285
+ $post_ids = array_diff($post_ids, $exclude_ids);
286
+ }
287
+ }
288
+ $this->on_sale_list['items'][$rule_id]['list'] = $post_ids;
289
+ } else {
290
+ $this->on_sale_list['items'][$rule_id]['list'] = array();
291
+ }
292
+
293
+ }
294
+
295
+ protected function generateQueryArguments($generated_filters, $has_store_wide){
296
+ $query_arguments = array();
297
+ foreach ($generated_filters as $type => $generated_filter){
298
+ switch ($type) {
299
+ case "product_on_sale":
300
+ if (isset($generated_filter['in_list'])) {
301
+ $this->setOnSaleProductQueryArguments($query_arguments, 'include');
302
+ }
303
+ if (isset($generated_filter['not_in_list'])) {
304
+ $this->setOnSaleProductQueryArguments($query_arguments, 'exclude');
305
+ }
306
+ break;
307
+ case "product_category":
308
+ if (isset($generated_filter['in_list'])) {
309
+ $this->setCategoriesQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
310
+ }
311
+ if (isset($generated_filter['not_in_list'])) {
312
+ $this->setCategoriesQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
313
+ }
314
+ break;
315
+ case "products":
316
+ if (isset($generated_filter['in_list'])) {
317
+ $this->setProductsQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
318
+ }
319
+ if (isset($generated_filter['not_in_list'])) {
320
+ $this->setProductsQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
321
+ }
322
+ break;
323
+ case "product_tags":
324
+ if (isset($generated_filter['in_list'])) {
325
+ $this->setTagsQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
326
+ }
327
+ if (isset($generated_filter['not_in_list'])) {
328
+ $this->setTagsQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
329
+ }
330
+ break;
331
+ case "product_attributes":
332
+ if (isset($generated_filter['in_list'])) {
333
+ $this->setAttributesQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
334
+ }
335
+ if (isset($generated_filter['not_in_list'])) {
336
+ $this->setAttributesQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
337
+ }
338
+ break;
339
+ case "product_sku":
340
+ if (isset($generated_filter['in_list'])) {
341
+ $this->setSkuQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
342
+ }
343
+ if (isset($generated_filter['not_in_list'])) {
344
+ $this->setSkuQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
345
+ }
346
+ break;
347
+ default:
348
+ if (isset($generated_filter['in_list'])) {
349
+ $this->setCustomTaxonomyQueryArguments($query_arguments, 'include', $generated_filter['in_list']);
350
+ }
351
+ if (isset($generated_filter['not_in_list'])) {
352
+ $this->setCustomTaxonomyQueryArguments($query_arguments, 'exclude', $generated_filter['not_in_list']);
353
+ }
354
+ break;
355
+ }
356
+ }
357
+ $this->setQueryRelationship($query_arguments);
358
+ return $query_arguments;
359
+
360
+ }
361
+
362
+ function setCustomTaxonomyQueryArguments(&$query_arguments, $query_type, $taxonomies)
363
+ {
364
+ if($query_type == 'include'){
365
+ $operator = 'IN';
366
+ } else {
367
+ $operator = 'NOT IN';
368
+ }
369
+ if (!empty($taxonomies)) {
370
+ foreach ($taxonomies as $taxonomy => $values) {
371
+ $values = array_map('absint', $values);
372
+ $query_arguments['tax_query'][$query_type][] = array(
373
+ 'taxonomy' => $taxonomy,
374
+ 'terms' => $values,
375
+ 'field' => 'term_id',
376
+ 'operator' => $operator,
377
+ );
378
+ }
379
+ }
380
+ }
381
+
382
+ function setSkuQueryArguments(&$query_arguments, $query_type, $values)
383
+ {
384
+ $values = array_map('absint', $values);
385
+ if($query_type == 'include'){
386
+ $operator = 'IN';
387
+ } else {
388
+ $operator = 'NOT IN';
389
+ }
390
+ $query_arguments['meta_query'][] = array(
391
+ 'key' => '_sku',
392
+ 'value' => $values,
393
+ 'compare' => $operator,
394
+ );
395
+ }
396
+
397
+ function setOnSaleProductQueryArguments(&$query_arguments, $query_type)
398
+ {
399
+ if($query_type == 'include'){
400
+ $operator = '>';
401
+ $values = 0;
402
+ } else {
403
+ $operator = '<=';
404
+ $values = 0;
405
+ }
406
+ $query_arguments['meta_query'][] = array(
407
+ 'key' => '_sale_price',
408
+ 'value' => $values,
409
+ 'compare' => $operator,
410
+ );
411
+ }
412
+
413
+ protected function setAttributesQueryArguments(&$query_arguments, $query_type, $values)
414
+ {
415
+ $values = array_map('absint', $values);
416
+ if($query_type == 'include'){
417
+ $operator = 'IN';
418
+ } else {
419
+ $operator = 'NOT IN';
420
+ }
421
+ foreach ($values as $attribute) {
422
+ $data = get_term($attribute);
423
+ if (!empty($data)) {
424
+ $taxonomy = $data->taxonomy;
425
+ $query_arguments['tax_query'][$query_type][$taxonomy] = array(
426
+ 'taxonomy' => $taxonomy,
427
+ 'field' => 'term_id',
428
+ 'operator' => $operator
429
+ );
430
+ $query_arguments['tax_query'][$query_type][$taxonomy]['terms'][] = $attribute;
431
+ }
432
+ }
433
+ }
434
+
435
+ function setTagsQueryArguments(&$query_arguments, $query_type, $values)
436
+ {
437
+ $values = array_map('absint', $values);
438
+ if($query_type == 'include'){
439
+ $operator = 'IN';
440
+ } else {
441
+ $operator = 'NOT IN';
442
+ }
443
+ $query_arguments['tax_query'][$query_type][] = array(
444
+ 'taxonomy' => 'product_tag',
445
+ 'terms' => $values,
446
+ 'field' => 'term_id',
447
+ 'operator' => $operator
448
+ );
449
+ }
450
+
451
+ function setProductsQueryArguments(&$query_arguments, $query_type, $values)
452
+ {
453
+ /*
454
+ * As per https://www.billerickson.net/code/wp_query-arguments/
455
+ * you cannot combine 'post__in' and 'post__not_in' in the same query
456
+ */
457
+ //TODO: you cannot combine 'post__in' and 'post__not_in' in the same query
458
+ if($query_type == 'include'){
459
+ $query_arguments['post__in'] = $values;
460
+ } else {
461
+ $query_arguments['post__not_in'] = $values;
462
+ }
463
+ }
464
+
465
+ function setCategoriesQueryArguments(&$query_arguments, $query_type, $values)
466
+ {
467
+ $values = array_map('absint', $values);
468
+ if($query_type == 'include'){
469
+ $operator = 'IN';
470
+ } else {
471
+ $operator = 'NOT IN';
472
+ }
473
+ $query_arguments['tax_query'][$query_type][] = array(
474
+ 'taxonomy' => 'product_cat',
475
+ 'terms' => $values,
476
+ 'field' => 'term_id',
477
+ 'operator' => $operator,
478
+ 'include_children' => false
479
+ );
480
+ }
481
+
482
+ protected function generateFilters($rule, $filters, $has_store_wide, $additional_filters){
483
+ $generated_filters = array();
484
+ foreach ($filters as $filter) {
485
+ $type = $rule->getFilterType($filter);
486
+ $values = (array)$rule->getFilterOptionValue($filter);
487
+ $parent_product_ids = (array)$rule->getFilterOptionParentValue($filter);
488
+ $method = $rule->getFilterMethod($filter);
489
+ if($type == "products"){
490
+ if ($method == "in_list") {
491
+ if(!empty($parent_product_ids) && is_array($parent_product_ids)){
492
+ $values = array_merge($values, $parent_product_ids);
493
+ }
494
+ }
495
+ }
496
+ switch ($type) {
497
+ case "all_products":
498
+ break;
499
+ case "product_on_sale":
500
+ if($has_store_wide){
501
+ if($method == 'not_in_list'){
502
+ $generated_filters[$type][$method] = true;
503
+ }
504
+ } else {
505
+ $generated_filters[$type][$method] = true;
506
+ }
507
+ break;
508
+ default:
509
+ if($has_store_wide){
510
+ if($method == 'not_in_list' && !empty($values) && is_array($values)){
511
+ $method = 'in_list';
512
+ $generated_filters[$type][$method] = $this->mergeValues($generated_filters, $type, $method, $values);
513
+ }
514
+ } else {
515
+ if(!empty($values) && is_array($values)){
516
+ $generated_filters[$type][$method] = $this->mergeValues($generated_filters, $type, $method, $values);
517
+ }
518
+ }
519
+ break;
520
+ }
521
+ }
522
+
523
+ return $generated_filters;
524
+ }
525
+
526
+ protected function mergeValues($generated_filters, $type, $method, $values){
527
+ if(isset($generated_filters[$type])){
528
+ if(isset($generated_filters[$type][$method]) && !empty($generated_filters[$type][$method])){
529
+ $values = array_merge($generated_filters[$type][$method], $values);
530
+ $values = array_unique($values);
531
+ }
532
+ }
533
+ return $values;
534
+ }
535
+
536
+ protected function hasStoreWideDiscount($rule, $filters){
537
+ foreach ($filters as $filter) {
538
+ $type = $rule->getFilterType($filter);
539
+ if($type == "all_products"){
540
+ return true;
541
+ }
542
+ }
543
+ return false;
544
+ }
545
+
546
+ /**
547
+ * Set the query relations
548
+ * @param $query_arguments
549
+ */
550
+ function setQueryRelationship(&$query_arguments)
551
+ {
552
+ if (!empty($query_arguments['tax_query'])) {
553
+ if (!empty($query_arguments['tax_query']['include'])) {
554
+ $query_arguments['tax_query']['include']['relation'] = 'or';
555
+ }
556
+ if (!empty($query_arguments['tax_query']['exclude'])) {
557
+ $query_arguments['tax_query']['exclude']['relation'] = 'or';
558
+ }
559
+ if (!empty($query_arguments['tax_query'])) {
560
+ $query_arguments['tax_query']['relation'] = 'and';
561
+ }
562
+ }
563
+ if (!empty($query_arguments['meta_query'])) {
564
+ $query_arguments['meta_query']['relation'] = 'or';
565
+ }
566
+ }
567
+ }
v2/App/Controllers/ShortCodeManager.php ADDED
@@ -0,0 +1,680 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Controllers;
4
+
5
+ use Wdr\App\Helpers\Woocommerce;
6
+
7
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
8
+
9
+ class ShortCodeManager extends ManageDiscount
10
+ {
11
+ function __construct()
12
+ {
13
+ parent::__construct();
14
+ }
15
+
16
+ /**
17
+ * Create SKU query arguments
18
+ * @param $query_arguments
19
+ * @param $skus
20
+ * @param $exclude_skus
21
+ * @param $all_products
22
+ */
23
+ function setSkuQueryArguments(&$query_arguments, $skus, $exclude_skus, $all_products)
24
+ {
25
+ $this->removeDuplicateValuesInArray($skus, $exclude_skus);
26
+ if (!empty($skus) && empty($all_products)) {
27
+ $query_arguments['meta_query'][] = array(
28
+ 'key' => '_sku',
29
+ 'value' => $skus,
30
+ 'compare' => 'IN',
31
+ );
32
+ }
33
+ if (!empty($exclude_skus)) {
34
+ $query_arguments['meta_query'][] = array(
35
+ 'key' => '_sku',
36
+ 'value' => $exclude_skus,
37
+ 'compare' => 'NOT IN',
38
+ );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Create on sale query arguments
44
+ * @param $query_arguments
45
+ * @param $onsale_product_id
46
+ * @param $exclude_product_id
47
+ * @param $all_products
48
+ */
49
+ function setOnSaleQueryArguments(&$query_arguments, $on_sale_products, $all_products)
50
+ {
51
+ if (function_exists('wc_get_product_ids_on_sale')) {
52
+ $product_ids_on_sale = wc_get_product_ids_on_sale();
53
+ }
54
+ if (!empty($on_sale_products) && $on_sale_products == 'in_list' && empty($all_products)) {
55
+ /*$query_arguments['meta_query'][] = array( // Simple products type
56
+ 'key' => '_sale_price',
57
+ 'value' => 0,
58
+ 'compare' => '>',
59
+ 'type' => 'numeric'
60
+ );
61
+ $query_arguments['meta_query'][] = array( // Variable products type
62
+ 'key' => '_min_variation_sale_price',
63
+ 'value' => 0,
64
+ 'compare' => '>',
65
+ 'type' => 'numeric'
66
+ );*/
67
+
68
+ if(isset($query_arguments['post__in']) && !empty($query_arguments['post__in'])){
69
+ $query_arguments['post__in'] = array_merge($query_arguments['post__in'],$product_ids_on_sale);
70
+ $query_arguments['post__in'] = array_unique($query_arguments['post__in']);
71
+ }else{
72
+ $query_arguments['post__in'] = $product_ids_on_sale;
73
+ }
74
+ }
75
+ if (!empty($on_sale_products) && $on_sale_products == 'not_in_list' ) {
76
+ if(isset($query_arguments['post__not_in']) && !empty($query_arguments['post__not_in'])){
77
+ $query_arguments['post__not_in'] = array_merge($query_arguments['post__not_in'],$product_ids_on_sale);
78
+ $query_arguments['post__not_in'] = array_unique($query_arguments['post__not_in']);
79
+ }else{
80
+ $query_arguments['post__not_in'] = $product_ids_on_sale;
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Create SKU query arguments
87
+ * @param $query_arguments
88
+ * @param $products
89
+ * @param $exclude_products
90
+ * @param $all_products
91
+ */
92
+ function setProductsQueryArguments(&$query_arguments, $products, $exclude_products, $all_products)
93
+ {
94
+ /*
95
+ * As per https://www.billerickson.net/code/wp_query-arguments/
96
+ * you cannot combine 'post__in' and 'post__not_in' in the same query
97
+ */
98
+ //TODO: you cannot combine 'post__in' and 'post__not_in' in the same query
99
+ $this->removeDuplicateValuesInArray($products, $exclude_products);
100
+ if (!empty($products) && empty($all_products)) {
101
+ $query_arguments['post__in'] = $products;
102
+ }
103
+ if (!empty($exclude_products)) {
104
+ $query_arguments['post__not_in'] = $exclude_products;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Set the query relations
110
+ * @param $query_arguments
111
+ */
112
+ function setQueryRelationship(&$query_arguments)
113
+ {
114
+ if (!empty($query_arguments['tax_query'])) {
115
+ if (!empty($query_arguments['tax_query']['include'])) {
116
+ $query_arguments['tax_query']['include']['relation'] = 'or';
117
+ }
118
+ if (!empty($query_arguments['tax_query']['exclude'])) {
119
+ $query_arguments['tax_query']['exclude']['relation'] = 'or';
120
+ }
121
+ if (!empty($query_arguments['tax_query'])) {
122
+ $query_arguments['tax_query']['relation'] = 'and';
123
+ }
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Create Tags query arguments
129
+ * @param $query_arguments
130
+ * @param $tags
131
+ * @param $exclude_tags
132
+ * @param $all_products
133
+ */
134
+ function setTagsQueryArguments(&$query_arguments, $tags, $exclude_tags, $all_products)
135
+ {
136
+ $this->removeDuplicateValuesInArray($tags, $exclude_tags);
137
+ if (!empty($tags) && empty($all_products)) {
138
+ $tags = array_map('absint', $tags);
139
+ $query_arguments['tax_query']['include'][] = array(
140
+ 'taxonomy' => 'product_tag',
141
+ 'terms' => $tags,
142
+ 'field' => 'term_id',
143
+ 'operator' => 'IN',
144
+ );
145
+ }
146
+ if (!empty($exclude_tags)) {
147
+ $exclude_tags = array_map('absint', $exclude_tags);
148
+ $query_arguments['tax_query']['exclude'][] = array(
149
+ 'taxonomy' => 'product_tag',
150
+ 'terms' => $exclude_tags,
151
+ 'field' => 'term_id',
152
+ 'operator' => 'NOT IN',
153
+ );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Create Tags query arguments
159
+ * @param $query_arguments
160
+ * @param $taxonomies
161
+ * @param $exclude_taxonomies
162
+ * @param $all_products
163
+ */
164
+ function setCustomTaxonomyQueryArguments(&$query_arguments, $taxonomies, $exclude_taxonomies, $all_products)
165
+ {
166
+ $this->removeDuplicateValuesInArray($taxonomies, $exclude_taxonomies);
167
+ if (!empty($taxonomies) && empty($all_products)) {
168
+ foreach ($taxonomies as $taxonomy => $values) {
169
+ $values = array_map('absint', $values);
170
+ $query_arguments['tax_query']['include'][] = array(
171
+ 'taxonomy' => $taxonomy,
172
+ 'terms' => $values,
173
+ 'field' => 'term_id',
174
+ 'operator' => 'IN',
175
+ );
176
+ }
177
+ }
178
+ if (!empty($exclude_taxonomies)) {
179
+ foreach ($exclude_taxonomies as $taxonomy => $values) {
180
+ $values = array_map('absint', $values);
181
+ $query_arguments['tax_query']['include'][] = array(
182
+ 'taxonomy' => $taxonomy,
183
+ 'terms' => $values,
184
+ 'field' => 'term_id',
185
+ 'operator' => 'NOT IN',
186
+ );
187
+ }
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Create Category query arguments
193
+ * @param $query_arguments
194
+ * @param $categories
195
+ * @param $exclude_categories
196
+ * @param $all_products
197
+ */
198
+ function setCategoriesQueryArguments(&$query_arguments, $categories, $exclude_categories, $all_products)
199
+ {
200
+ $this->removeDuplicateValuesInArray($categories, $exclude_categories);
201
+ if (!empty($categories) && empty($all_products)) {
202
+ $categories = array_map('absint', $categories);
203
+ $query_arguments['tax_query']['include'][] = array(
204
+ 'taxonomy' => 'product_cat',
205
+ 'terms' => $categories,
206
+ 'field' => 'term_id',
207
+ 'operator' => 'IN',
208
+ 'include_children' => true
209
+ );
210
+ }
211
+ if (!empty($exclude_categories)) {
212
+ $exclude_categories = array_map('absint', $exclude_categories);
213
+ $query_arguments['tax_query']['exclude'][] = array(
214
+ 'taxonomy' => 'product_cat',
215
+ 'terms' => $exclude_categories,
216
+ 'field' => 'term_id',
217
+ 'operator' => 'NOT IN',
218
+ 'include_children' => true
219
+ );
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Remove duplicate value by comparing 2 different array
225
+ * @param $array_1
226
+ * @param $array_2
227
+ * @param int $remove_from
228
+ */
229
+ function removeDuplicateValuesInArray(&$array_1, &$array_2, $remove_from = 2)
230
+ {
231
+ $duplicate_values = array_intersect($array_1, $array_2);
232
+ if ($remove_from == 2) {
233
+ $array_2 = array_diff($array_2, $duplicate_values);
234
+ } else {
235
+ $array_1 = array_diff($array_1, $duplicate_values);
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Set attributes query args.
241
+ * @param $query_arguments
242
+ * @param $attributes
243
+ * @param $exclude_attributes
244
+ * @param $all_products
245
+ */
246
+ protected function setAttributesQueryArguments(&$query_arguments, $attributes, $exclude_attributes, $all_products)
247
+ {
248
+ if (!empty($attributes) && empty($all_products)) {
249
+ $attributes = array_map('absint', $attributes);
250
+ foreach ($attributes as $attribute) {
251
+ $data = get_term($attribute);
252
+ if (!empty($data)) {
253
+ $taxonomy = $data->taxonomy;
254
+ $query_arguments['tax_query']['include'][$taxonomy] = array(
255
+ 'taxonomy' => $taxonomy,
256
+ 'field' => 'term_id',
257
+ 'operator' => 'IN'
258
+ );
259
+ $query_arguments['tax_query']['include'][$taxonomy]['terms'][] = $attribute;
260
+ }
261
+ }
262
+ }
263
+ if (!empty($exclude_attributes)) {
264
+ $exclude_attributes = array_map('absint', $exclude_attributes);
265
+ foreach ($exclude_attributes as $attribute) {
266
+ $data = get_term($attribute);
267
+ if (!empty($data)) {
268
+ $taxonomy = $data->taxonomy;
269
+ $query_arguments['tax_query']['exclude'][$taxonomy] = array(
270
+ 'taxonomy' => $taxonomy,
271
+ 'field' => 'term_id',
272
+ 'operator' => 'NOT IN'
273
+ );
274
+ $query_arguments['tax_query']['exclude'][$taxonomy]['terms'][] = $attribute;
275
+ }
276
+ }
277
+ }
278
+ }
279
+
280
+ function modifyFilterArguments(&$query_arguments, $order_by)
281
+ {
282
+ switch ($order_by) {
283
+ default:
284
+ $meta_key = NULL;
285
+ $order = 'asc';
286
+ $order_by = 'title';
287
+ break;
288
+ case 'popularity':
289
+ $meta_key = '';
290
+ $order = 'asc';
291
+ $order_by = 'post_views';
292
+ break;
293
+ case 'price':
294
+ case 'low_to_high':
295
+ $meta_key = '_price';
296
+ $order = 'asc';
297
+ $order_by = 'meta_value_num';
298
+ break;
299
+ case 'price-desc':
300
+ case 'high_to_low':
301
+ $meta_key = '_price';
302
+ $order = 'desc';
303
+ $order_by = 'meta_value_num';
304
+ break;
305
+ case 'date':
306
+ case 'newness':
307
+ $meta_key = NULL;
308
+ $order = 'desc';
309
+ $order_by = 'date';
310
+ break;
311
+ case 'rating':
312
+ $meta_key = NULL;
313
+ $order = 'desc';
314
+ $order_by = 'rating';
315
+ break;
316
+ }
317
+ $query_arguments['orderby'] = $order_by;
318
+ $query_arguments['order'] = $order;
319
+ if (!empty($meta_key)) {
320
+ $query_arguments['meta_key'] = $meta_key;
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Show sale items by short code
326
+ * @param $short_code_attributes
327
+ * @return string
328
+ */
329
+ function saleItemsList($short_code_attributes)
330
+ {
331
+ if (!empty(self::$available_rules)) {
332
+ global $woocommerce_loop;
333
+ $short_code_attributes = shortcode_atts(array(
334
+ 'per_page' => 12,
335
+ 'columns' => 3,
336
+ 'orderby' => 'title',
337
+ 'do_pagination' => 1,
338
+ 'order' => 'asc'
339
+ ), $short_code_attributes);
340
+ $paged = $this->input->get('product-page', 1);
341
+ $order_by = $this->input->get('orderby', 'title');
342
+ /*$exclude_categories = $exclude_products = $exclude_tags = $exclude_attributes = $exclude_skus = $exclude_custom_taxonomies = array();
343
+ $categories = $products = $tags = $attributes = $skus = $custom_taxonomies = array();
344
+ $all_products = $on_sale_products = '';
345
+ $query_arguments = array(
346
+ 'post_type' => 'product',
347
+ 'post_status' => 'publish',
348
+ 'paged' => $paged,
349
+ 'posts_per_page' => $short_code_attributes['per_page'],
350
+ 'orderby' => $short_code_attributes['orderby'],
351
+ 'order' => $short_code_attributes['order'],
352
+ );
353
+ $this->modifyFilterArguments($query_arguments, $order_by);
354
+ foreach (self::$available_rules as $rule) {
355
+ $discount_type = $rule->getRuleDiscountType();
356
+ if($discount_type == 'wdr_buy_x_get_y_discount'){
357
+ $get_y = $rule->getBuyXGetYAdjustment();
358
+ $type = (isset($get_y->type) && !empty($get_y->type)) ? $get_y->type : '';
359
+ $parent_id = array();
360
+ foreach ($get_y->ranges as $range){
361
+ $get_y_products = isset($range->products) ? $range->products : array();
362
+ $get_y_parent_ids = isset($range->product_variants_for_sale_badge) ? $range->product_variants_for_sale_badge : array();
363
+ foreach ($get_y_parent_ids as $get_y_parent_id){
364
+ $get_y_parent_id_array = isset($get_y_parent_id) ? $get_y_parent_id : array();
365
+ $parent_id = array_merge($parent_id, $get_y_parent_id_array);
366
+ }
367
+ if(!empty($type)){
368
+ if($type == 'bxgy_product' && isset($range->products) && !empty($range->products)){
369
+ if(!empty($parent_id)){
370
+ $get_y_products = array_merge($get_y_products, $parent_id);
371
+ }
372
+ $products = array_merge($products, $get_y_products);
373
+ $products = array_unique($products);
374
+ }
375
+ if($type == 'bxgy_category' && isset($range->categories) && !empty($range->categories)){
376
+ $categories = array_merge($categories, $range->categories);
377
+ }
378
+ }
379
+ }
380
+ }
381
+ $filters = $rule->getFilter();
382
+ foreach ($filters as $filter) {
383
+ $type = $rule->getFilterType($filter);
384
+ $values = (array)$rule->getFilterOptionValue($filter);
385
+ $parent_product_id = (array)$rule->getFilterOptionParentValue($filter);
386
+ $method = $rule->getFilterMethod($filter);
387
+ switch ($type) {
388
+ case "all_products":
389
+ $all_products = 'yes';
390
+ break;
391
+ case "product_on_sale":
392
+ $on_sale_products = $method;
393
+ break;
394
+ case "product_category":
395
+ if ($method == "in_list") {
396
+ $categories = array_merge($categories, $values);
397
+ $categories = array_unique($categories);
398
+ } else {
399
+ $exclude_categories = array_merge($exclude_categories, $values);
400
+ }
401
+ break;
402
+ case "products":
403
+ if ($method == "in_list") {
404
+ if(!empty($parent_product_id)){
405
+ $values = array_merge($values, $parent_product_id);
406
+ }
407
+ $products = array_merge($products, $values);
408
+ $products = array_unique($products);
409
+ } else {
410
+ $exclude_products = array_merge($exclude_products, $values);
411
+ }
412
+ break;
413
+ case "product_tags":
414
+ if ($method == "in_list") {
415
+ $tags = array_merge($tags, $values);
416
+ } else {
417
+ $exclude_tags = array_merge($exclude_tags, $values);
418
+ }
419
+ break;
420
+ case "product_attributes":
421
+ if ($method == "in_list") {
422
+ $attributes = array_merge($attributes, $values);
423
+ } else {
424
+ $exclude_attributes = array_merge($exclude_attributes, $values);
425
+ }
426
+ break;
427
+ case "product_sku":
428
+ if ($method == "in_list") {
429
+ $skus = array_merge($skus, $values);
430
+ } else {
431
+ $exclude_skus = array_merge($exclude_skus, $values);
432
+ }
433
+ break;
434
+ default:
435
+ if ($method == "in_list") {
436
+ $custom_taxonomies[$type] = isset($custom_taxonomies[$type]) ? array_merge($custom_taxonomies[$type], $values) : $values;
437
+ } else {
438
+ $exclude_custom_taxonomies[$type] = isset($exclude_custom_taxonomies[$type]) ? array_merge($exclude_custom_taxonomies[$type], $values) : $values;
439
+ }
440
+ break;
441
+ }
442
+ }
443
+ }
444
+
445
+ $this->setCategoriesQueryArguments($query_arguments, $categories, $exclude_categories, $all_products);
446
+ $this->setTagsQueryArguments($query_arguments, $tags, $exclude_tags, $all_products);
447
+ $this->setAttributesQueryArguments($query_arguments, $attributes, $exclude_attributes, $all_products);
448
+ $this->setSkuQueryArguments($query_arguments, $skus, $exclude_skus, $all_products);
449
+ $this->setOnSaleQueryArguments($query_arguments, $on_sale_products, $all_products);
450
+ $this->setCustomTaxonomyQueryArguments($query_arguments, $custom_taxonomies, $exclude_custom_taxonomies, $all_products);
451
+ $this->setProductsQueryArguments($query_arguments, $products, $exclude_products, $all_products);
452
+ $this->setQueryRelationship($query_arguments);
453
+ // echo "<pre>"; print_r($query_arguments); echo "</pre>"; die;*/
454
+ ob_start();
455
+ $onsale_list = OnSaleShortCode::getOnSaleList();
456
+ // echo "<pre>";
457
+ // print_r($onsale_list);
458
+ // echo "</pre>";
459
+ // exit;
460
+ if(!empty($onsale_list)){
461
+ $query_arguments = array(
462
+ 'post_type' => 'product',
463
+ 'post_status' => 'publish',
464
+ 'paged' => $paged,
465
+ 'posts_per_page' => $short_code_attributes['per_page'],
466
+ 'orderby' => $short_code_attributes['orderby'],
467
+ 'order' => $short_code_attributes['order'],
468
+ );
469
+ if($onsale_list['has_store_wide']){
470
+ if (!empty($onsale_list['list'])) {
471
+ $query_arguments['post__not_in'] = $onsale_list['list'];
472
+ }
473
+ } else {
474
+ if (!empty($onsale_list['list'])) {
475
+ $query_arguments['post__in'] = $onsale_list['list'];
476
+ }
477
+ }
478
+ } else {
479
+ $query_arguments = array();
480
+ }
481
+ $products = new \WP_Query($query_arguments);
482
+ $columns = absint($short_code_attributes['columns']);
483
+ $woocommerce_loop['columns'] = $columns;
484
+ if ($products->have_posts()) {
485
+ self::$woocommerce_helper->setLoopProperties('is_shortcode', true);
486
+ self::$woocommerce_helper->setLoopProperties('is_paginated', (!empty($short_code_attributes['do_pagination'])));
487
+ self::$woocommerce_helper->setLoopProperties('per_page', $short_code_attributes['per_page']);
488
+ self::$woocommerce_helper->setLoopProperties('current_page', $paged);
489
+ $total = $products->found_posts;
490
+ self::$woocommerce_helper->setLoopProperties('total', $total);
491
+ $total_pages = ceil($total / $short_code_attributes['per_page']);
492
+ self::$woocommerce_helper->setLoopProperties('total_pages', $total_pages);
493
+ do_action('woocommerce_before_shop_loop');
494
+ self::$woocommerce_helper->productLoopStart();
495
+ while ($products->have_posts()) {
496
+ $products->the_post();
497
+ wc_get_template_part('content', 'product');
498
+ }
499
+ self::$woocommerce_helper->productLoopEnd();
500
+ do_action('woocommerce_after_shop_loop');
501
+ // woocommerce_pagination();
502
+ wp_reset_postdata();
503
+ } else {
504
+ do_action('woocommerce_no_products_found');
505
+ }
506
+ return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
507
+ }
508
+ return NULL;
509
+ }
510
+
511
+ /**
512
+ * Show sale items by short code
513
+ * @param $short_code_attributes
514
+ * @return string
515
+ */
516
+ function saleItemsList_old($short_code_attributes)
517
+ {
518
+ if (!empty(self::$available_rules)) {
519
+ global $woocommerce_loop;
520
+ $short_code_attributes = shortcode_atts(array(
521
+ 'per_page' => 12,
522
+ 'columns' => 3,
523
+ 'orderby' => 'title',
524
+ 'do_pagination' => 1,
525
+ 'order' => 'asc'
526
+ ), $short_code_attributes);
527
+ $paged = $this->input->get('product-page', 1);
528
+ $order_by = $this->input->get('orderby', 'title');
529
+ $exclude_categories = $exclude_products = $exclude_tags = $exclude_attributes = $exclude_skus = $exclude_custom_taxonomies = array();
530
+ $categories = $products = $tags = $attributes = $skus = $custom_taxonomies = array();
531
+ $all_products = $on_sale_products = '';
532
+ $query_arguments = array(
533
+ 'post_type' => 'product',
534
+ 'post_status' => 'publish',
535
+ 'paged' => $paged,
536
+ 'posts_per_page' => $short_code_attributes['per_page'],
537
+ 'orderby' => $short_code_attributes['orderby'],
538
+ 'order' => $short_code_attributes['order'],
539
+ );
540
+ $this->modifyFilterArguments($query_arguments, $order_by);
541
+ foreach (self::$available_rules as $rule) {
542
+ $discount_type = $rule->getRuleDiscountType();
543
+ if($discount_type == 'wdr_buy_x_get_y_discount'){
544
+ $get_y = $rule->getBuyXGetYAdjustment();
545
+ $type = (isset($get_y->type) && !empty($get_y->type)) ? $get_y->type : '';
546
+ $parent_id = array();
547
+ foreach ($get_y->ranges as $range){
548
+ $get_y_products = isset($range->products) ? $range->products : array();
549
+ $get_y_parent_ids = isset($range->product_variants_for_sale_badge) ? $range->product_variants_for_sale_badge : array();
550
+ foreach ($get_y_parent_ids as $get_y_parent_id){
551
+ $get_y_parent_id_array = isset($get_y_parent_id) ? $get_y_parent_id : array();
552
+ $parent_id = array_merge($parent_id, $get_y_parent_id_array);
553
+ }
554
+ if(!empty($type)){
555
+ if($type == 'bxgy_product' && isset($range->products) && !empty($range->products)){
556
+ if(!empty($parent_id)){
557
+ $get_y_products = array_merge($get_y_products, $parent_id);
558
+ }
559
+ $products = array_merge($products, $get_y_products);
560
+ $products = array_unique($products);
561
+ }
562
+ if($type == 'bxgy_category' && isset($range->categories) && !empty($range->categories)){
563
+ $categories = array_merge($categories, $range->categories);
564
+ }
565
+ }
566
+ }
567
+ }
568
+ $filters = $rule->getFilter();
569
+ foreach ($filters as $filter) {
570
+ $type = $rule->getFilterType($filter);
571
+ $values = (array)$rule->getFilterOptionValue($filter);
572
+ $parent_product_id = (array)$rule->getFilterOptionParentValue($filter);
573
+ $method = $rule->getFilterMethod($filter);
574
+ switch ($type) {
575
+ case "all_products":
576
+ $all_products = 'yes';
577
+ break;
578
+ case "product_on_sale":
579
+ $on_sale_products = $method;
580
+ break;
581
+ case "product_category":
582
+ if ($method == "in_list") {
583
+ $categories = array_merge($categories, $values);
584
+ $categories = array_unique($categories);
585
+ } else {
586
+ $exclude_categories = array_merge($exclude_categories, $values);
587
+ }
588
+ break;
589
+ case "products":
590
+ if ($method == "in_list") {
591
+ if(!empty($parent_product_id)){
592
+ $values = array_merge($values, $parent_product_id);
593
+ }
594
+ $products = array_merge($products, $values);
595
+ $products = array_unique($products);
596
+ } else {
597
+ $exclude_products = array_merge($exclude_products, $values);
598
+ }
599
+ break;
600
+ case "product_tags":
601
+ if ($method == "in_list") {
602
+ $tags = array_merge($tags, $values);
603
+ } else {
604
+ $exclude_tags = array_merge($exclude_tags, $values);
605
+ }
606
+ break;
607
+ case "product_attributes":
608
+ if ($method == "in_list") {
609
+ $attributes = array_merge($attributes, $values);
610
+ } else {
611
+ $exclude_attributes = array_merge($exclude_attributes, $values);
612
+ }
613
+ break;
614
+ case "product_sku":
615
+ if ($method == "in_list") {
616
+ $skus = array_merge($skus, $values);
617
+ } else {
618
+ $exclude_skus = array_merge($exclude_skus, $values);
619
+ }
620
+ break;
621
+ default:
622
+ if ($method == "in_list") {
623
+ $custom_taxonomies[$type] = isset($custom_taxonomies[$type]) ? array_merge($custom_taxonomies[$type], $values) : $values;
624
+ } else {
625
+ $exclude_custom_taxonomies[$type] = isset($exclude_custom_taxonomies[$type]) ? array_merge($exclude_custom_taxonomies[$type], $values) : $values;
626
+ }
627
+ break;
628
+ }
629
+ }
630
+ }
631
+
632
+ $this->setCategoriesQueryArguments($query_arguments, $categories, $exclude_categories, $all_products);
633
+ $this->setTagsQueryArguments($query_arguments, $tags, $exclude_tags, $all_products);
634
+ $this->setAttributesQueryArguments($query_arguments, $attributes, $exclude_attributes, $all_products);
635
+ $this->setSkuQueryArguments($query_arguments, $skus, $exclude_skus, $all_products);
636
+ $this->setOnSaleQueryArguments($query_arguments, $on_sale_products, $all_products);
637
+ $this->setCustomTaxonomyQueryArguments($query_arguments, $custom_taxonomies, $exclude_custom_taxonomies, $all_products);
638
+ $this->setProductsQueryArguments($query_arguments, $products, $exclude_products, $all_products);
639
+ $this->setQueryRelationship($query_arguments);
640
+ // echo "<pre>"; print_r($query_arguments); echo "</pre>"; die;
641
+ ob_start();
642
+ $products = new \WP_Query($query_arguments);
643
+ $columns = absint($short_code_attributes['columns']);
644
+ $woocommerce_loop['columns'] = $columns;
645
+ if ($products->have_posts()) {
646
+ self::$woocommerce_helper->setLoopProperties('is_shortcode', true);
647
+ self::$woocommerce_helper->setLoopProperties('is_paginated', (!empty($short_code_attributes['do_pagination'])));
648
+ self::$woocommerce_helper->setLoopProperties('per_page', $short_code_attributes['per_page']);
649
+ self::$woocommerce_helper->setLoopProperties('current_page', $paged);
650
+ $total = $products->found_posts;
651
+ self::$woocommerce_helper->setLoopProperties('total', $total);
652
+ $total_pages = ceil($total / $short_code_attributes['per_page']);
653
+ self::$woocommerce_helper->setLoopProperties('total_pages', $total_pages);
654
+ do_action('woocommerce_before_shop_loop');
655
+ self::$woocommerce_helper->productLoopStart();
656
+ while ($products->have_posts()) {
657
+ $products->the_post();
658
+ wc_get_template_part('content', 'product');
659
+ }
660
+ self::$woocommerce_helper->productLoopEnd();
661
+ do_action('woocommerce_after_shop_loop');
662
+ // woocommerce_pagination();
663
+ wp_reset_postdata();
664
+ } else {
665
+ do_action('woocommerce_no_products_found');
666
+ }
667
+ return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
668
+ }
669
+ return NULL;
670
+ }
671
+
672
+ function bannerContent(){
673
+ $awdr_banner_editer = self::$config->getConfig('awdr_banner_editor', '');
674
+ if(!empty($awdr_banner_editer) && $awdr_banner_editer != ''){
675
+ echo "<div class='awdr_banner_content'>".$awdr_banner_editer."</div>";
676
+ }else{
677
+ echo "<div class='awdr_banner_content'>"._e('No Banner Content', WDR_TEXT_DOMAIN);".</div>";
678
+ }
679
+ }
680
+ }
v2/App/Helpers/Filter.php ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ use Wdr\App\Controllers\Configuration;
6
+
7
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
8
+
9
+ class Filter
10
+ {
11
+ /**
12
+ * Match rule filters against product
13
+ * @param $product
14
+ * @param $type
15
+ * @param $method
16
+ * @param $values
17
+ * @param object $options
18
+ * @param array $cart_item
19
+ * @return bool
20
+ */
21
+ function match($product, $type, $method, $values, $options, $cart_item = array())
22
+ {
23
+ $config = new Configuration();
24
+ if (is_a($product, 'WC_Product')) {
25
+ $method = !empty($method) ? $method : 'in_list';
26
+ $product_id = Woocommerce::getProductId($product);
27
+ if ('all_products' === $type) {
28
+ return true;
29
+ } else if ('products' === $type) {
30
+ $apply_discount_to_child = apply_filters('advanced_woo_discount_rules_apply_discount_to_child', true, $product);
31
+ if ($apply_discount_to_child) {
32
+ if (isset($options->product_variants) && !empty($options->product_variants) && is_array($options->product_variants)) {
33
+ $values = Helper::combineProductArrays($values, $options->product_variants);
34
+ }
35
+ }
36
+ return $this->compareWithProducts($values, $method, $product_id, $product);
37
+ } elseif ('product_category' === $type) {
38
+ return $this->compareWithCategories($product, $values, $method);
39
+ } elseif ('product_tags' === $type) {
40
+ $product = Woocommerce::getParentProduct($product);
41
+ return $this->compareWithTags($product, $values, $method);
42
+ } elseif ('product_attributes' === $type) {
43
+ return $this->compareWithAttributes($product, $values, $method, $cart_item);
44
+ } elseif ('product_sku' === $type) {
45
+ return $this->compareWithSku($product, $values, $method);
46
+ } elseif ('product_on_sale' === $type) {
47
+ return $this->compareWithOnSale($product, $method);
48
+ } elseif (in_array($type, array_keys(Woocommerce::getCustomProductTaxonomies()))) {
49
+ return $this->compareWithCustomTaxonomy($product_id, $values, $method, $type);
50
+ }
51
+ }
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Match rule filters against product
57
+ * @param $product
58
+ * @param $filters array
59
+ * @param $sale_badge
60
+ * @return bool
61
+ */
62
+ function matchFilters($product, $filters, $sale_badge)
63
+ {
64
+ $rule = new Rule();
65
+ $status = false;
66
+ if (is_a($product, 'WC_Product')) {
67
+ $product_id = Woocommerce::getProductId($product);
68
+ if (!empty($filters)) {
69
+ foreach ($filters as $filter) {
70
+ $type = $rule->getFilterType($filter);
71
+ $method = $rule->getFilterMethod($filter);
72
+ $values = $rule->getFilterOptionValue($filter);
73
+ $options = $filter;
74
+ $cart_item = array();
75
+ $method = !empty($method) ? $method : 'in_list';
76
+ $processing_result = false;
77
+ if ('all_products' === $type) {
78
+ $status = true;
79
+ } else if ('products' === $type) {
80
+ $apply_discount_to_child = apply_filters('advanced_woo_discount_rules_apply_discount_to_variants', true);
81
+ if ($apply_discount_to_child) {
82
+ if (isset($options->product_variants) && !empty($options->product_variants) && is_array($options->product_variants)) {
83
+ $values = Helper::combineProductArrays($values, $options->product_variants);
84
+ }
85
+ if($sale_badge && isset($options->product_variants_for_sale_badge) && !empty($options->product_variants_for_sale_badge) && is_array($options->product_variants_for_sale_badge)){
86
+ $values = Helper::combineProductArrays($values, $options->product_variants_for_sale_badge);
87
+ }
88
+ }
89
+ $processing_result = $this->compareWithProducts($values, $method, $product_id, $product);
90
+ } elseif ('product_category' === $type) {
91
+ //$product = Woocommerce::getParentProduct($product);
92
+ $processing_result = $this->compareWithCategories($product, $values, $method);
93
+ } elseif ('product_tags' === $type) {
94
+ $product = Woocommerce::getParentProduct($product);
95
+ $processing_result = $this->compareWithTags($product, $values, $method);
96
+ } elseif ('product_attributes' === $type) {
97
+ //$product = Woocommerce::getParentProduct($product);
98
+ $processing_result = $this->compareWithAttributes($product, $values, $method, $cart_item);
99
+ } elseif ('product_sku' === $type) {
100
+ $processing_result = $this->compareWithSku($product, $values, $method);
101
+ } elseif ('product_on_sale' === $type) {
102
+ $processing_result = $this->compareWithOnSale($product, $method);
103
+ } elseif (in_array($type, array_keys(Woocommerce::getCustomProductTaxonomies()))) {
104
+ $parant_product_id = Woocommerce::getProductParentId($product);
105
+ if(!empty($parant_product_id)){
106
+ $product_id = $parant_product_id;
107
+ }
108
+ $processing_result = $this->compareWithCustomTaxonomy($product_id, $values, $method, $type);
109
+ }
110
+ if ($method === 'not_in_list') {
111
+ if (!$processing_result) {
112
+ $status = false;
113
+ break;
114
+ }
115
+ } else if ($processing_result) {
116
+ $status = true;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ // echo "<pre>"; var_dump($status); echo "</pre>"; die;
122
+ return $status;
123
+ }
124
+
125
+ protected function processInNotInList()
126
+ {
127
+ }
128
+
129
+ /**
130
+ * Compare product against Custom taxonomy Filter
131
+ * @param $product_id
132
+ * @param $operation_values
133
+ * @param $operation_method
134
+ * @param $taxonomy
135
+ * @return bool
136
+ */
137
+ protected function compareWithCustomTaxonomy($product_id, $operation_values, $operation_method, $taxonomy)
138
+ {
139
+ $term_ids = wp_get_post_terms($product_id, $taxonomy, array("fields" => "ids"));
140
+ $is_product_has_term = count(array_intersect($term_ids, $operation_values)) > 0;
141
+ if ('in_list' === $operation_method) {
142
+ return $is_product_has_term;
143
+ } elseif ('not_in_list' === $operation_method) {
144
+ return !$is_product_has_term;
145
+ }
146
+ return false;
147
+ }
148
+
149
+ /**
150
+ * Compare product against SKU Filter
151
+ * @param $product
152
+ * @param $operation_values
153
+ * @param $operation_method
154
+ * @return bool
155
+ */
156
+ protected function compareWithSku($product, $operation_values, $operation_method)
157
+ {
158
+ $result = false;
159
+ $product_sku = Woocommerce::getProductSku($product);
160
+ if ('in_list' === $operation_method) {
161
+ $result = (in_array($product_sku, $operation_values));
162
+ } elseif ('not_in_list' === $operation_method) {
163
+ $result = !(in_array($product_sku, $operation_values));
164
+ } elseif ('any' === $operation_method) {
165
+ $result = true;
166
+ }
167
+ return $result;
168
+ }
169
+
170
+ /**
171
+ * Compare product's tags against attribute filters
172
+ * @param $product
173
+ * @param $operation_values
174
+ * @param $operation_method
175
+ * @param $cart_item
176
+ * @return bool
177
+ */
178
+ protected function compareWithAttributes($product, $operation_values, $operation_method, $cart_item)
179
+ {
180
+ $attrs = Woocommerce::getProductAttributes($product);
181
+ $attr_ids = array();
182
+ if (Woocommerce::productTypeIs($product, 'variation')) {
183
+ if (count(array_filter($attrs)) < count($attrs)) {
184
+ if (isset($cart_item['variation'])) {
185
+ $attrs = array();
186
+ foreach ($cart_item['variation'] as $attribute_name => $value) {
187
+ $attrs[str_replace('attribute_', '', $attribute_name)] = $value;
188
+ }
189
+ }
190
+ }
191
+ foreach ($attrs as $taxonomy => $value) {
192
+ if ($value) {
193
+ $term_obj = get_term_by('slug', $value, $taxonomy);
194
+ if (!is_wp_error($term_obj) && $term_obj && $term_obj->name) {
195
+ $attr_ids = array_merge($attr_ids, (array)($term_obj->term_id));
196
+ }
197
+ } else {
198
+ $product_variation = Woocommerce::getProduct(Woocommerce::getProductParentId($product));
199
+ $attrs_variation = Woocommerce::getProductAttributes($product_variation);
200
+ foreach ($attrs_variation as $attr) {
201
+ if ($taxonomy == Woocommerce::getAttributeName($attr))
202
+ $attr_ids = array_merge($attr_ids, Woocommerce::getAttributeOption($attr));
203
+ }
204
+ }
205
+ }
206
+ } else {
207
+ foreach ($attrs as $attr) {
208
+ $attr_ids = array_merge($attr_ids, Woocommerce::getAttributeOption($attr));
209
+ }
210
+ }
211
+ $attr_ids = array_unique($attr_ids);
212
+ $is_product_has_attrs = count(array_intersect($attr_ids, $operation_values)) > 0;
213
+ if ('in_list' === $operation_method) {
214
+ return $is_product_has_attrs;
215
+ } elseif ('not_in_list' === $operation_method) {
216
+ return !$is_product_has_attrs;
217
+ }
218
+ return false;
219
+ }
220
+
221
+ /**
222
+ * Compare product's tags against tag filters
223
+ * @param $product
224
+ * @param $operation_values
225
+ * @param $operation_method
226
+ * @return bool
227
+ */
228
+ protected function compareWithTags($product, $operation_values, $operation_method)
229
+ {
230
+ $tag_ids = Woocommerce::getProductTags($product);
231
+ $is_product_has_tag = count(array_intersect($tag_ids, $operation_values)) > 0;
232
+ if ('in_list' === $operation_method) {
233
+ return $is_product_has_tag;
234
+ } elseif ('not_in_list' === $operation_method) {
235
+ return !$is_product_has_tag;
236
+ }
237
+ return false;
238
+ }
239
+
240
+ /**
241
+ * Compare product's categories against category filters
242
+ * @param $product
243
+ * @param $operation_values
244
+ * @param $operation_method
245
+ * @return bool
246
+ */
247
+ protected function compareWithCategories($product, $operation_values, $operation_method)
248
+ {
249
+ $categories = Woocommerce::getProductCategories($product);
250
+ $is_product_in_category = count(array_intersect($categories, $operation_values)) > 0;
251
+ if ('in_list' === $operation_method) {
252
+ return $is_product_in_category;
253
+ } elseif ('not_in_list' === $operation_method) {
254
+ return !$is_product_in_category;
255
+ }
256
+ return false;
257
+ }
258
+
259
+ /**
260
+ * Compare products against product filter values
261
+ * @param $operation_values
262
+ * @param $operation_method
263
+ * @param $product_id
264
+ * @param $product
265
+ * @return bool
266
+ */
267
+ protected function compareWithProducts($operation_values, $operation_method, $product_id, $product)
268
+ {
269
+ $result = $this->checkInList($product_id, $operation_method, $operation_values);
270
+ if($operation_method == 'not_in_list'){
271
+ if (!$result) {
272
+ return false;
273
+ }
274
+ } else {
275
+ if ($result) {
276
+ return true;
277
+ }
278
+ }
279
+ $apply_discount_to_child = apply_filters('advanced_woo_discount_rules_apply_discount_to_variants', true);
280
+ $parent_id = Woocommerce::getProductParentId($product);
281
+ if (!empty($apply_discount_to_child) && !empty($parent_id)) {
282
+ $product_id = $parent_id;
283
+ }
284
+ $result = $this->checkInList($product_id, $operation_method, $operation_values);
285
+ return $result;
286
+ }
287
+
288
+ /**
289
+ * Compare products against product is on sale values
290
+ * @param $product
291
+ * @param $operation_method
292
+ * @return bool
293
+ */
294
+ protected function compareWithOnSale($product, $operation_method)
295
+ {
296
+ if ('in_list' === $operation_method) {
297
+ return (Woocommerce::isProductInSale($product)) ? true : false;
298
+ } elseif ('not_in_list' === $operation_method) {
299
+ return (Woocommerce::isProductInSale($product)) ? false : true;
300
+ } elseif ('any' === $operation_method) {
301
+ return false;
302
+ }
303
+
304
+ }
305
+
306
+ /**
307
+ * Check product in list
308
+ * @param $product_id
309
+ * @param $operation_method
310
+ * @param $operation_values
311
+ * @return bool
312
+ */
313
+ function checkInList($product_id, $operation_method, $operation_values)
314
+ {
315
+ $result = false;
316
+ if ('in_list' === $operation_method) {
317
+ $result = (in_array($product_id, $operation_values));
318
+ } elseif ('not_in_list' === $operation_method) {
319
+ $result = !(in_array($product_id, $operation_values));
320
+ } elseif ('any' === $operation_method) {
321
+ $result = true;
322
+ }
323
+ return $result;
324
+ }
325
+ }
v2/App/Helpers/Helper.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class Helper
8
+ {
9
+ /**
10
+ * Combine two array with unique values
11
+ *
12
+ * @param $products array
13
+ * @param $additional_products array
14
+ * @return array
15
+ * */
16
+ public static function combineProductArrays($products, $additional_products){
17
+ $products = array_merge($products, $additional_products);
18
+ $products = array_unique($products);
19
+
20
+ return $products;
21
+ }
22
+
23
+ /**
24
+ * Check has pro version
25
+ *
26
+ * @return boolean
27
+ * */
28
+ public static function hasPro(){
29
+ if (defined('WDR_PRO'))
30
+ if(WDR_PRO === true) return true;
31
+
32
+ return false;
33
+ }
34
+
35
+ /**
36
+ * Format price
37
+ *
38
+ * @param $data mixed
39
+ * @return mixed
40
+ * */
41
+ public static function formatAllPrices($data){
42
+ if(is_array($data)){
43
+ if(isset($data['initial_price']) && !isset($data['initial_price_html'])){
44
+ $data['initial_price_html'] = Woocommerce::formatPrice($data['initial_price']);
45
+ }
46
+ if(isset($data['discounted_price']) && !isset($data['discounted_price_html'])){
47
+ $data['discounted_price_html'] = Woocommerce::formatPrice($data['discounted_price']);
48
+ }
49
+ if(isset($data['initial_price_with_tax']) && !isset($data['initial_price_with_tax_html'])){
50
+ $data['initial_price_with_tax_html'] = Woocommerce::formatPrice($data['initial_price_with_tax']);
51
+ }
52
+ if(isset($data['discounted_price_with_tax']) && !isset($data['discounted_price_with_tax_html'])){
53
+ $data['discounted_price_with_tax_html'] = Woocommerce::formatPrice($data['discounted_price_with_tax']);
54
+ }
55
+ if(!isset($data['currency_symbol'])){
56
+ $data['currency_symbol'] = Woocommerce::get_currency_symbol();
57
+ }
58
+ }
59
+
60
+ return $data;
61
+ }
62
+
63
+ /**
64
+ * Get template override
65
+ * @param string $template_name
66
+ * @param string $folder
67
+ * @return string
68
+ * */
69
+ public static function getTemplateOverride($template_name, $folder = ''){
70
+ if(!empty($folder)){
71
+ $path = trailingslashit('woo-discount-rules') .$folder."/".$template_name;
72
+ } else {
73
+ $path = trailingslashit( 'woo-discount-rules' ) . $template_name;
74
+ }
75
+ $template = locate_template(
76
+ array(
77
+ $path,
78
+ $template_name,
79
+ )
80
+ );
81
+
82
+ return $template;
83
+ }
84
+
85
+ /**
86
+ * Get template path
87
+ *
88
+ * @param $template_name string
89
+ * @param $default_path string
90
+ * @param $folder string
91
+ * @return string
92
+ * */
93
+ public static function getTemplatePath($template_name, $default_path, $folder = ''){
94
+ $path_from_template = self::getTemplateOverride($template_name, $folder);
95
+ if($path_from_template) $default_path = $path_from_template;
96
+
97
+ return $default_path;
98
+ }
99
+
100
+ /**
101
+ * Is Cart item is consider for discount calculation
102
+ *
103
+ * @param $status bool
104
+ * @param $cart_item array
105
+ * @param $type string
106
+ * @return bool
107
+ * */
108
+ public static function isCartItemConsideredForCalculation($status, $cart_item, $type){
109
+ return apply_filters('advanced_woo_discount_rules_include_cart_item_to_count_quantity', $status, $cart_item, $type);
110
+ }
111
+ }
v2/App/Helpers/Input.php ADDED
@@ -0,0 +1,1000 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class Input
8
+ {
9
+ /**
10
+ * Character set
11
+ *
12
+ * Will be overridden by the constructor.
13
+ *
14
+ * @var string
15
+ */
16
+ public $charset = 'UTF-8';
17
+ /**
18
+ * IP address of the current user
19
+ *
20
+ * @var string
21
+ */
22
+ protected $ip_address = FALSE;
23
+ /**
24
+ * Allow GET array flag
25
+ *
26
+ * If set to FALSE, then $_GET will be set to an empty array.
27
+ *
28
+ * @var bool
29
+ */
30
+ protected $_allow_get_array = TRUE;
31
+ /**
32
+ * Standardize new lines flag
33
+ *
34
+ * If set to TRUE, then newlines are standardized.
35
+ *
36
+ * @var bool
37
+ */
38
+ protected $_standardize_newlines;
39
+ /**
40
+ * Enable XSS flag
41
+ *
42
+ * Determines whether the XSS filter is always active when
43
+ * GET, POST or COOKIE data is encountered.
44
+ * Set automatically based on config setting.
45
+ *
46
+ * @var bool
47
+ */
48
+ protected $_enable_xss = TRUE;
49
+ /**
50
+ * List of all HTTP request headers
51
+ *
52
+ * @var array
53
+ */
54
+ protected $headers = array();
55
+ /**
56
+ * Raw input stream data
57
+ *
58
+ * Holds a cache of php://input contents
59
+ *
60
+ * @var string
61
+ */
62
+ protected $_raw_input_stream;
63
+ /**
64
+ * List of never allowed strings
65
+ *
66
+ * @var array
67
+ */
68
+ protected $_never_allowed_str = array(
69
+ 'document.cookie' => '[removed]',
70
+ '(document).cookie' => '[removed]',
71
+ 'document.write' => '[removed]',
72
+ '(document).write' => '[removed]',
73
+ '.parentNode' => '[removed]',
74
+ '.innerHTML' => '[removed]',
75
+ '-moz-binding' => '[removed]',
76
+ '<!--' => '&lt;!--',
77
+ '-->' => '--&gt;',
78
+ '<![CDATA[' => '&lt;![CDATA[',
79
+ '<comment>' => '&lt;comment&gt;',
80
+ '<%' => '&lt;&#37;'
81
+ );
82
+ /**
83
+ * List of never allowed regex replacements
84
+ *
85
+ * @var array
86
+ */
87
+ protected $_never_allowed_regex = array(
88
+ 'javascript\s*:',
89
+ '(\(?document\)?|\(?window\)?(\.document)?)\.(location|on\w*)',
90
+ 'expression\s*(\(|&\#40;)', // CSS and IE
91
+ 'vbscript\s*:', // IE, surprise!
92
+ 'wscript\s*:', // IE
93
+ 'jscript\s*:', // IE
94
+ 'vbs\s*:', // IE
95
+ 'Redirect\s+30\d',
96
+ "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
97
+ );
98
+ /**
99
+ * XSS Hash
100
+ *
101
+ * Random Hash for protecting URLs.
102
+ *
103
+ * @var string
104
+ */
105
+ protected $_xss_hash;
106
+ /**
107
+ * Parsed input stream data
108
+ *
109
+ * Parsed from php://input at runtime
110
+ *
111
+ * @see CI_Input::input_stream()
112
+ * @var array
113
+ */
114
+ protected $_input_stream;
115
+ protected $security;
116
+ protected $uni;
117
+
118
+ /**
119
+ * Input constructor.
120
+ */
121
+ function __construct()
122
+ {
123
+ // Sanitize global arrays
124
+ $this->_sanitize_globals();
125
+ }
126
+
127
+ /**
128
+ * Sanitize Globals
129
+ */
130
+ protected function _sanitize_globals()
131
+ {
132
+ // Is $_GET data allowed? If not we'll set the $_GET to an empty array
133
+ if ($this->_allow_get_array === FALSE) {
134
+ $_GET = array();
135
+ } elseif (is_array($_GET)) {
136
+ foreach ($_GET as $key => $val) {
137
+ $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
138
+ }
139
+ }
140
+ // Clean $_POST Data
141
+ if (is_array($_POST)) {
142
+ foreach ($_POST as $key => $val) {
143
+ $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
144
+ }
145
+ }
146
+ // Clean $_COOKIE Data
147
+ if (is_array($_COOKIE)) {
148
+ // Also get rid of specially treated cookies that might be set by a server
149
+ // or silly application, that are of no use to a CI application anyway
150
+ // but that when present will trip our 'Disallowed Key Characters' alarm
151
+ // http://www.ietf.org/rfc/rfc2109.txt
152
+ // note that the key names below are single quoted strings, and are not PHP variables
153
+ unset(
154
+ $_COOKIE['$Version'],
155
+ $_COOKIE['$Path'],
156
+ $_COOKIE['$Domain']
157
+ );
158
+ foreach ($_COOKIE as $key => $val) {
159
+ if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE) {
160
+ $_COOKIE[$cookie_key] = $this->_clean_input_data($val);
161
+ } else {
162
+ unset($_COOKIE[$key]);
163
+ }
164
+ }
165
+ }
166
+ // Sanitize PHP_SELF
167
+ $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
168
+ }
169
+
170
+ /**
171
+ * Clean Keys
172
+ * @param $str
173
+ * @param bool $fatal
174
+ * @return bool
175
+ */
176
+ protected function _clean_input_keys($str, $fatal = TRUE)
177
+ {
178
+ if (!preg_match('/^[a-z0-9:_\/|-]+$/i', $str)) {
179
+ if ($fatal === TRUE) {
180
+ return FALSE;
181
+ } else {
182
+ $this->set_status_header(503);
183
+ echo 'Disallowed Key Characters.';
184
+ exit(7); // EXIT_USER_INPUT
185
+ }
186
+ }
187
+ return $str;
188
+ }
189
+
190
+ /**
191
+ * Set HTTP Status Header
192
+ * @param int $code
193
+ * @param string $text
194
+ */
195
+ function set_status_header($code = 200, $text = '')
196
+ {
197
+ if (empty($text)) {
198
+ is_int($code) OR $code = (int)$code;
199
+ $stati = array(
200
+ 100 => 'Continue',
201
+ 101 => 'Switching Protocols',
202
+ 200 => 'OK',
203
+ 201 => 'Created',
204
+ 202 => 'Accepted',
205
+ 203 => 'Non-Authoritative Information',
206
+ 204 => 'No Content',
207
+ 205 => 'Reset Content',
208
+ 206 => 'Partial Content',
209
+ 300 => 'Multiple Choices',
210
+ 301 => 'Moved Permanently',
211
+ 302 => 'Found',
212
+ 303 => 'See Other',
213
+ 304 => 'Not Modified',
214
+ 305 => 'Use Proxy',
215
+ 307 => 'Temporary Redirect',
216
+ 400 => 'Bad Request',
217
+ 401 => 'Unauthorized',
218
+ 402 => 'Payment Required',
219
+ 403 => 'Forbidden',
220
+ 404 => 'Not Found',
221
+ 405 => 'Method Not Allowed',
222
+ 406 => 'Not Acceptable',
223
+ 407 => 'Proxy Authentication Required',
224
+ 408 => 'Request Timeout',
225
+ 409 => 'Conflict',
226
+ 410 => 'Gone',
227
+ 411 => 'Length Required',
228
+ 412 => 'Precondition Failed',
229
+ 413 => 'Request Entity Too Large',
230
+ 414 => 'Request-URI Too Long',
231
+ 415 => 'Unsupported Media Type',
232
+ 416 => 'Requested Range Not Satisfiable',
233
+ 417 => 'Expectation Failed',
234
+ 422 => 'Unprocessable Entity',
235
+ 426 => 'Upgrade Required',
236
+ 428 => 'Precondition Required',
237
+ 429 => 'Too Many Requests',
238
+ 431 => 'Request Header Fields Too Large',
239
+ 500 => 'Internal Server Error',
240
+ 501 => 'Not Implemented',
241
+ 502 => 'Bad Gateway',
242
+ 503 => 'Service Unavailable',
243
+ 504 => 'Gateway Timeout',
244
+ 505 => 'HTTP Version Not Supported',
245
+ 511 => 'Network Authentication Required',
246
+ );
247
+ if (isset($stati[$code])) {
248
+ $text = $stati[$code];
249
+ }
250
+ }
251
+ $server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2'), TRUE))
252
+ ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
253
+ header($server_protocol . ' ' . $code . ' ' . $text, TRUE, $code);
254
+ }
255
+
256
+ /**
257
+ * Clean Input Data
258
+ * @param $str
259
+ * @return array|string|string[]|null
260
+ */
261
+ protected function _clean_input_data($str)
262
+ {
263
+ if (is_array($str)) {
264
+ $new_array = array();
265
+ foreach (array_keys($str) as $key) {
266
+ $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
267
+ }
268
+ return $new_array;
269
+ }
270
+ /* We strip slashes if magic quotes is on to keep things consistent
271
+
272
+ NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
273
+ it will probably not exist in future versions at all.
274
+ */
275
+ if (!$this->is_php('5.4') && get_magic_quotes_gpc()) {
276
+ $str = stripslashes($str);
277
+ }
278
+ // Remove control characters
279
+ $str = $this->remove_invisible_characters($str, FALSE);
280
+ // Standardize newlines if needed
281
+ if ($this->_standardize_newlines === TRUE) {
282
+ return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
283
+ }
284
+ return $str;
285
+ }
286
+
287
+ /**
288
+ * Determines if the current version of PHP is equal to or greater than the supplied value
289
+ * @param $version
290
+ * @return mixed
291
+ */
292
+ function is_php($version)
293
+ {
294
+ static $_is_php;
295
+ $version = (string)$version;
296
+ if (!isset($_is_php[$version])) {
297
+ $_is_php[$version] = version_compare(PHP_VERSION, $version, '>=');
298
+ }
299
+ return $_is_php[$version];
300
+ }
301
+
302
+ /**
303
+ * Remove Invisible Characters
304
+ * @param $str
305
+ * @param bool $url_encoded
306
+ * @return string|string[]|null
307
+ */
308
+ function remove_invisible_characters($str, $url_encoded = TRUE)
309
+ {
310
+ $non_displayables = array();
311
+ // every control character except newline (dec 10),
312
+ // carriage return (dec 13) and horizontal tab (dec 09)
313
+ if ($url_encoded) {
314
+ $non_displayables[] = '/%0[0-8bcef]/i'; // url encoded 00-08, 11, 12, 14, 15
315
+ $non_displayables[] = '/%1[0-9a-f]/i'; // url encoded 16-31
316
+ $non_displayables[] = '/%7f/i'; // url encoded 127
317
+ }
318
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
319
+ do {
320
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
321
+ } while ($count);
322
+ return $str;
323
+ }
324
+
325
+ /**
326
+ * Fetch an item from POST data with fallback to GET
327
+ * @param $index
328
+ * @param null $xss_clean
329
+ * @param null $default
330
+ * @return mixed
331
+ */
332
+ function post_get($index, $default = NULL, $xss_clean = NULL)
333
+ {
334
+ return isset($_POST[$index])
335
+ ? $this->post($index, $default, $xss_clean)
336
+ : $this->get($index, $default, $xss_clean);
337
+ }
338
+
339
+ /**
340
+ * Fetch an item from the POST array
341
+ * @param null $index
342
+ * @param null $default
343
+ * @param null $xss_clean
344
+ * @return mixed
345
+ */
346
+ function post($index = NULL, $default = NULL, $xss_clean = NULL)
347
+ {
348
+ return $this->_fetch_from_array($_POST, $index, $default, $xss_clean);
349
+ }
350
+
351
+ /**
352
+ * Fetch from array
353
+ * @param $array
354
+ * @param null $index
355
+ * @param null $default
356
+ * @param null $xss_clean
357
+ * @return array|string|null
358
+ */
359
+ protected function _fetch_from_array(&$array, $index = NULL, $default = NULL, $xss_clean = NULL)
360
+ {
361
+ is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
362
+ // If $index is NULL, it means that the whole $array is requested
363
+ $index = (!isset($index) || is_null($index)) ? array_keys($array) : $index;
364
+ // allow fetching multiple keys at once
365
+ if (is_array($index)) {
366
+ $output = array();
367
+ foreach ($index as $key) {
368
+ $output[$key] = $this->_fetch_from_array($array, $key, $default, $xss_clean);
369
+ }
370
+ return $output;
371
+ }
372
+ if (isset($array[$index])) {
373
+ $value = $array[$index];
374
+ } elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
375
+ {
376
+ $value = $array;
377
+ for ($i = 0; $i < $count; $i++) {
378
+ $key = trim($matches[0][$i], '[]');
379
+ if ($key === '') // Empty notation will return the value as array
380
+ {
381
+ break;
382
+ }
383
+ if (isset($value[$key])) {
384
+ $value = $value[$key];
385
+ } else {
386
+ return NULL;
387
+ }
388
+ }
389
+ } else {
390
+ return $default;
391
+ }
392
+ return ($xss_clean === TRUE) ? $this->xss_clean($value) : $value;
393
+ }
394
+
395
+ /**
396
+ * XSS Clean
397
+ * @param $str
398
+ * @param bool $is_image
399
+ * @return array|bool|string|string[]|null
400
+ */
401
+ function xss_clean($str, $is_image = FALSE)
402
+ {
403
+ // Is the string an array?
404
+ if (is_array($str)) {
405
+ foreach ($str as $key => &$value) {
406
+ $str[$key] = $this->xss_clean($value);
407
+ }
408
+ return $str;
409
+ }
410
+ // Remove Invisible Characters
411
+ $str = $this->remove_invisible_characters($str);
412
+ /*
413
+ * URL Decode
414
+ *
415
+ * Just in case stuff like this is submitted:
416
+ *
417
+ * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
418
+ *
419
+ * Note: Use rawurldecode() so it does not remove plus signs
420
+ */
421
+ if (stripos($str, '%') !== false) {
422
+ do {
423
+ $oldstr = $str;
424
+ $str = rawurldecode($str);
425
+ $str = preg_replace_callback('#%(?:\s*[0-9a-f]){2,}#i', array($this, '_urldecodespaces'), $str);
426
+ } while ($oldstr !== $str);
427
+ unset($oldstr);
428
+ }
429
+ /*
430
+ * Convert character entities to ASCII
431
+ *
432
+ * This permits our tests below to work reliably.
433
+ * We only convert entities that are within tags since
434
+ * these are the ones that will pose security problems.
435
+ */
436
+ $str = preg_replace_callback("/[^a-z0-9>]+[a-z0-9]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
437
+ $str = preg_replace_callback('/<\w+.*/si', array($this, '_decode_entity'), $str);
438
+ // Remove Invisible Characters Again!
439
+ $str = $this->remove_invisible_characters($str);
440
+ /*
441
+ * Convert all tabs to spaces
442
+ *
443
+ * This prevents strings like this: ja vascript
444
+ * NOTE: we deal with spaces between characters later.
445
+ * NOTE: preg_replace was found to be amazingly slow here on
446
+ * large blocks of data, so we use str_replace.
447
+ */
448
+ $str = str_replace("\t", ' ', $str);
449
+ // Capture converted string for later comparison
450
+ $converted_string = $str;
451
+ // Remove Strings that are never allowed
452
+ $str = $this->_do_never_allowed($str);
453
+ /*
454
+ * Makes PHP tags safe
455
+ *
456
+ * Note: XML tags are inadvertently replaced too:
457
+ *
458
+ * <?xml
459
+ *
460
+ * But it doesn't seem to pose a problem.
461
+ */
462
+ if ($is_image === TRUE) {
463
+ // Images have a tendency to have the PHP short opening and
464
+ // closing tags every so often so we skip those and only
465
+ // do the long opening tags.
466
+ $str = preg_replace('/<\?(php)/i', '&lt;?\\1', $str);
467
+ } else {
468
+ $str = str_replace(array('<?', '?' . '>'), array('&lt;?', '?&gt;'), $str);
469
+ }
470
+ /*
471
+ * Compact any exploded words
472
+ *
473
+ * This corrects words like: j a v a s c r i p t
474
+ * These words are compacted back to their correct state.
475
+ */
476
+ $words = array(
477
+ 'javascript', 'expression', 'vbscript', 'jscript', 'wscript',
478
+ 'vbs', 'script', 'base64', 'applet', 'alert', 'document',
479
+ 'write', 'cookie', 'window', 'confirm', 'prompt', 'eval'
480
+ );
481
+ foreach ($words as $word) {
482
+ $word = implode('\s*', str_split($word)) . '\s*';
483
+ // We only want to do this when it is followed by a non-word character
484
+ // That way valid stuff like "dealer to" does not become "dealerto"
485
+ $str = preg_replace_callback('#(' . substr($word, 0, -3) . ')(\W)#is', array($this, '_compact_exploded_words'), $str);
486
+ }
487
+ /*
488
+ * Remove disallowed Javascript in links or img tags
489
+ * We used to do some version comparisons and use of stripos(),
490
+ * but it is dog slow compared to these simplified non-capturing
491
+ * preg_match(), especially if the pattern exists in the string
492
+ *
493
+ * Note: It was reported that not only space characters, but all in
494
+ * the following pattern can be parsed as separators between a tag name
495
+ * and its attributes: [\d\s"\'`;,\/\=\(\x00\x0B\x09\x0C]
496
+ * ... however, remove_invisible_characters() above already strips the
497
+ * hex-encoded ones, so we'll skip them below.
498
+ */
499
+ do {
500
+ $original = $str;
501
+ if (preg_match('/<a/i', $str)) {
502
+ $str = preg_replace_callback('#<a(?:rea)?[^a-z0-9>]+([^>]*?)(?:>|$)#si', array($this, '_js_link_removal'), $str);
503
+ }
504
+ if (preg_match('/<img/i', $str)) {
505
+ $str = preg_replace_callback('#<img[^a-z0-9]+([^>]*?)(?:\s?/?>|$)#si', array($this, '_js_img_removal'), $str);
506
+ }
507
+ if (preg_match('/script|xss/i', $str)) {
508
+ $str = preg_replace('#</*(?:script|xss).*?>#si', '[removed]', $str);
509
+ }
510
+ } while ($original !== $str);
511
+ unset($original);
512
+ /*
513
+ * Sanitize naughty HTML elements
514
+ *
515
+ * If a tag containing any of the words in the list
516
+ * below is found, the tag gets converted to entities.
517
+ *
518
+ * So this: <blink>
519
+ * Becomes: &lt;blink&gt;
520
+ */
521
+ $pattern = '#'
522
+ . '<((?<slash>/*\s*)((?<tagName>[a-z0-9]+)(?=[^a-z0-9]|$)|.+)' // tag start and name, followed by a non-tag character
523
+ . '[^\s\042\047a-z0-9>/=]*' // a valid attribute character immediately after the tag would count as a separator
524
+ // optional attributes
525
+ . '(?<attributes>(?:[\s\042\047/=]*' // non-attribute characters, excluding > (tag close) for obvious reasons
526
+ . '[^\s\042\047>/=]+' // attribute characters
527
+ // optional attribute-value
528
+ . '(?:\s*=' // attribute-value separator
529
+ . '(?:[^\s\042\047=><`]+|\s*\042[^\042]*\042|\s*\047[^\047]*\047|\s*(?U:[^\s\042\047=><`]*))' // single, double or non-quoted value
530
+ . ')?' // end optional attribute-value group
531
+ . ')*)' // end optional attributes group
532
+ . '[^>]*)(?<closeTag>\>)?#isS';
533
+ // Note: It would be nice to optimize this for speed, BUT
534
+ // only matching the naughty elements here results in
535
+ // false positives and in turn - vulnerabilities!
536
+ do {
537
+ $old_str = $str;
538
+ $str = preg_replace_callback($pattern, array($this, '_sanitize_naughty_html'), $str);
539
+ } while ($old_str !== $str);
540
+ unset($old_str);
541
+ /*
542
+ * Sanitize naughty scripting elements
543
+ *
544
+ * Similar to above, only instead of looking for
545
+ * tags it looks for PHP and JavaScript commands
546
+ * that are disallowed. Rather than removing the
547
+ * code, it simply converts the parenthesis to entities
548
+ * rendering the code un-executable.
549
+ *
550
+ * For example: eval('some code')
551
+ * Becomes: eval&#40;'some code'&#41;
552
+ */
553
+ $str = preg_replace(
554
+ '#(alert|prompt|confirm|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si',
555
+ '\\1\\2&#40;\\3&#41;',
556
+ $str
557
+ );
558
+ // Same thing, but for "tag functions" (e.g. eval`some code`)
559
+ // See https://github.com/bcit-ci/CodeIgniter/issues/5420
560
+ $str = preg_replace(
561
+ '#(alert|prompt|confirm|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)`(.*?)`#si',
562
+ '\\1\\2&#96;\\3&#96;',
563
+ $str
564
+ );
565
+ // Final clean up
566
+ // This adds a bit of extra precaution in case
567
+ // something got through the above filters
568
+ $str = $this->_do_never_allowed($str);
569
+ /*
570
+ * Images are Handled in a Special Way
571
+ * - Essentially, we want to know that after all of the character
572
+ * conversion is done whether any unwanted, likely XSS, code was found.
573
+ * If not, we return TRUE, as the image is clean.
574
+ * However, if the string post-conversion does not matched the
575
+ * string post-removal of XSS, then it fails, as there was unwanted XSS
576
+ * code found and removed/changed during processing.
577
+ */
578
+ if ($is_image === TRUE) {
579
+ return ($str === $converted_string);
580
+ }
581
+ return $str;
582
+ }
583
+
584
+ /**
585
+ * Do Never Allowed
586
+ * @param $str
587
+ * @return mixed|string|string[]|null
588
+ */
589
+ protected
590
+ function _do_never_allowed($str)
591
+ {
592
+ $str = str_replace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str);
593
+ foreach ($this->_never_allowed_regex as $regex) {
594
+ $str = preg_replace('#' . $regex . '#is', '[removed]', $str);
595
+ }
596
+ return $str;
597
+ }
598
+
599
+ /**
600
+ * Fetch an item from the GET array
601
+ * @param null $index
602
+ * @param null $default
603
+ * @param null $xss_clean
604
+ * @return mixed
605
+ */
606
+ function get($index = NULL, $default = NULL, $xss_clean = NULL)
607
+ {
608
+ return $this->_fetch_from_array($_GET, $index, $default, $xss_clean);
609
+ }
610
+
611
+ /**
612
+ * Fetch an item from GET data with fallback to POST
613
+ * @param $index
614
+ * @param null $xss_clean
615
+ * @param null $default
616
+ * @return mixed
617
+ */
618
+ function get_post($index, $default = NULL, $xss_clean = NULL)
619
+ {
620
+ return isset($_GET[$index])
621
+ ? $this->get($index, $default, $xss_clean)
622
+ : $this->post($index, $default, $xss_clean);
623
+ }
624
+
625
+ /**
626
+ * Fetch an item from the COOKIE array
627
+ * @param null $index
628
+ * @param null $default
629
+ * @param null $xss_clean
630
+ * @return mixed
631
+ */
632
+ function cookie($index = NULL, $default = NULL, $xss_clean = NULL)
633
+ {
634
+ return $this->_fetch_from_array($_COOKIE, $index, $default, $xss_clean);
635
+ }
636
+
637
+ /**
638
+ * Fetch an item from the php://input stream
639
+ * @param null $index
640
+ * @param null $default
641
+ * @param null $xss_clean
642
+ * @return mixed
643
+ */
644
+ function input_stream($index = NULL, $default = NULL, $xss_clean = NULL)
645
+ {
646
+ // Prior to PHP 5.6, the input stream can only be read once,
647
+ // so we'll need to check if we have already done that first.
648
+ if (!is_array($this->_input_stream)) {
649
+ // $this->raw_input_stream will trigger __get().
650
+ parse_str($this->_raw_input_stream, $this->_input_stream);
651
+ is_array($this->_input_stream) OR $this->_input_stream = array();
652
+ }
653
+ return $this->_fetch_from_array($this->_input_stream, $index, $default, $xss_clean);
654
+ }
655
+
656
+ /**
657
+ * Fetch User Agent string
658
+ * @param null $xss_clean
659
+ * @param null $default
660
+ * @return mixed
661
+ */
662
+ function user_agent($xss_clean = NULL, $default = NULL)
663
+ {
664
+ return $this->_fetch_from_array($_SERVER, 'HTTP_USER_AGENT', $default, $xss_clean);
665
+ }
666
+
667
+ /**
668
+ * Get Request Header
669
+ * @param $index
670
+ * @param bool $xss_clean
671
+ * @return string|null
672
+ */
673
+ function get_request_header($index, $xss_clean = FALSE)
674
+ {
675
+ static $headers;
676
+ if (!isset($headers)) {
677
+ empty($this->headers) && $this->request_headers();
678
+ foreach ($this->headers as $key => $value) {
679
+ $headers[strtolower($key)] = $value;
680
+ }
681
+ }
682
+ $index = strtolower($index);
683
+ if (!isset($headers[$index])) {
684
+ return NULL;
685
+ }
686
+ return ($xss_clean === TRUE)
687
+ ? $this->xss_clean($headers[$index])
688
+ : $headers[$index];
689
+ }
690
+
691
+ /**
692
+ * Request Headers
693
+ * @param bool $xss_clean
694
+ * @return mixed
695
+ */
696
+ function request_headers($xss_clean = FALSE)
697
+ {
698
+ // If header is already defined, return it immediately
699
+ if (!empty($this->headers)) {
700
+ return $this->_fetch_from_array($this->headers, NULL, NULL, $xss_clean);
701
+ }
702
+ // In Apache, you can simply call apache_request_headers()
703
+ if (function_exists('apache_request_headers')) {
704
+ $this->headers = apache_request_headers();
705
+ } else {
706
+ isset($_SERVER['CONTENT_TYPE']) && $this->headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
707
+ foreach ($_SERVER as $key => $val) {
708
+ if (sscanf($key, 'HTTP_%s', $header) === 1) {
709
+ // take SOME_HEADER and turn it into Some-Header
710
+ $header = str_replace('_', ' ', strtolower($header));
711
+ $header = str_replace(' ', '-', ucwords($header));
712
+ $this->headers[$header] = $_SERVER[$key];
713
+ }
714
+ }
715
+ }
716
+ return $this->_fetch_from_array($this->headers, NULL, NULL, $xss_clean);
717
+ }
718
+
719
+ /**
720
+ * Is AJAX request?
721
+ * @return bool
722
+ */
723
+ function is_ajax_request()
724
+ {
725
+ return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
726
+ }
727
+
728
+ /**
729
+ * Get Request Method
730
+ * @param bool $upper
731
+ * @return string
732
+ */
733
+ function method($upper = FALSE)
734
+ {
735
+ return ($upper)
736
+ ? strtoupper($this->server('REQUEST_METHOD'))
737
+ : strtolower($this->server('REQUEST_METHOD'));
738
+ }
739
+
740
+ /**
741
+ * Fetch an item from the SERVER array
742
+ * @param $index
743
+ * @param null $xss_clean
744
+ * @param null $default
745
+ * @return mixed
746
+ */
747
+ function server($index, $default = NULL, $xss_clean = NULL)
748
+ {
749
+ return $this->_fetch_from_array($_SERVER, $index, $default, $xss_clean);
750
+ }
751
+
752
+ /**
753
+ * Allows read access to protected properties
754
+ * @param $name
755
+ * @return false|string
756
+ */
757
+ function __get($name)
758
+ {
759
+ if ($name === 'raw_input_stream') {
760
+ isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input');
761
+ return $this->_raw_input_stream;
762
+ } elseif ($name === 'ip_address') {
763
+ return $this->ip_address;
764
+ }
765
+ }
766
+
767
+ /**
768
+ * URL-decode taking spaces into account
769
+ * @param $matches
770
+ * @return string
771
+ */
772
+ protected
773
+ function _urldecodespaces($matches)
774
+ {
775
+ $input = $matches[0];
776
+ $nospaces = preg_replace('#\s+#', '', $input);
777
+ return ($nospaces === $input)
778
+ ? $input
779
+ : rawurldecode($nospaces);
780
+ }
781
+
782
+ /**
783
+ * HTML Entity Decode Callback
784
+ * @param $match
785
+ * @return mixed
786
+ * @throws \Exception
787
+ */
788
+ protected
789
+ function _decode_entity($match)
790
+ {
791
+ // Protect GET variables in URLs
792
+ // 901119URL5918AMP18930PROTECT8198
793
+ $match = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-/]+)|i', $this->xss_hash() . '\\1=\\2', $match[0]);
794
+ // Decode, then un-protect URL GET vars
795
+ return str_replace(
796
+ $this->xss_hash(),
797
+ '&',
798
+ $this->entity_decode($match, $this->charset)
799
+ );
800
+ }
801
+
802
+ /**
803
+ * Generates the XSS hash if needed and returns it.
804
+ * @return mixed|string
805
+ * @throws \Exception
806
+ */
807
+ function xss_hash()
808
+ {
809
+ if ($this->_xss_hash === NULL) {
810
+ $rand = $this->get_random_bytes(16);
811
+ $this->_xss_hash = ($rand === FALSE)
812
+ ? md5(uniqid(mt_rand(), TRUE))
813
+ : bin2hex($rand);
814
+ }
815
+ return $this->_xss_hash;
816
+ }
817
+
818
+ /**
819
+ * Get random bytes
820
+ * @param $length
821
+ * @return bool|string|void
822
+ * @throws \Exception
823
+ */
824
+ function get_random_bytes($length)
825
+ {
826
+ if (empty($length) OR !ctype_digit((string)$length)) {
827
+ return FALSE;
828
+ }
829
+ if (function_exists('random_bytes')) {
830
+ try {
831
+ // The cast is required to avoid TypeError
832
+ return random_bytes((int)$length);
833
+ } catch (Exception $e) {
834
+ // If random_bytes() can't do the job, we can't either ...
835
+ // There's no point in using fallbacks.
836
+ log_message('error', $e->getMessage());
837
+ return FALSE;
838
+ }
839
+ }
840
+ // Unfortunately, none of the following PRNGs is guaranteed to exist ...
841
+ if (defined('MCRYPT_DEV_URANDOM') && ($output = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM)) !== FALSE) {
842
+ return $output;
843
+ }
844
+ if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
845
+ // Try not to waste entropy ...
846
+ is_php('5.4') && stream_set_chunk_size($fp, $length);
847
+ $output = fread($fp, $length);
848
+ fclose($fp);
849
+ if ($output !== FALSE) {
850
+ return $output;
851
+ }
852
+ }
853
+ if (function_exists('openssl_random_pseudo_bytes')) {
854
+ return openssl_random_pseudo_bytes($length);
855
+ }
856
+ return FALSE;
857
+ }
858
+
859
+ /**
860
+ * HTML Entities Decode
861
+ * @param $str
862
+ * @param null $charset
863
+ * @return mixed|string
864
+ */
865
+ function entity_decode($str, $charset = NULL)
866
+ {
867
+ if (strpos($str, '&') === FALSE) {
868
+ return $str;
869
+ }
870
+ static $_entities;
871
+ isset($charset) OR $charset = $this->charset;
872
+
873
+ $flag = $this->is_php('5.4')
874
+ ? ENT_COMPAT | ENT_HTML5
875
+ : ENT_COMPAT;
876
+ if (!isset($_entities)) {
877
+ $_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, $flag, $charset));
878
+ // If we're not on PHP 5.4+, add the possibly dangerous HTML 5
879
+ // entities to the array manually
880
+ if ($flag === ENT_COMPAT) {
881
+ $_entities[':'] = '&colon;';
882
+ $_entities['('] = '&lpar;';
883
+ $_entities[')'] = '&rpar;';
884
+ $_entities["\n"] = '&NewLine;';
885
+ $_entities["\t"] = '&Tab;';
886
+ }
887
+ }
888
+ do {
889
+ $str_compare = $str;
890
+ // Decode standard entities, avoiding false positives
891
+ if (preg_match_all('/&[a-z]{2,}(?![a-z;])/i', $str, $matches)) {
892
+ $replace = array();
893
+ $matches = array_unique(array_map('strtolower', $matches[0]));
894
+ foreach ($matches as &$match) {
895
+ if (($char = array_search($match . ';', $_entities, TRUE)) !== FALSE) {
896
+ $replace[$match] = $char;
897
+ }
898
+ }
899
+ $str = str_replace(array_keys($replace), array_values($replace), $str);
900
+ }
901
+ // Decode numeric & UTF16 two byte entities
902
+ $str = html_entity_decode(
903
+ preg_replace('/(&#(?:x0*[0-9a-f]{2,5}(?![0-9a-f;])|(?:0*\d{2,4}(?![0-9;]))))/iS', '$1;', $str),
904
+ $flag,
905
+ $charset
906
+ );
907
+ if ($flag === ENT_COMPAT) {
908
+ $str = str_replace(array_values($_entities), array_keys($_entities), $str);
909
+ }
910
+ } while ($str_compare !== $str);
911
+ return $str;
912
+ }
913
+
914
+ /**
915
+ * Compact Exploded Words
916
+ * @param $matches
917
+ * @return string
918
+ */
919
+ protected
920
+ function _compact_exploded_words($matches)
921
+ {
922
+ return preg_replace('/\s+/s', '', $matches[1]) . $matches[2];
923
+ }
924
+
925
+ /**
926
+ * Sanitize Naughty HTML
927
+ * @param $matches
928
+ * @return string
929
+ */
930
+ protected
931
+ function _sanitize_naughty_html($matches)
932
+ {
933
+ static $naughty_tags = array(
934
+ 'alert', 'area', 'prompt', 'confirm', 'applet', 'audio', 'basefont', 'base', 'behavior', 'bgsound',
935
+ 'blink', 'body', 'embed', 'expression', 'form', 'frameset', 'frame', 'head', 'html', 'ilayer',
936
+ 'iframe', 'input', 'button', 'select', 'isindex', 'layer', 'link', 'meta', 'keygen', 'object',
937
+ 'plaintext', 'style', 'script', 'textarea', 'title', 'math', 'video', 'svg', 'xml', 'xss'
938
+ );
939
+ static $evil_attributes = array(
940
+ 'on\w+', 'style', 'xmlns', 'formaction', 'form', 'xlink:href', 'FSCommand', 'seekSegmentTime'
941
+ );
942
+ // First, escape unclosed tags
943
+ if (empty($matches['closeTag'])) {
944
+ return '&lt;' . $matches[1];
945
+ } // Is the element that we caught naughty? If so, escape it
946
+ elseif (in_array(strtolower($matches['tagName']), $naughty_tags, TRUE)) {
947
+ return '&lt;' . $matches[1] . '&gt;';
948
+ } // For other tags, see if their attributes are "evil" and strip those
949
+ elseif (isset($matches['attributes'])) {
950
+ // We'll store the already filtered attributes here
951
+ $attributes = array();
952
+ // Attribute-catching pattern
953
+ $attributes_pattern = '#'
954
+ . '(?<name>[^\s\042\047>/=]+)' // attribute characters
955
+ // optional attribute-value
956
+ . '(?:\s*=(?<value>[^\s\042\047=><`]+|\s*\042[^\042]*\042|\s*\047[^\047]*\047|\s*(?U:[^\s\042\047=><`]*)))' // attribute-value separator
957
+ . '#i';
958
+ // Blacklist pattern for evil attribute names
959
+ $is_evil_pattern = '#^(' . implode('|', $evil_attributes) . ')$#i';
960
+ // Each iteration filters a single attribute
961
+ do {
962
+ // Strip any non-alpha characters that may precede an attribute.
963
+ // Browsers often parse these incorrectly and that has been a
964
+ // of numerous XSS issues we've had.
965
+ $matches['attributes'] = preg_replace('#^[^a-z]+#i', '', $matches['attributes']);
966
+ if (!preg_match($attributes_pattern, $matches['attributes'], $attribute, PREG_OFFSET_CAPTURE)) {
967
+ // No (valid) attribute found? Discard everything else inside the tag
968
+ break;
969
+ }
970
+ if (
971
+ // Is it indeed an "evil" attribute?
972
+ preg_match($is_evil_pattern, $attribute['name'][0])
973
+ // Or does it have an equals sign, but no value and not quoted? Strip that too!
974
+ OR (trim($attribute['value'][0]) === '')
975
+ ) {
976
+ $attributes[] = 'xss=removed';
977
+ } else {
978
+ $attributes[] = $attribute[0][0];
979
+ }
980
+ $matches['attributes'] = substr($matches['attributes'], $attribute[0][1] + strlen($attribute[0][0]));
981
+ } while ($matches['attributes'] !== '');
982
+ $attributes = empty($attributes)
983
+ ? ''
984
+ : ' ' . implode(' ', $attributes);
985
+ return '<' . $matches['slash'] . $matches['tagName'] . $attributes . '>';
986
+ }
987
+ return $matches[0];
988
+ }
989
+
990
+ /**
991
+ * Attribute Conversion
992
+ * @param $match
993
+ * @return mixed
994
+ */
995
+ protected
996
+ function _convert_attribute($match)
997
+ {
998
+ return str_replace(array('>', '<', '\\'), array('&gt;', '&lt;', '\\\\'), $match[0]);
999
+ }
1000
+ }
v2/App/Helpers/Language.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class Language
8
+ {
9
+ /**
10
+ * This will return the current language
11
+ * @return string - current active language code
12
+ */
13
+ static function getCurrentLanguage()
14
+ {
15
+ if (defined('ICL_LANGUAGE_CODE')) {
16
+ return ICL_LANGUAGE_CODE;
17
+ }
18
+ return NULL;
19
+ }
20
+
21
+ /**
22
+ * Get all available languages
23
+ * @return mixed|void
24
+ */
25
+ static function getAvailableLanguages()
26
+ {
27
+ $languages = apply_filters('wpml_active_languages', NULL, 'orderby=id&order=desc');
28
+ if (empty($languages) && function_exists('icl_get_languages')) {
29
+ $languages = icl_get_languages();
30
+ }
31
+ return $languages;
32
+ }
33
+
34
+ /**
35
+ * Get the default language of the site
36
+ * @return String|null
37
+ */
38
+ function getDefaultLanguage()
39
+ {
40
+ $current_lang = NULL;
41
+ $wpml_options = get_option('icl_sitepress_settings');
42
+ if (!empty($wpml_options)) {
43
+ return (isset($wpml_options['default_language'])) ? $wpml_options['default_language'] : NULL;
44
+ }
45
+ if (function_exists('get_locale')) {
46
+ $current_lang = get_locale();
47
+ if (empty($current_lang)) {
48
+ $current_lang = 'en';
49
+ }
50
+ }
51
+ return $current_lang;
52
+ }
53
+
54
+ /**
55
+ * Get site's default language
56
+ * @return array
57
+ */
58
+ function getWpAvailableTranslations()
59
+ {
60
+ require_once(ABSPATH . 'wp-admin/includes/translation-install.php');
61
+ if (function_exists('wp_get_available_translations')) {
62
+ return wp_get_available_translations();
63
+ }
64
+ return array();
65
+ }
66
+
67
+ /**
68
+ * get language label by lang code
69
+ * @param $language_code
70
+ * @return mixed|string|null
71
+ */
72
+ function getLanguageLabel($language_code)
73
+ {
74
+ if ($language_code == 'en_US' || $language_code == "en") {
75
+ return "English";
76
+ } else {
77
+ $translations = $this->getWpAvailableTranslations();
78
+ if (isset($translations[$language_code]['native_name'])) {
79
+ return $translations[$language_code]['native_name'];
80
+ }
81
+ }
82
+ return NULL;
83
+ }
84
+ }
v2/App/Helpers/Migration.php ADDED
@@ -0,0 +1,1034 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ use Wdr\App\Controllers\Configuration;
6
+
7
+ class Migration
8
+ {
9
+ protected $form;
10
+ protected $rule;
11
+ protected $migrated_option_key = 'awdr_migration_info';
12
+ protected $migration_count_on_a_set = 2;
13
+
14
+ public function __construct()
15
+ {
16
+ $this->form = new RuleForm();
17
+ $this->rule = new Rule();
18
+ }
19
+
20
+ public static function init(){
21
+ $do_migration = true;
22
+ if($do_migration === true){
23
+ return (new self())->processMigrationV1ToV2();
24
+ }
25
+ return false;
26
+ }
27
+ public static function hasSwitchBackOption(){
28
+ // For v2 phase 1 switch back should display by default
29
+ $has_switch_back_option = true;
30
+ /*$has_migration = (new self())->getMigrationInfoOf('has_migration', null);
31
+ $has_switch_back_option = false;
32
+ if($has_migration == 1){
33
+ $has_switch_back_option = true;
34
+ }*/
35
+
36
+ return apply_filters('advanced_woo_discount_rules_has_switch_back_option', $has_switch_back_option);
37
+ }
38
+
39
+ /**
40
+ * Migrate licence key
41
+ * */
42
+ protected function migrateLicenceKey(){
43
+ $v2_config = new Configuration();
44
+ $licence_key = $v2_config->getConfig('licence_key', null);
45
+ if(empty($licence_key)){
46
+ $v1_config = get_option("woo-discount-config");
47
+ if (is_string($v1_config)) $v1_config = json_decode($v1_config, true);
48
+ $v1_licence_key = isset($v1_config["license_key"])? $v1_config["license_key"] : null;
49
+ if(!empty($v1_licence_key)){
50
+ self::updateLicenceKeyInSettings($v1_licence_key);
51
+ }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Update Licence key with settings
57
+ * */
58
+ protected static function updateLicenceKeyInSettings($licence_key){
59
+ $config = get_option(Configuration::DEFAULT_OPTION);
60
+ $config['licence_key'] = $licence_key;
61
+ update_option(Configuration::DEFAULT_OPTION, $config);
62
+ }
63
+
64
+ /**
65
+ * check for migration
66
+ * */
67
+ public static function checkForMigration(){
68
+ $current_obj = new self();
69
+ $has_migration = $current_obj->getMigrationInfoOf('has_migration', null);
70
+ if($has_migration === null){
71
+ $has_migration_status = 0;
72
+ $price_rules = $current_obj->getV1Rules();
73
+ if(!empty($price_rules)){
74
+ $has_migration_status = 1;
75
+ } else {
76
+ $cart_rules = $current_obj->getV1Rules('woo_discount_cart');
77
+ if(!empty($cart_rules)){
78
+ $has_migration_status = 1;
79
+ }
80
+ }
81
+ $current_obj->updateMigrationInfo(array('has_migration' => $has_migration_status));
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Process migration
87
+ * */
88
+ protected function processMigrationV1ToV2(){
89
+ $total_count = Woocommerce::getSession('awdr_v1_to_v2_total_migration');
90
+ if(empty($total_count)){
91
+ $total_count = 0;
92
+ $price_rules = $this->getV1Rules('woo_discount', 1);
93
+ $cart_rules = $this->getV1Rules('woo_discount_cart', 1);
94
+ if(!empty($price_rules)){
95
+ $total_count += count($price_rules);
96
+ }
97
+ if(!empty($cart_rules)){
98
+ $total_count += count($cart_rules);
99
+ }
100
+ Woocommerce::setSession('awdr_v1_to_v2_total_migration', $total_count);
101
+ Woocommerce::setSession('awdr_v1_to_v2_total_migrated', 0);
102
+ }
103
+ $current_migrated_count = 0;
104
+ $price_rules = $this->getV1Rules();
105
+ $cart_rules = $this->getV1Rules('woo_discount_cart');
106
+ if(!empty($price_rules)){
107
+ $this->processPriceRules($price_rules);
108
+ $current_migrated_count += count($price_rules);
109
+ }
110
+ if(!empty($cart_rules)){
111
+ $this->processCartRules($cart_rules);
112
+ $current_migrated_count += count($cart_rules);
113
+ }
114
+ $total_migrated = Woocommerce::getSession('awdr_v1_to_v2_total_migrated', 0);
115
+ $total_migrated += $current_migrated_count;
116
+ $return_status = array(
117
+ 'total_count' => $total_count,
118
+ 'completed_count' => $total_migrated,
119
+ 'status' => 'processing',
120
+ );
121
+ if($total_migrated >= $total_count || $current_migrated_count == 0){
122
+ $this->updateMigrationInfo(array('migration_completed' => 1));
123
+ $return_status['status'] = 'completed';
124
+ $percentage = 100;
125
+ Woocommerce::setSession('awdr_v1_to_v2_total_migration', null);
126
+ $this->migrateLicenceKey();
127
+ } else {
128
+ $percentage = ($total_migrated/$total_count)*100;
129
+ $percentage = round($percentage);
130
+ Woocommerce::setSession('awdr_v1_to_v2_total_migrated', $total_migrated);
131
+ }
132
+ $percentage = $percentage.'%';
133
+ $return_status['display_text'] = sprintf(esc_html__('%s Completed. Please wait..', WDR_TEXT_DOMAIN), $percentage);
134
+
135
+ return $return_status;
136
+ }
137
+
138
+ /**
139
+ * get migration data
140
+ * */
141
+ protected function getMigrationInfo(){
142
+ return get_option($this->migrated_option_key, array());
143
+ }
144
+
145
+ /**
146
+ * get migration data
147
+ * */
148
+ public function getMigrationInfoOf($key, $default = ''){
149
+ $config = self::getMigrationInfo();
150
+ if(isset($config[$key])){
151
+ return $config[$key];
152
+ } else {
153
+ return $default;
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Update migration data
159
+ * */
160
+ public function updateMigrationInfo($data){
161
+ $config = $this->getMigrationInfo();
162
+ if(!is_array($config)) $config = array();
163
+ $config = array_merge($config, $data);
164
+ update_option($this->migrated_option_key, $config);
165
+ }
166
+
167
+ /**
168
+ * Process cart rules
169
+ * @param $rules
170
+ * */
171
+ protected function processCartRules($rules){
172
+ foreach ($rules as $key => $rule){
173
+ $form_data = $this->convertV1CartRuleToV2($rule);
174
+ $this->rule->save($form_data);
175
+ $this->updateMigrationInfo(array('v1_last_migrated_cart_rule_id' => $rule->ID));
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Process price rules
181
+ * @param $rules
182
+ * */
183
+ protected function processPriceRules($rules){
184
+ foreach ($rules as $key => $rule){
185
+ $split_rule_types = $this->splitRuleTypes($rule);
186
+ if(!empty($split_rule_types) && count($split_rule_types)){
187
+ foreach ($split_rule_types as $split_rule_type){
188
+ $rule->meta['discount_range'][0] = json_encode($split_rule_type);
189
+ $this->processPriceRulesBasedOnType($rule);
190
+ }
191
+ } else {
192
+ $this->processPriceRulesBasedOnType($rule);
193
+ }
194
+ }
195
+ }
196
+
197
+ protected function processPriceRulesBasedOnType($rule){
198
+ $form_data = $this->convertV1PriceRuleToV2($rule);
199
+ $this->rule->save($form_data);
200
+ $this->updateMigrationInfo(array('v1_last_migrated_price_rule_id' => $rule->ID));
201
+ }
202
+
203
+ protected function splitRuleTypes($price_rule){
204
+ $return = array();
205
+ if($price_rule->rule_method == 'qty_based'){
206
+ $discount_ranges = $this->getDiscountRange($price_rule);
207
+ foreach ($discount_ranges as $key => $discount_range){
208
+ if(in_array($discount_range->discount_type, array('percentage_discount', 'price_discount', 'fixed_price'))){
209
+ $return['bulk_discounts'][] = $discount_range;
210
+ } else if($discount_range->discount_type == 'set_discount'){
211
+ $return['set_discount'][] = $discount_range;
212
+ } else if($discount_range->discount_type == 'buy_x_get_x'){
213
+ $return['buy_x_get_x'][] = $discount_range;
214
+ } else if($discount_range->discount_type == 'buy_x_get_y'){
215
+ $return['buy_x_get_y'][] = $discount_range;
216
+ } else if($discount_range->discount_type == 'more_than_one_cheapest'){
217
+ $return['more_than_one_cheapest'][] = $discount_range;
218
+ } else if($discount_range->discount_type == 'more_than_one_cheapest_from_cat'){
219
+ $return['more_than_one_cheapest_from_cat'][] = $discount_range;
220
+ } else if($discount_range->discount_type == 'more_than_one_cheapest_from_all'){
221
+ $return['more_than_one_cheapest_from_all'][] = $discount_range;
222
+ } else if($discount_range->discount_type == 'product_discount'){
223
+ if($discount_range->discount_product_option == 'same_product'){
224
+ $discount_range->discount_type = 'buy_x_get_x';
225
+ $return['buy_x_get_x'][] = $discount_range;
226
+ } else if($discount_range->discount_product_option == 'all'){
227
+ $discount_range->discount_type = 'buy_x_get_y';
228
+ $return['buy_x_get_y'][] = $discount_range;
229
+ } else if($discount_range->discount_product_option == 'more_than_one_cheapest'){
230
+ $discount_range->discount_type = 'more_than_one_cheapest';
231
+ $return['more_than_one_cheapest'][] = $discount_range;
232
+ } else if($discount_range->discount_product_option == 'more_than_one_cheapest_from_cat'){
233
+ $discount_range->discount_type = 'more_than_one_cheapest_from_cat';
234
+ $return['more_than_one_cheapest_from_cat'][] = $discount_range;
235
+ } else if($discount_range->discount_product_option == 'more_than_one_cheapest_from_all'){
236
+ $discount_range->discount_type = 'more_than_one_cheapest_from_all';
237
+ $return['more_than_one_cheapest_from_all'][] = $discount_range;
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ return $return;
244
+ }
245
+
246
+ /**
247
+ * Convert the v1 rule to v2 format for cart rules
248
+ * */
249
+ protected function convertV1CartRuleToV2($rule){
250
+ $this->form->reset();
251
+ $this->processCommonData($rule);
252
+ $this->processDiscountType($rule, 'cart');
253
+ $this->processFilters($rule, 'cart');
254
+ $this->processConditions($rule, 'cart');
255
+ $this->processCartDiscounts($rule);
256
+ return $this->form->getForm();
257
+ }
258
+
259
+ /**
260
+ * Convert the v1 rule to v2 format
261
+ * */
262
+ protected function convertV1PriceRuleToV2($price_rule){
263
+ $this->form->reset();
264
+ $this->processCommonData($price_rule);
265
+ $this->processDiscountType($price_rule);
266
+ $this->processFilters($price_rule);
267
+ $this->processCumulativeOption($price_rule);
268
+ $this->processRanges($price_rule);
269
+ $this->processConditions($price_rule);
270
+ $this->processAdvanceTable($price_rule);
271
+
272
+ return $this->form->getForm();
273
+ }
274
+
275
+ /**
276
+ * Process cumulative option
277
+ * */
278
+ protected function processAdvanceTable($price_rule){
279
+ $advance_table_format = $price_rule->advance_table_format;
280
+ if(!empty($advance_table_format)){
281
+
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Process cumulative option
287
+ * */
288
+ protected function processRanges($price_rule){
289
+ if($price_rule->rule_method == "qty_based"){
290
+ $discount_ranges = $this->getDiscountRange($price_rule);
291
+ if(!empty($discount_ranges)){
292
+ foreach ($discount_ranges as $discount_range){
293
+ $discount_type = $discount_range->discount_type;
294
+ if(in_array($discount_type, array('percentage_discount', 'price_discount', 'fixed_price'))){
295
+ if($discount_type == 'percentage_discount'){
296
+ $type = 'percentage';
297
+ } else if($discount_type == 'price_discount'){
298
+ $type = 'flat';
299
+ } else {
300
+ $type = 'fixed_price';
301
+ }
302
+ $this->form->setBulkRange($discount_range->min_qty, $discount_range->max_qty, $discount_range->to_discount, $type);
303
+ } elseif ($discount_type == 'set_discount'){
304
+ $this->form->setSetRange($discount_range->min_qty, $discount_range->to_discount);
305
+ } elseif ($discount_type == 'buy_x_get_x'){
306
+ $type = ($discount_range->discount_product_discount_type == '')? 'free_product': 'percentage';
307
+ $min_qty = $discount_range->min_qty;
308
+ $max_qty = $discount_range->max_qty;
309
+ $discount_bogo_qty = $discount_range->discount_bogo_qty;
310
+ if($type == "free_product"){
311
+ $new_min_qty = $min_qty-$discount_bogo_qty;
312
+ $new_max_qty = $max_qty-$discount_bogo_qty;
313
+ if($new_min_qty > 0) $min_qty = $new_min_qty;
314
+ if($new_max_qty > 0) $max_qty = $new_max_qty;
315
+ }
316
+ $value = (isset($discount_range->discount_product_percent))? $discount_range->discount_product_percent: '';
317
+ $this->form->setBuyXGetXRange($min_qty, $discount_bogo_qty, $max_qty, $type, $value);
318
+ } else{
319
+ if ($discount_type == 'buy_x_get_y'){
320
+ $discount_product = (isset($discount_range->discount_product))? $this->getData($discount_range->discount_product): array();
321
+ $additional_values = array('products' => $discount_product);
322
+ $discount_bogo_qty = $discount_range->discount_bogo_qty;
323
+ } elseif ($discount_type == 'more_than_one_cheapest'){
324
+ $discount_product = (isset($discount_range->discount_product))? $this->getData($discount_range->discount_product): array();
325
+ $additional_values = array('products' => $discount_product);
326
+ $discount_bogo_qty = $discount_range->discount_product_qty;
327
+ } elseif ($discount_type == 'more_than_one_cheapest_from_cat'){
328
+ $discount_category = (isset($discount_range->discount_category))? $this->getData($discount_range->discount_category): array();
329
+ $additional_values = array('categories' => $discount_category);
330
+ $discount_bogo_qty = $discount_range->discount_product_qty;
331
+ } else {
332
+ $additional_values = array();
333
+ $discount_bogo_qty = $discount_range->discount_product_qty;
334
+ }
335
+ $type = ($discount_range->discount_product_discount_type == '')? 'free_product': 'percentage';
336
+ $value = (isset($discount_range->discount_product_percent))? $discount_range->discount_product_percent: '';
337
+ $this->form->setBuyXGetyRange($discount_range->min_qty, $discount_bogo_qty, $additional_values, $discount_range->max_qty, $type, $value);
338
+ }
339
+ }
340
+ }
341
+ } else {
342
+ $condition = $this->getData($price_rule->product_based_condition);
343
+ $discount = $this->getData($price_rule->product_based_discount);
344
+ $has_set = false;
345
+ if($discount->discount_type == "percentage_discount"){
346
+ $type = 'percentage';
347
+ } else {
348
+ $type = 'flat';
349
+ }
350
+ if($condition->get_discount_type == "product"){
351
+ if(isset($condition->product_to_apply_count_option) && $condition->product_to_apply_count_option == "apply_first"){
352
+ $this->form->setSetRange($condition->product_to_apply_count, $discount->discount_value, $type);
353
+ $has_set = true;
354
+ }
355
+ }
356
+ if($has_set == false){
357
+ $this->form->setProductAdjustment($type, $discount->discount_value);
358
+ }
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Process cumulative option
364
+ * */
365
+ protected function processCumulativeOption($price_rule){
366
+ if($price_rule->rule_method == "qty_based"){
367
+ $has_cumulative = false;
368
+ $field_name = '';
369
+ if(in_array($price_rule->apply_to, array('all_products', 'specific_category', 'specific_attribute'))) {
370
+ if ($price_rule->apply_to == 'all_products') {
371
+ $field_name = 'is_cumulative_for_products';
372
+ } else if ($price_rule->apply_to == 'specific_category') {
373
+ $field_name = 'is_cumulative';
374
+ } else if ($price_rule->apply_to == 'specific_attribute') {
375
+ $field_name = 'is_cumulative_attribute';
376
+ }
377
+ }
378
+ if($field_name != ''){
379
+ if(isset($price_rule->$field_name)){
380
+ if($price_rule->$field_name){
381
+ $has_cumulative = true;
382
+ }
383
+ }
384
+ }
385
+ if($has_cumulative){
386
+ $this->form->setCumulativeOption();
387
+ } else {
388
+ $this->form->setCumulativeOption('product');
389
+ }
390
+ }
391
+ }
392
+
393
+ /**
394
+ * Process cart discounts
395
+ * */
396
+ protected function processCartDiscounts($rule){
397
+ $discount_value = $rule->to_discount;
398
+ if($rule->discount_type == "percentage_discount"){
399
+ $this->form->setCartAdjustment($discount_value);
400
+ } elseif ($rule->discount_type == "price_discount"){
401
+ $this->form->setCartAdjustment($discount_value, 'flat_in_subtotal');
402
+ } elseif ($rule->discount_type == "product_discount"){
403
+ $this->form->setBuyXGetYOption();
404
+ $additional_values = array('products' => $this->getData($rule->cart_discounted_products));
405
+ $this->form->setBuyXGetyRange(1, $rule->product_discount_quantity, $additional_values, 9999, 'free_product');
406
+ }
407
+ }
408
+
409
+ protected function processPriceRulesQuantityBasedConditions($rule){
410
+ if($rule->customer == 'only_given'){
411
+ $option = array('operator' => 'in_list', 'value' => $this->getData($rule->users_to_apply));
412
+ $this->form->setConditions('user_list', $option);
413
+ }
414
+ if(isset($rule->user_roles_to_apply) && !empty($rule->user_roles_to_apply)){
415
+ $user_roles_to_apply = $this->getData($rule->user_roles_to_apply);
416
+ if(!empty($user_roles_to_apply)){
417
+ $option = array('operator' => 'in_list', 'value' => $user_roles_to_apply);
418
+ $this->form->setConditions('user_role', $option);
419
+ }
420
+ }
421
+ if(isset($rule->coupons_to_apply_option) && $rule->coupons_to_apply_option != "none"){
422
+ if($rule->coupons_to_apply_option == 'create_dynamic_coupon'){
423
+ $option = array('operator' => 'custom_coupon', 'custom_value' => $rule->dynamic_coupons_to_apply);
424
+ } else if($rule->coupons_to_apply_option == 'any_selected'){
425
+ $option = array('operator' => 'at_least_one', 'value' => $this->getData($rule->coupons_to_apply));
426
+ } else {
427
+ $option = array('operator' => 'all', 'value' => $this->getData($rule->coupons_to_apply));
428
+ }
429
+ $this->form->setConditions('cart_coupon', $option);
430
+ }
431
+ if(isset($rule->subtotal_to_apply_option) && $rule->subtotal_to_apply_option != "none"){
432
+ if($rule->subtotal_to_apply_option == 'atleast'){
433
+ $option = array('operator' => 'greater_than_or_equal', 'value' => $rule->subtotal_to_apply);
434
+ $this->form->setConditions('cart_subtotal', $option);
435
+ }
436
+ }
437
+ if(isset($rule->based_on_purchase_history) && $rule->based_on_purchase_history != "0"){
438
+ if($rule->based_on_purchase_history == 'first_order'){
439
+ $option = array('value' => 1);
440
+ $this->form->setConditions('purchase_first_order', $option);
441
+ } elseif ($rule->based_on_purchase_history == 1){
442
+ $history_type = ($rule->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
443
+ $status = $this->getData($rule->purchase_history_status_list);
444
+ $status = (empty($status))? array(): $status;
445
+ $duration = 'all_time';
446
+ if(isset($rule->purchased_history_duration)){
447
+ $duration = $this->getPurchaseHistoryDuration($rule->purchased_history_duration, $rule->purchased_history_duration_days);
448
+ }
449
+ $option = array('operator' => $history_type, 'amount' => $rule->purchased_history_amount, 'status' => $status, 'time' => $duration);
450
+ $this->form->setConditions('purchase_spent', $option);
451
+ } elseif ($rule->based_on_purchase_history == 2){
452
+ $history_type = ($rule->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
453
+ $status = $this->getData($rule->purchase_history_status_list);
454
+ $status = (empty($status))? array(): $status;
455
+ $duration = 'all_time';
456
+ if(isset($rule->purchased_history_duration)){
457
+ $duration = $this->getPurchaseHistoryDuration($rule->purchased_history_duration, $rule->purchased_history_duration_days);
458
+ }
459
+ $option = array('operator' => $history_type, 'count' => $rule->purchased_history_amount, 'status' => $status, 'time' => $duration);
460
+ $this->form->setConditions('purchase_previous_orders', $option);
461
+ } else{
462
+ //for 3 and 4
463
+ $history_type = ($rule->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
464
+ $status = $this->getData($rule->purchase_history_status_list);
465
+ $status = (empty($status))? array(): $status;
466
+ $duration = 'all_time';
467
+ if(isset($rule->purchased_history_duration)){
468
+ $duration = $this->getPurchaseHistoryDuration($rule->purchased_history_duration, $rule->purchased_history_duration_days);
469
+ }
470
+ $products = $this->getData($rule->purchase_history_products);
471
+ $option = array('products'=> $products, 'operator' => $history_type, 'count' => $rule->purchased_history_amount, 'status' => $status, 'time' => $duration);
472
+ $this->form->setConditions('purchase_previous_orders_for_specific_product', $option);
473
+ }
474
+ }
475
+ }
476
+
477
+ protected function getPurchaseHistoryDuration($duration, $custom_days){
478
+ if($duration == 'all_time'){
479
+ $return = 'all_time';
480
+ } elseif ($duration == 'custom_days'){
481
+ $return = '-'.$custom_days.'_days';
482
+ } else {
483
+ if($duration == '7_days'){
484
+ $return = '-1_week';
485
+ } else if($duration == '14_days'){
486
+ $return = '-2_week';
487
+ } else if($duration == '30_days'){
488
+ $return = '-1_month';
489
+ } else if($duration == '60_days'){
490
+ $return = '-2_months';
491
+ } else if($duration == '90_days'){
492
+ $return = '-3_months';
493
+ } else if($duration == '180_days'){
494
+ $return = '-9_months';
495
+ } else {
496
+ $return = '-12_months';
497
+ }
498
+ }
499
+ return $return;
500
+ }
501
+
502
+ protected function getStateInFormat($states){
503
+ if(is_array($states)){
504
+ $new_states = array();
505
+ foreach ($states as $state){
506
+ $new_state = null;
507
+ $available_states = Woocommerce::getStatesList();
508
+ foreach ($available_states as $key => $val) {
509
+ foreach ($val as $key2 => $value){
510
+ if(strtolower($state) == strtolower($value)){
511
+ $new_state = $key2;
512
+ }
513
+ }
514
+ }
515
+ if($new_state !== null){
516
+ $new_states[] = $new_state;
517
+ } else {
518
+ $new_states[] = $state;
519
+ }
520
+ }
521
+
522
+ return $new_states;
523
+ }
524
+
525
+ return array();
526
+ }
527
+
528
+ protected function processCartRulesConditions($rule){
529
+ $discount_rule_conditions = $this->getData($rule->discount_rule);
530
+ foreach ($discount_rule_conditions as $discount_rule_condition){
531
+ $has_condition = false;
532
+ if(isset($discount_rule_condition->subtotal_less)){
533
+ $condition_type = 'cart_subtotal';
534
+ $option = array(
535
+ 'operator' => 'less_than_or_equal',
536
+ 'value' => $discount_rule_condition->subtotal_less,
537
+ 'calculate_from' => 'from_filter',
538
+ );
539
+ $has_condition = true;
540
+ }
541
+ if(isset($discount_rule_condition->subtotal_least)){
542
+ $condition_type = 'cart_subtotal';
543
+ $option = array(
544
+ 'operator' => 'greater_than_or_equal',
545
+ 'value' => $discount_rule_condition->subtotal_least,
546
+ 'calculate_from' => 'from_filter',
547
+ );
548
+ $has_condition = true;
549
+ }
550
+ if(isset($discount_rule_condition->item_count_least)){
551
+ $condition_type = 'cart_line_items_count';
552
+ $option = array(
553
+ 'operator' => 'greater_than_or_equal',
554
+ 'value' => $discount_rule_condition->item_count_least,
555
+ 'calculate_from' => 'from_filter',
556
+ );
557
+ $has_condition = true;
558
+ }
559
+ if(isset($discount_rule_condition->item_count_less)){
560
+ $condition_type = 'cart_line_items_count';
561
+ $option = array(
562
+ 'operator' => 'less_than_or_equal',
563
+ 'value' => $discount_rule_condition->item_count_less,
564
+ 'calculate_from' => 'from_filter',
565
+ );
566
+ $has_condition = true;
567
+ }
568
+ if(isset($discount_rule_condition->quantity_least)){
569
+ $condition_type = 'cart_items_quantity';
570
+ $option = array(
571
+ 'operator' => 'greater_than_or_equal',
572
+ 'value' => $discount_rule_condition->quantity_least,
573
+ 'calculate_from' => 'from_filter',
574
+ );
575
+ $has_condition = true;
576
+ }
577
+ if(isset($discount_rule_condition->quantity_less)){
578
+ $condition_type = 'cart_items_quantity';
579
+ $option = array(
580
+ 'operator' => 'less_than_or_equal',
581
+ 'value' => $discount_rule_condition->quantity_less,
582
+ 'calculate_from' => 'from_filter',
583
+ );
584
+ $has_condition = true;
585
+ }
586
+ if(isset($discount_rule_condition->users_in)){
587
+ $condition_type = 'user_list';
588
+ $option = array('operator' => 'in_list', 'value' => $discount_rule_condition->users_in);
589
+ $has_condition = true;
590
+ }
591
+ if(isset($discount_rule_condition->roles_in)){
592
+ $condition_type = 'user_role';
593
+ $option = array('operator' => 'in_list', 'value' => $discount_rule_condition->roles_in);
594
+ $has_condition = true;
595
+ }
596
+ if(isset($discount_rule_condition->customer_email_tld)){
597
+ $condition_type = 'user_email';
598
+ $option = array('operator' => 'user_email_tld', 'value' => $discount_rule_condition->customer_email_tld);
599
+ $has_condition = true;
600
+ }
601
+ if(isset($discount_rule_condition->customer_email_domain)){
602
+ $condition_type = 'user_email';
603
+ $option = array('operator' => 'user_email_domain', 'value' => $discount_rule_condition->customer_email_domain);
604
+ $has_condition = true;
605
+ }
606
+ if(isset($discount_rule_condition->customer_shipping_city)){
607
+ $condition_type = 'shipping_city';
608
+ $option = array('operator' => 'in_list', 'value' => explode(",", $discount_rule_condition->customer_shipping_city));
609
+ $has_condition = true;
610
+ }
611
+ if(isset($discount_rule_condition->customer_billing_city)){
612
+ $condition_type = 'billing_city';
613
+ $option = array('operator' => 'in_list', 'value' => explode(",", $discount_rule_condition->customer_billing_city));
614
+ $has_condition = true;
615
+ }
616
+ if(isset($discount_rule_condition->customer_shipping_state)){
617
+ $condition_type = 'shipping_state';
618
+ $shipping_state = $this->getStateInFormat(explode(",", $discount_rule_condition->customer_shipping_state));
619
+ $option = array('operator' => 'in_list', 'value' => $shipping_state);
620
+ $has_condition = true;
621
+ }
622
+ if(isset($discount_rule_condition->shipping_countries_in)){
623
+ $condition_type = 'shipping_country';
624
+ $option = array('operator' => 'in_list', 'value' => $discount_rule_condition->shipping_countries_in);
625
+ $has_condition = true;
626
+ }
627
+ if(isset($discount_rule_condition->customer_shipping_zip_code)){
628
+ $condition_type = 'shipping_zipcode';
629
+ $option = array('operator' => 'in_list', 'value' => $discount_rule_condition->customer_shipping_zip_code);
630
+ $has_condition = true;
631
+ }
632
+ if(isset($discount_rule_condition->customer_based_on_first_order)){
633
+ $condition_type = 'purchase_first_order';
634
+ $option = array('value' => 1);
635
+ $has_condition = true;
636
+ }
637
+ if(isset($discount_rule_condition->customer_based_on_purchase_history)){
638
+ $purchase_history_value = $discount_rule_condition->customer_based_on_purchase_history;
639
+ $condition_type = 'purchase_spent';
640
+ $history_type = ($purchase_history_value->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
641
+ $status = $purchase_history_value->purchase_history_order_status;
642
+ $status = (empty($status))? array(): $status;
643
+ $duration = 'all_time';
644
+ if(isset($purchase_history_value->purchased_history_duration)){
645
+ $duration = $this->getPurchaseHistoryDuration($purchase_history_value->purchased_history_duration, $purchase_history_value->purchased_history_duration_days);
646
+ }
647
+ $option = array('operator' => $history_type, 'amount' => $rule->purchased_history_amount, 'status' => $status, 'time' => $duration);
648
+ $has_condition = true;
649
+ }
650
+
651
+ if(isset($discount_rule_condition->customer_based_on_purchase_history)){
652
+ $purchase_history_value = $discount_rule_condition->customer_based_on_purchase_history;
653
+ $condition_type = 'purchase_spent';
654
+ $history_type = ($purchase_history_value->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
655
+ $status = $purchase_history_value->purchase_history_order_status;
656
+ $status = (empty($status))? array(): $status;
657
+ $duration = 'all_time';
658
+ if(isset($purchase_history_value->purchased_history_duration)){
659
+ $duration = $this->getPurchaseHistoryDuration($purchase_history_value->purchased_history_duration, $purchase_history_value->purchased_history_duration_days);
660
+ }
661
+ $option = array('operator' => $history_type, 'amount' => $rule->purchased_history_amount, 'status' => $status, 'time' => $duration);
662
+ $has_condition = true;
663
+ }
664
+
665
+ if(isset($discount_rule_condition->customer_based_on_purchase_history_order_count)){
666
+ $purchase_history_value = $discount_rule_condition->customer_based_on_purchase_history_order_count;
667
+ $condition_type = 'purchase_previous_orders';
668
+ $history_type = ($purchase_history_value->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
669
+ $status = $purchase_history_value->purchase_history_order_status;
670
+ $status = (empty($status))? array(): $status;
671
+ $duration = 'all_time';
672
+ if(isset($purchase_history_value->purchased_history_duration)){
673
+ $duration = $this->getPurchaseHistoryDuration($purchase_history_value->purchased_history_duration, $purchase_history_value->purchased_history_duration_days);
674
+ }
675
+ $option = array('operator' => $history_type, 'count' => $purchase_history_value->purchased_history_amount, 'status' => $status, 'time' => $duration);
676
+ $has_condition = true;
677
+ }
678
+
679
+ if(isset($discount_rule_condition->customer_based_on_purchase_history_product_order_count)){
680
+ $purchase_history_value = $discount_rule_condition->customer_based_on_purchase_history_product_order_count;
681
+ $condition_type = 'purchase_previous_orders_for_specific_product';
682
+ $history_type = ($purchase_history_value->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
683
+ $status = $purchase_history_value->purchase_history_order_status;
684
+ $status = (empty($status))? array(): $status;
685
+ $duration = 'all_time';
686
+ if(isset($purchase_history_value->purchased_history_duration)){
687
+ $duration = $this->getPurchaseHistoryDuration($purchase_history_value->purchased_history_duration, $purchase_history_value->purchased_history_duration_days);
688
+ }
689
+ $products = $purchase_history_value->purchase_history_products;
690
+ $option = array('products'=> $products, 'operator' => $history_type, 'count' => $purchase_history_value->purchased_history_amount, 'status' => $status, 'time' => $duration);
691
+ $has_condition = true;
692
+ }
693
+ if(isset($discount_rule_condition->customer_based_on_purchase_history_product_quantity_count)){
694
+ $purchase_history_value = $discount_rule_condition->customer_based_on_purchase_history_product_quantity_count;
695
+ $condition_type = 'purchase_quantities_for_specific_product';
696
+ $history_type = ($purchase_history_value->purchased_history_type == 'atleast')? 'greater_than_or_equal': 'less_than_or_equal';
697
+ $status = $purchase_history_value->purchase_history_order_status;
698
+ $status = (empty($status))? array(): $status;
699
+ $duration = 'all_time';
700
+ if(isset($purchase_history_value->purchased_history_duration)){
701
+ $duration = $this->getPurchaseHistoryDuration($purchase_history_value->purchased_history_duration, $purchase_history_value->purchased_history_duration_days);
702
+ }
703
+ $products = $purchase_history_value->purchase_history_products;
704
+ $option = array('products'=> $products, 'operator' => $history_type, 'count' => $purchase_history_value->purchased_history_amount, 'status' => $status, 'time' => $duration);
705
+ $has_condition = true;
706
+ }
707
+
708
+ if(isset($discount_rule_condition->create_dynamic_coupon)){
709
+ $condition_type = 'cart_coupon';
710
+ $option = array('operator' => 'custom_coupon', 'custom_value' => $discount_rule_condition->create_dynamic_coupon);
711
+ $has_condition = true;
712
+ }
713
+
714
+ if(isset($discount_rule_condition->coupon_applied_all_selected)){
715
+ $condition_type = 'cart_coupon';
716
+ $option = array('operator' => 'at_least_one', 'custom_value' => $discount_rule_condition->coupon_applied_all_selected);
717
+ $has_condition = true;
718
+ }
719
+
720
+ if(isset($discount_rule_condition->coupon_applied_any_one)){
721
+ $condition_type = 'cart_coupon';
722
+ $option = array('operator' => 'all', 'custom_value' => $discount_rule_condition->coupon_applied_any_one);
723
+ $has_condition = true;
724
+ }
725
+
726
+ if(isset($discount_rule_condition->in_each_category)){
727
+ $condition_type_cat = 'cart_item_category_combination';
728
+ $option_cat = array('combination' => 'each', 'category' => $discount_rule_condition->in_each_category);
729
+ $this->setCategoryCombinationConditions($condition_type_cat, $discount_rule_conditions, $option_cat);
730
+ }
731
+
732
+ if($has_condition) $this->form->setConditions($condition_type, $option);
733
+ }
734
+ }
735
+
736
+ protected function setCategoryCombinationConditions($condition_type_cat, $discount_rule_conditions, $option_cat){
737
+ foreach ($discount_rule_conditions as $discount_rule_condition) {
738
+ if (isset($discount_rule_condition->subtotal_less)) {
739
+ $option_cat_temp = $option_cat;
740
+ $option_cat_temp['type'] = 'cart_subtotal';
741
+ $option_cat_temp['operator'] = 'less_than_or_equal';
742
+ $option_cat_temp['from'] = $discount_rule_condition->subtotal_less;
743
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
744
+ }
745
+ if (isset($discount_rule_condition->subtotal_least)) {
746
+ $option_cat_temp = $option_cat;
747
+ $option_cat_temp['type'] = 'cart_subtotal';
748
+ $option_cat_temp['operator'] = 'greater_than_or_equal';
749
+ $option_cat_temp['from'] = $discount_rule_condition->subtotal_least;
750
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
751
+ }
752
+ if (isset($discount_rule_condition->item_count_least)) {
753
+ $option_cat_temp = $option_cat;
754
+ $option_cat_temp['type'] = 'cart_line_item';
755
+ $option_cat_temp['operator'] = 'greater_than_or_equal';
756
+ $option_cat_temp['from'] = $discount_rule_condition->item_count_least;
757
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
758
+ }
759
+ if (isset($discount_rule_condition->item_count_less)) {
760
+ $option_cat_temp = $option_cat;
761
+ $option_cat_temp['type'] = 'cart_line_item';
762
+ $option_cat_temp['operator'] = 'less_than_or_equal';
763
+ $option_cat_temp['from'] = $discount_rule_condition->item_count_less;
764
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
765
+ }
766
+ if (isset($discount_rule_condition->quantity_least)) {
767
+ $option_cat_temp = $option_cat;
768
+ $option_cat_temp['type'] = 'cart_quantity';
769
+ $option_cat_temp['operator'] = 'greater_than_or_equal';
770
+ $option_cat_temp['from'] = $discount_rule_condition->quantity_least;
771
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
772
+ }
773
+ if (isset($discount_rule_condition->quantity_less)) {
774
+ $option_cat_temp = $option_cat;
775
+ $option_cat_temp['type'] = 'cart_quantity';
776
+ $option_cat_temp['operator'] = 'less_than_or_equal';
777
+ $option_cat_temp['from'] = $discount_rule_condition->quantity_less;
778
+ $this->form->setConditions($condition_type_cat, $option_cat_temp);
779
+ }
780
+ }
781
+ }
782
+
783
+ /**
784
+ * Process common data
785
+ * */
786
+ protected function processConditions($rule, $type = 'price'){
787
+ if($type == 'price'){
788
+ if($rule->rule_method == "qty_based"){
789
+ $this->processPriceRulesQuantityBasedConditions($rule);
790
+ } else {
791
+ $condition = $this->getData($rule->product_based_condition);
792
+ if($condition->product_quantity_rule == "more"){
793
+ $operator = 'greater_than_or_equal';
794
+ } elseif($condition->product_quantity_rule == "less"){
795
+ $operator = 'less_than_or_equal';
796
+ } elseif($condition->product_quantity_rule == "equal"){
797
+ $operator = 'equal_to';
798
+ } else {
799
+ $operator = 'in_range';
800
+ }
801
+ $option = array('type' => $condition->product_buy_type, 'product' => $condition->product_to_buy,
802
+ 'operator' => $operator, 'from' => $condition->product_quantity_from, 'to' => $condition->product_quantity_to);
803
+ $this->form->setConditions('cart_item_product_combination', $option);
804
+ }
805
+ } else {
806
+ $this->processCartRulesConditions($rule);
807
+ }
808
+ }
809
+
810
+ /**
811
+ * Process common data
812
+ * */
813
+ protected function processFilters($price_rule, $type = 'price'){
814
+ if($type == 'price'){
815
+ if($price_rule->rule_method == "qty_based"){
816
+ if(in_array($price_rule->apply_to, array('all_products', 'specific_category', 'specific_attribute'))){
817
+ if($price_rule->apply_to == 'all_products'){
818
+ $this->form->setFilter('all_products');
819
+ } else if($price_rule->apply_to == 'specific_category'){
820
+ $this->form->setFilter('product_category', 'in_list', $this->getData($price_rule->category_to_apply));
821
+ } else if($price_rule->apply_to == 'specific_attribute'){
822
+ $this->form->setFilter('product_attributes','in_list', $this->getData($price_rule->attribute_to_apply));
823
+ }
824
+
825
+ $product_to_exclude = $this->getData($price_rule->product_to_exclude);
826
+ if(!empty($product_to_exclude)){
827
+ $this->form->setFilter('products', 'not_in_list', $product_to_exclude);
828
+ }
829
+ } else if($price_rule->apply_to == 'specific_products'){
830
+ $product_to_apply = $this->getData($price_rule->product_to_apply);
831
+ if(!empty($product_to_apply)){
832
+ $this->form->setFilter('products', 'in_list', $product_to_apply);
833
+ }
834
+ }
835
+ if(isset($price_rule->exclude_sale_items)){
836
+ if($price_rule->exclude_sale_items){
837
+ $this->form->setFilter('product_on_sale', 'not_in_list');
838
+ }
839
+ }
840
+ } else {
841
+ $condition = $this->getData($price_rule->product_based_condition);
842
+ if($condition->get_discount_type == "product"){
843
+ $this->form->setFilter('products', 'in_list', $condition->product_to_apply);
844
+ } else {
845
+ $this->form->setFilter('product_category', 'in_list', $condition->category_to_apply);
846
+ }
847
+ }
848
+ } else {
849
+ $discount_rule = $this->getData($price_rule->discount_rule);
850
+ $has_no_filters = true;
851
+ foreach ($discount_rule as $condition_type){
852
+ if(isset($condition_type->products_in_list)){
853
+ $this->form->setFilter('products', 'in_list', $condition_type->products_in_list);
854
+ $has_no_filters = false;
855
+ }
856
+ if(isset($condition_type->products_not_in_list)){
857
+ $this->form->setFilter('products', 'not_in_list', $condition_type->products_not_in_list);
858
+ }
859
+ if(isset($condition_type->exclude_sale_products)){
860
+ $this->form->setFilter('product_on_sale', 'not_in_list');
861
+ }
862
+ if(isset($condition_type->categories_in)){
863
+ $this->form->setFilter('product_category', 'in_list', $condition_type->categories_in);
864
+ $has_no_filters = false;
865
+ }
866
+ if(isset($condition_type->atleast_one_including_sub_categories)){
867
+ $this->form->setFilter('product_category', 'in_list', $condition_type->atleast_one_including_sub_categories);
868
+ $has_no_filters = false;
869
+ }
870
+ if(isset($condition_type->in_each_category)){
871
+ $this->form->setFilter('product_category', 'in_list', $condition_type->in_each_category);
872
+ $has_no_filters = false;
873
+ }
874
+ if(isset($condition_type->exclude_categories)){
875
+ $this->form->setFilter('product_category', 'not_in_list', $condition_type->exclude_categories);
876
+ }
877
+ }
878
+ if($has_no_filters){
879
+ $this->form->setFilter('all_products');
880
+ }
881
+ }
882
+ }
883
+
884
+ /**
885
+ * Get data in right format
886
+ * */
887
+ protected function getData($data){
888
+ if(is_array($data)){
889
+ return $data;
890
+ } else if(is_serialized($data)){
891
+ return unserialize($data);
892
+ } else {
893
+ return json_decode($data);
894
+ }
895
+ }
896
+
897
+ /**
898
+ * Process common data
899
+ * */
900
+ protected function processDiscountType($price_rule, $type = 'price'){
901
+ if($type == 'price'){
902
+ if($price_rule->rule_method == 'qty_based'){
903
+ $discount_range = $this->getDiscountRange($price_rule);
904
+ $discount_type = $this->getDiscountTypeFromV1($discount_range);
905
+ $this->form->discount_type = 'wdr_bulk_discount';
906
+ if(in_array($discount_type, array('percentage_discount', 'price_discount', 'fixed_price'))){
907
+ $this->form->discount_type = 'wdr_bulk_discount';
908
+ } elseif ($discount_type == 'set_discount'){
909
+ $this->form->discount_type = 'wdr_set_discount';
910
+ } elseif ($discount_type == 'buy_x_get_x'){
911
+ $this->form->discount_type = 'wdr_buy_x_get_x_discount';
912
+ } elseif ($discount_type == 'buy_x_get_y'){
913
+ $this->form->discount_type = 'wdr_buy_x_get_y_discount';
914
+ $this->form->setBuyXGetYOption();
915
+ } elseif ($discount_type == 'more_than_one_cheapest'){
916
+ $this->form->discount_type = 'wdr_buy_x_get_y_discount';
917
+ $this->form->setBuyXGetYOption('bxgy_product', 'cheapest');
918
+ } elseif ($discount_type == 'more_than_one_cheapest_from_cat'){
919
+ $this->form->discount_type = 'wdr_buy_x_get_y_discount';
920
+ $this->form->setBuyXGetYOption('bxgy_category', 'cheapest');
921
+ } else {
922
+ $this->form->discount_type = 'wdr_buy_x_get_y_discount';
923
+ $this->form->setBuyXGetYOption('bxgy_all', 'cheapest');
924
+ }
925
+ } else {
926
+ $condition = $this->getData($price_rule->product_based_condition);
927
+ $has_set = false;
928
+ if($condition->get_discount_type == "product"){
929
+ if(isset($condition->product_to_apply_count_option) && $condition->product_to_apply_count_option == "apply_first"){
930
+ $this->form->discount_type = 'wdr_set_discount';
931
+ $has_set = true;
932
+ }
933
+ }
934
+ if($has_set == false){
935
+ $this->form->discount_type = 'wdr_simple_discount';
936
+ }
937
+ }
938
+ } else {
939
+ if($price_rule->discount_type == "product_discount"){
940
+ $this->form->discount_type = 'wdr_buy_x_get_y_discount';
941
+ } elseif ($price_rule->discount_type == "shipping_price"){
942
+ $this->form->discount_type = 'wdr_free_shipping';
943
+ } else {
944
+ $this->form->discount_type = 'wdr_cart_discount';
945
+ }
946
+ }
947
+ }
948
+
949
+ protected function getDiscountRange($rule){
950
+ if(isset($rule->meta['discount_range'][0])){
951
+ return $this->getData($rule->meta['discount_range'][0]);
952
+ }
953
+
954
+ return $rule->discount_range;
955
+ }
956
+
957
+ protected function getDiscountTypeFromV1($discount_range){
958
+ if(isset($discount_range[0])){
959
+ $discount_type = $discount_range[0]->discount_type;
960
+ } else {
961
+ $discount_type = $discount_range->{0}->discount_type;
962
+ }
963
+
964
+ return $discount_type;
965
+ }
966
+
967
+ /**
968
+ * Process common data
969
+ * */
970
+ protected function processCommonData($price_rule){
971
+ $this->form->title = $price_rule->post_title;
972
+ $this->form->enabled = ($price_rule->status == 'disable')? 0: 1;
973
+ $this->form->additional = array('condition_relationship' => 'and');
974
+ $this->form->usage_limits = 0;
975
+ $this->form->date_from = isset($price_rule->date_from)? $price_rule->date_from: '';
976
+ $this->form->date_to = isset($price_rule->date_to)? $price_rule->date_to: '';
977
+ if(isset($price_rule->wpml_language)){
978
+ if(!empty($price_rule->wpml_language)){
979
+ $this->form->rule_language = array($price_rule->wpml_language);
980
+ }
981
+ }
982
+ }
983
+
984
+ /**
985
+ * Alter query
986
+ * */
987
+ public function filter_where( $where = '', $object ) {
988
+ $query_array = $object->query;
989
+ if(isset($query_array['awdr_last_upgrade_id'])){
990
+ if($query_array['awdr_last_upgrade_id'] > 0){
991
+ $last_id = (int)$query_array['awdr_last_upgrade_id'];
992
+ $where .= " AND wp_posts.ID > ".$last_id." ";
993
+ }
994
+ }
995
+
996
+ return $where;
997
+ }
998
+
999
+ /**
1000
+ * Get v1 rules
1001
+ * @param $post_type string
1002
+ * @return mixed
1003
+ * */
1004
+ public function getV1Rules($post_type = 'woo_discount', $count = 0){
1005
+ if($post_type == 'woo_discount'){
1006
+ $last_id = $this->getMigrationInfoOf('v1_last_migrated_price_rule_id', 0);
1007
+ } else {
1008
+ $last_id = $this->getMigrationInfoOf('v1_last_migrated_cart_rule_id', 0);
1009
+ }
1010
+
1011
+ $post_args = array('post_type' => $post_type);
1012
+ if($count){
1013
+ $post_args['numberposts'] = '-1';
1014
+ } else {
1015
+ $post_args['numberposts'] = $this->migration_count_on_a_set;
1016
+ }
1017
+ $post_args['orderby'] = 'ID';
1018
+ $post_args['order'] = 'ASC';
1019
+ $post_args['suppress_filters'] = false;
1020
+ $post_args['awdr_last_upgrade_id'] = $last_id;
1021
+
1022
+ add_filter( 'posts_where', array($this, 'filter_where'), 10, 2);
1023
+ $posts = get_posts($post_args);
1024
+ remove_filter( 'posts_where', array($this, 'filter_where'), 10);
1025
+
1026
+ if (!empty($posts) && count($posts) > 0) {
1027
+ foreach ($posts as $index => $item) {
1028
+ $posts[$index]->meta = get_post_meta($posts[$index]->ID);
1029
+ }
1030
+ }
1031
+
1032
+ return $posts;
1033
+ }
1034
+ }
v2/App/Helpers/ProOptions.php ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class ProOptions
8
+ {
9
+ public static function init(){
10
+ self::hooks();
11
+ }
12
+
13
+ /**
14
+ * Hooks
15
+ * */
16
+ protected static function hooks(){
17
+ add_filter('advanced_woo_discount_rules_filters', array(__CLASS__, 'addProFilters'));
18
+ add_filter('advanced_woo_discount_rules_conditions', array(__CLASS__, 'addProConditions'));
19
+ add_filter('advanced_woo_discount_rules_adjustment_type', array(__CLASS__, 'addProAdjustmentType'));
20
+ }
21
+
22
+ /**
23
+ * Add Pro adjustment type
24
+ *
25
+ * @param $filter_types array
26
+ * @return array
27
+ * */
28
+ public static function addProFilters($filter_types){
29
+ $is_pro = Helper::hasPro();
30
+ if($is_pro === false){
31
+ $filter_types['product_category'] = array(
32
+ 'active' => false,
33
+ 'label' => __('Category - PRO -', WDR_TEXT_DOMAIN),
34
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
35
+ 'template' => '',
36
+ );
37
+ $filter_types['product_attributes'] = array(
38
+ 'active' => false,
39
+ 'label' => __('Attributes - PRO -', WDR_TEXT_DOMAIN),
40
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
41
+ 'template' => '',
42
+ );
43
+ $filter_types['product_tags'] = array(
44
+ 'active' => false,
45
+ 'label' => __('Tags - PRO -', WDR_TEXT_DOMAIN),
46
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
47
+ 'template' => '',
48
+ );
49
+ $filter_types['product_sku'] = array(
50
+ 'active' => false,
51
+ 'label' => __('SKUs - PRO -', WDR_TEXT_DOMAIN),
52
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
53
+ 'template' => '',
54
+ );
55
+ $filter_types['product_on_sale'] = array(
56
+ 'active' => false,
57
+ 'label' => __('On sale products - PRO -', WDR_TEXT_DOMAIN),
58
+ 'group' => __('Product', WDR_TEXT_DOMAIN),
59
+ 'template' => '',
60
+ );
61
+
62
+ }
63
+
64
+ return $filter_types;
65
+ }
66
+
67
+ /**
68
+ * Add Pro conditions
69
+ *
70
+ * @param $available_conditions array
71
+ * @return array
72
+ * */
73
+ public static function addProConditions($available_conditions){
74
+ $is_pro = Helper::hasPro();
75
+ if($is_pro === false){
76
+ $available_conditions['cart_coupon'] = array(
77
+ 'object' => '\Wdr\App\Conditions\Base',
78
+ 'enable' => false,
79
+ 'label' => __('Coupons - PRO -', WDR_TEXT_DOMAIN),
80
+ 'group' => __('Cart', WDR_TEXT_DOMAIN),
81
+ 'template' => '',
82
+ 'extra_params' => array(),
83
+ );
84
+ $available_conditions['cart_item_product_attributes'] = array(
85
+ 'object' => '\Wdr\App\Conditions\Base',
86
+ 'enable' => false,
87
+ 'label' => __('Attributes - PRO -', WDR_TEXT_DOMAIN),
88
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
89
+ 'template' => '',
90
+ 'extra_params' => array(),
91
+ );
92
+ $available_conditions['cart_item_product_category'] = array(
93
+ 'object' => '\Wdr\App\Conditions\Base',
94
+ 'enable' => false,
95
+ 'label' => __('Category - PRO -', WDR_TEXT_DOMAIN),
96
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
97
+ 'template' => '',
98
+ 'extra_params' => array(),
99
+ );
100
+ $available_conditions['cart_item_product_combination'] = array(
101
+ 'object' => '\Wdr\App\Conditions\Base',
102
+ 'enable' => false,
103
+ 'label' => __('Product combination - PRO -', WDR_TEXT_DOMAIN),
104
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
105
+ 'template' => '',
106
+ 'extra_params' => array(),
107
+ );
108
+ $available_conditions['cart_item_products'] = array(
109
+ 'object' => '\Wdr\App\Conditions\Base',
110
+ 'enable' => false,
111
+ 'label' => __('Products - PRO -', WDR_TEXT_DOMAIN),
112
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
113
+ 'template' => '',
114
+ 'extra_params' => array(),
115
+ );
116
+ $available_conditions['cart_item_product_sku'] = array(
117
+ 'object' => '\Wdr\App\Conditions\Base',
118
+ 'enable' => false,
119
+ 'label' => __('SKU - PRO -', WDR_TEXT_DOMAIN),
120
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
121
+ 'template' => '',
122
+ 'extra_params' => array(),
123
+ );
124
+ $available_conditions['cart_item_product_tags'] = array(
125
+ 'object' => '\Wdr\App\Conditions\Base',
126
+ 'enable' => false,
127
+ 'label' => __('Tags - PRO -', WDR_TEXT_DOMAIN),
128
+ 'group' => __('Cart Items', WDR_TEXT_DOMAIN),
129
+ 'template' => '',
130
+ 'extra_params' => array(),
131
+ );
132
+ $available_conditions['cart_items_quantity'] = array(
133
+ 'object' => '\Wdr\App\Conditions\Base',
134
+ 'enable' => false,
135
+ 'label' => __('Cart items quantity - PRO -', WDR_TEXT_DOMAIN),
136
+ 'group' => __('Cart', WDR_TEXT_DOMAIN),
137
+ 'template' => '',
138
+ 'extra_params' => array(),
139
+ );
140
+ $available_conditions['cart_items_weight'] = array(
141
+ 'object' => '\Wdr\App\Conditions\Base',
142
+ 'enable' => false,
143
+ 'label' => __('Total weight - PRO -', WDR_TEXT_DOMAIN),
144
+ 'group' => __('Cart', WDR_TEXT_DOMAIN),
145
+ 'template' => '',
146
+ 'extra_params' => array(),
147
+ );
148
+ $available_conditions['cart_payment_method'] = array(
149
+ 'object' => '\Wdr\App\Conditions\Base',
150
+ 'enable' => false,
151
+ 'label' => __('Payment Method - PRO -', WDR_TEXT_DOMAIN),
152
+ 'group' => __('Cart', WDR_TEXT_DOMAIN),
153
+ 'template' => '',
154
+ 'extra_params' => array(),
155
+ );
156
+ $available_conditions['order_date'] = array(
157
+ 'object' => '\Wdr\App\Conditions\Base',
158
+ 'enable' => false,
159
+ 'label' => __('Date - PRO -', WDR_TEXT_DOMAIN),
160
+ 'group' => __('Date & Time', WDR_TEXT_DOMAIN),
161
+ 'template' => '',
162
+ 'extra_params' => array(),
163
+ );
164
+ $available_conditions['order_date_and_time'] = array(
165
+ 'object' => '\Wdr\App\Conditions\Base',
166
+ 'enable' => false,
167
+ 'label' => __('Date and Time - PRO -', WDR_TEXT_DOMAIN),
168
+ 'group' => __('Date & Time', WDR_TEXT_DOMAIN),
169
+ 'template' => '',
170
+ 'extra_params' => array(),
171
+ );
172
+ $available_conditions['order_days'] = array(
173
+ 'object' => '\Wdr\App\Conditions\Base',
174
+ 'enable' => false,
175
+ 'label' => __('Days - PRO -', WDR_TEXT_DOMAIN),
176
+ 'group' => __('Date & Time', WDR_TEXT_DOMAIN),
177
+ 'template' => '',
178
+ 'extra_params' => array(),
179
+ );
180
+ $available_conditions['order_time'] = array(
181
+ 'object' => '\Wdr\App\Conditions\Base',
182
+ 'enable' => false,
183
+ 'label' => __('Time - PRO -', WDR_TEXT_DOMAIN),
184
+ 'group' => __('Date & Time', WDR_TEXT_DOMAIN),
185
+ 'template' => '',
186
+ 'extra_params' => array(),
187
+ );
188
+ $available_conditions['purchase_first_order'] = array(
189
+ 'object' => '\Wdr\App\Conditions\Base',
190
+ 'enable' => false,
191
+ 'label' => __('First order - PRO -', WDR_TEXT_DOMAIN),
192
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
193
+ 'template' => '',
194
+ 'extra_params' => array(),
195
+ );
196
+ $available_conditions['purchase_last_order'] = array(
197
+ 'object' => '\Wdr\App\Conditions\Base',
198
+ 'enable' => false,
199
+ 'label' => __('Last order - PRO -', WDR_TEXT_DOMAIN),
200
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
201
+ 'template' => '',
202
+ 'extra_params' => array(),
203
+ );
204
+ $available_conditions['purchase_last_order_amount'] = array(
205
+ 'object' => '\Wdr\App\Conditions\Base',
206
+ 'enable' => false,
207
+ 'label' => __('Last order amount - PRO -', WDR_TEXT_DOMAIN),
208
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
209
+ 'template' => '',
210
+ 'extra_params' => array(),
211
+ );
212
+ $available_conditions['purchase_previous_orders'] = array(
213
+ 'object' => '\Wdr\App\Conditions\Base',
214
+ 'enable' => false,
215
+ 'label' => __('Number of orders made - PRO -', WDR_TEXT_DOMAIN),
216
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
217
+ 'template' => '',
218
+ 'extra_params' => array(),
219
+ );
220
+ $available_conditions['purchase_previous_orders_for_specific_product'] = array(
221
+ 'object' => '\Wdr\App\Conditions\Base',
222
+ 'enable' => false,
223
+ 'label' => __('Number of orders made with following products - PRO -', WDR_TEXT_DOMAIN),
224
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
225
+ 'template' => '',
226
+ 'extra_params' => array(),
227
+ );
228
+ $available_conditions['purchase_spent'] = array(
229
+ 'object' => '\Wdr\App\Conditions\Base',
230
+ 'enable' => false,
231
+ 'label' => __('Spent - PRO -', WDR_TEXT_DOMAIN),
232
+ 'group' => __('Purchase History', WDR_TEXT_DOMAIN),
233
+ 'template' => '',
234
+ 'extra_params' => array(),
235
+ );
236
+ $available_conditions['shipping_city'] = array(
237
+ 'object' => '\Wdr\App\Conditions\Base',
238
+ 'enable' => false,
239
+ 'label' => __('City - PRO -', WDR_TEXT_DOMAIN),
240
+ 'group' => __('Shipping', WDR_TEXT_DOMAIN),
241
+ 'template' => '',
242
+ 'extra_params' => array(),
243
+ );
244
+ $available_conditions['shipping_country'] = array(
245
+ 'object' => '\Wdr\App\Conditions\Base',
246
+ 'enable' => false,
247
+ 'label' => __('Country - PRO -', WDR_TEXT_DOMAIN),
248
+ 'group' => __('Shipping', WDR_TEXT_DOMAIN),
249
+ 'template' => '',
250
+ 'extra_params' => array(),
251
+ );
252
+ $available_conditions['shipping_state'] = array(
253
+ 'object' => '\Wdr\App\Conditions\Base',
254
+ 'enable' => false,
255
+ 'label' => __('State - PRO -', WDR_TEXT_DOMAIN),
256
+ 'group' => __('Shipping', WDR_TEXT_DOMAIN),
257
+ 'template' => '',
258
+ 'extra_params' => array(),
259
+ );
260
+ $available_conditions['shipping_zipcode'] = array(
261
+ 'object' => '\Wdr\App\Conditions\Base',
262
+ 'enable' => false,
263
+ 'label' => __('Zipcode - PRO -', WDR_TEXT_DOMAIN),
264
+ 'group' => __('Shipping', WDR_TEXT_DOMAIN),
265
+ 'template' => '',
266
+ 'extra_params' => array(),
267
+ );
268
+ $available_conditions['user_email'] = array(
269
+ 'object' => '\Wdr\App\Conditions\Base',
270
+ 'enable' => false,
271
+ 'label' => __('Email - PRO -', WDR_TEXT_DOMAIN),
272
+ 'group' => __('Customer', WDR_TEXT_DOMAIN),
273
+ 'template' => '',
274
+ 'extra_params' => array(),
275
+ );
276
+ $available_conditions['user_list'] = array(
277
+ 'object' => '\Wdr\App\Conditions\Base',
278
+ 'enable' => false,
279
+ 'label' => __('User - PRO -', WDR_TEXT_DOMAIN),
280
+ 'group' => __('Customer', WDR_TEXT_DOMAIN),
281
+ 'template' => '',
282
+ 'extra_params' => array(),
283
+ );
284
+ $available_conditions['user_logged_in'] = array(
285
+ 'object' => '\Wdr\App\Conditions\Base',
286
+ 'enable' => false,
287
+ 'label' => __('Is logged in - PRO -', WDR_TEXT_DOMAIN),
288
+ 'group' => __('Customer', WDR_TEXT_DOMAIN),
289
+ 'template' => '',
290
+ 'extra_params' => array(),
291
+ );
292
+ $available_conditions['user_role'] = array(
293
+ 'object' => '\Wdr\App\Conditions\Base',
294
+ 'enable' => false,
295
+ 'label' => __('User role - PRO -', WDR_TEXT_DOMAIN),
296
+ 'group' => __('Customer', WDR_TEXT_DOMAIN),
297
+ 'template' => '',
298
+ 'extra_params' => array(),
299
+ );
300
+
301
+ }
302
+ return $available_conditions;
303
+ }
304
+
305
+ /**
306
+ * Add Pro adjustment type
307
+ *
308
+ * @param $adjustment_type array
309
+ * @return array
310
+ * */
311
+ public static function addProAdjustmentType($adjustment_type){
312
+ $is_pro = Helper::hasPro();
313
+ if($is_pro === false){
314
+ $adjustment_type['wdr_buy_x_get_x_discount'] = array(
315
+ 'class' => '',
316
+ 'enable' => false,
317
+ 'label' => __('Buy X get X - PRO -', WDR_TEXT_DOMAIN),
318
+ 'group' => __('Bogo Discount', WDR_TEXT_DOMAIN),
319
+ 'template' => '',
320
+ );
321
+ $adjustment_type['wdr_buy_x_get_y_discount'] = array(
322
+ 'class' => '',
323
+ 'enable' => false,
324
+ 'label' => __('Buy X get Y - PRO -', WDR_TEXT_DOMAIN),
325
+ 'group' => __('Bogo Discount', WDR_TEXT_DOMAIN),
326
+ 'template' => '',
327
+ );
328
+ $adjustment_type['wdr_free_shipping'] = array(
329
+ 'class' => '',
330
+ 'enable' => false,
331
+ 'label' => __('Free Shipping - PRO -', WDR_TEXT_DOMAIN),
332
+ 'group' => __('Simple Discount', WDR_TEXT_DOMAIN),
333
+ );
334
+ $adjustment_type['wdr_set_discount'] = array(
335
+ 'class' => '',
336
+ 'enable' => false,
337
+ 'label' => __('Set Discount - PRO -', WDR_TEXT_DOMAIN),
338
+ 'group' => __('Bulk Discount', WDR_TEXT_DOMAIN),
339
+ );
340
+ }
341
+
342
+ return $adjustment_type;
343
+ }
344
+ }
345
+
346
+ ProOptions::init();
v2/App/Helpers/Rule.php ADDED
@@ -0,0 +1,1507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ use stdClass;
6
+ use Wdr\App\Controllers\OnSaleShortCode;
7
+ use Wdr\App\Models\DBTable;
8
+
9
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
+
11
+ class Rule
12
+ {
13
+ public $rule, $available_conditions;
14
+ public static $woocommerce_helper, $set_discount_count = array(), $set_discounts = array(), $bulk_discounts = array(), $simple_discounts = array(), $additional_discounts = array();
15
+
16
+ /**
17
+ * @param $rule_data
18
+ * @param $available_conditions
19
+ * @return $this
20
+ */
21
+ function __construct($rule_data = array(), $available_conditions = array())
22
+ {
23
+ if (!empty($rule_data)) {
24
+ $this->rule = $rule_data;
25
+ $this->available_conditions = $available_conditions;
26
+ self::$woocommerce_helper = (empty(self::$woocommerce_helper)) ? new Woocommerce() : self::$woocommerce_helper;
27
+ }
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * get all rules and set object
33
+ * @param $available_conditions array
34
+ * @return array
35
+ */
36
+ function getAvailableRules($available_conditions, $rule_id = NULL)
37
+ {
38
+ $available_rules = DBTable::getRules($rule_id);
39
+ return $this->getRuleObject($available_rules, $available_conditions);
40
+ }
41
+
42
+ /**
43
+ * convert rules to rule object
44
+ * @param $rules
45
+ * @param $conditions
46
+ * @return array
47
+ */
48
+ function getRuleObject($rules, $conditions)
49
+ {
50
+ $rule_list = array();
51
+ if (!empty($rules)) {
52
+ if (is_array($rules)) {
53
+ foreach ($rules as $rule) {
54
+ $rule_obj = new self($rule, $conditions);
55
+ $rule_id = $rule_obj->getId();
56
+ $rule_list[$rule_id] = $rule_obj;
57
+ }
58
+ } else {
59
+ $rule_list = new self($rules, $conditions);
60
+ }
61
+ }
62
+ return $rule_list;
63
+ }
64
+
65
+ /**
66
+ * get the rule ID
67
+ * @return int|null
68
+ */
69
+ function getId()
70
+ {
71
+ if (isset($this->rule->id)) {
72
+ return $this->rule->id;
73
+ }
74
+ return NULL;
75
+ }
76
+
77
+ /**
78
+ * get the rule ID
79
+ * @return int|null
80
+ */
81
+ function getPriorityId()
82
+ {
83
+ if (isset($this->rule->priority)) {
84
+ return $this->rule->priority;
85
+ }
86
+ return NULL;
87
+ }
88
+
89
+ /**
90
+ * Get rule discount type
91
+ * @return bool || Type
92
+ */
93
+ function getRuleDiscountType(){
94
+ if (isset($this->rule->discount_type)) {
95
+ return $this->rule->discount_type;
96
+ }
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * get all rules and set object
102
+ * @param $available_conditions array
103
+ * @return array
104
+ */
105
+ function getAllRules($available_conditions)
106
+ {
107
+ $available_rules = DBTable::getRules();
108
+ return $this->getRuleObject($available_rules, $available_conditions);
109
+ }
110
+
111
+ /**
112
+ * get particular and set object
113
+ * @param $rule_id int
114
+ * @param $available_conditions array
115
+ * @return array
116
+ */
117
+ function getRule($rule_id, $available_conditions)
118
+ {
119
+ $rule = DBTable::getRules($rule_id);
120
+ if (empty($rule)) {
121
+ $rule = $this->defaultRuleObj();
122
+ }
123
+ return $this->getRuleObject($rule, $available_conditions);
124
+ }
125
+
126
+ /**
127
+ * @param $from
128
+ * @param $to
129
+ * @param $option
130
+ * @return array|object|null
131
+ */
132
+ function getRuleByPeriod($from, $to, $option)
133
+ {
134
+ $rule = DBTable::getRulesByPeriod($from, $to, $option);
135
+ return $rule;
136
+ }
137
+
138
+ /**
139
+ * set the default rule obj
140
+ * @return stdClass
141
+ */
142
+ function defaultRuleObj()
143
+ {
144
+ //Todo: change default object if any modification happen in table structure
145
+ $obj = new stdClass();
146
+ $obj->id = NULL;
147
+ $obj->enabled = 1;
148
+ $obj->exclusive = 0;
149
+ $obj->priority = NULL;
150
+ $obj->apply_to = NULL;
151
+ $obj->filters = NULL;
152
+ $obj->conditions = NULL;
153
+ $obj->product_adjustments = NULL;
154
+ $obj->cart_adjustments = NULL;
155
+ $obj->bogo_adjustments = NULL;
156
+ $obj->bulk_adjustments = '{"operator":"product","type":"percentage","ranges":false,"table_message":""}';
157
+ $obj->set_adjustments = '{"discount_type":"fixed_set_price","ranges":false,"table_message":""}';
158
+ $obj->other_discounts = NULL;
159
+ $obj->date_from = NULL;
160
+ $obj->date_to = NULL;
161
+ $obj->usage_limits = NULL;
162
+ $obj->rule_language = NULL;
163
+ $obj->used_limits = 0;
164
+ $obj->additional = NULL;
165
+ $obj->max_discount_sum = NULL;
166
+ $obj->advanced_discount_message = NULL;
167
+ $obj->discount_type = NULL;
168
+ return $obj;
169
+ }
170
+
171
+ /**
172
+ * get the rule usage limits
173
+ * @return int|null
174
+ */
175
+ function getUsageLimits()
176
+ {
177
+ if (isset($this->rule->usage_limits)) {
178
+ return $this->rule->usage_limits;
179
+ }
180
+ return 0;
181
+ }
182
+
183
+ /**
184
+ * get the rule used limits
185
+ * @return int|null
186
+ */
187
+ function getUsedLimits()
188
+ {
189
+ if (isset($this->rule->used_limits)) {
190
+ return $this->rule->used_limits;
191
+ }
192
+ return 0;
193
+ }
194
+
195
+ /**
196
+ * Is the rule is exclusive rule
197
+ * @return bool
198
+ */
199
+ function isExclusive()
200
+ {
201
+ if (isset($this->rule->exclusive)) {
202
+ if ($this->rule->exclusive == 1) {
203
+ return true;
204
+ }
205
+ }
206
+ return false;
207
+ }
208
+
209
+ /**
210
+ * Rule title
211
+ * @return string|null
212
+ */
213
+ function getTitle()
214
+ {
215
+ if (isset($this->rule->title)) {
216
+ return $this->rule->title;
217
+ }
218
+ return NULL;
219
+ }
220
+
221
+ /**
222
+ * Rule is enabled
223
+ * @return string|null
224
+ */
225
+ function isEnabled()
226
+ {
227
+ if (isset($this->rule->enabled)) {
228
+ if ($this->rule->enabled == 1) {
229
+ return true;
230
+ }
231
+ }
232
+ return false;
233
+ }
234
+
235
+ /**
236
+ * get the start date of rule
237
+ * @param bool $timestamp
238
+ * @param string $format
239
+ * @return false|string|null
240
+ */
241
+ function getStartDate($timestamp = false, $format = "Y-m-d H:i:s")
242
+ {
243
+ if (isset($this->rule->date_from) && !empty($this->rule->date_from)) {
244
+ if ($timestamp) {
245
+ return $this->rule->date_from;
246
+ }
247
+ return $this->formatDate($this->rule->date_from, $format);
248
+ }
249
+ return NULL;
250
+ }
251
+
252
+ /**
253
+ * formatting the date
254
+ * @param $date
255
+ * @param string $format
256
+ * @param bool $time_stamp
257
+ * @return false|string
258
+ */
259
+ function formatDate($date, $format = "Y-m-d H:i:s", $time_stamp = false)
260
+ {
261
+ if ($time_stamp) {
262
+ return strtotime($date);
263
+ }
264
+ return date($format, $date);
265
+ }
266
+
267
+ /**
268
+ * get the start date of rule
269
+ * @param bool $timestamp
270
+ * @param string $format
271
+ * @return false|string|null
272
+ */
273
+ function getEndDate($timestamp = false, $format = "Y-m-d H:i:s")
274
+ {
275
+ if (isset($this->rule->date_to) && !empty($this->rule->date_to)) {
276
+ if ($timestamp) {
277
+ return $this->rule->date_to;
278
+ }
279
+ return $this->formatDate($this->rule->date_to, $format);
280
+ }
281
+ return NULL;
282
+ }
283
+
284
+ /**
285
+ * get the bulk adjustment details
286
+ * @return array|bool|mixed|object
287
+ */
288
+ function getBulkAdjustments()
289
+ {
290
+ if ($this->hasBulkDiscount()) {
291
+ return json_decode($this->rule->bulk_adjustments);
292
+ }
293
+ return false;
294
+ }
295
+
296
+ /**
297
+ * check the rule has bulk discount
298
+ * @return bool
299
+ */
300
+ function hasBulkDiscount()
301
+ {
302
+ if (!empty($this->rule->bulk_adjustments) && $this->rule->bulk_adjustments != '{}' && $this->rule->bulk_adjustments != '[]') {
303
+ return true;
304
+ }
305
+ return false;
306
+ }
307
+
308
+ /**
309
+ * check the rule has bulk discount
310
+ * @return bool
311
+ */
312
+ function getBuyXGetYAdjustment()
313
+ {
314
+ if (!empty($this->rule->buy_x_get_y_adjustments) && $this->rule->buy_x_get_y_adjustments != '{}' && $this->rule->buy_x_get_y_adjustments != '[]') {
315
+ return json_decode($this->rule->buy_x_get_y_adjustments);
316
+ }
317
+ return false;
318
+ }
319
+
320
+ /**
321
+ * Check the filter is passed for product
322
+ * @param $product
323
+ * @param $sale_badge
324
+ * @return bool
325
+ */
326
+ function isFilterPassed($product, $sale_badge = false)
327
+ {
328
+ if (!$this->hasFilter()) {
329
+ return true;
330
+ }
331
+ $filters = $this->getFilter();
332
+ if (!empty($filters)) {
333
+ $filter_helper = new Filter();
334
+ $filter_passed = $filter_helper->matchFilters($product, $filters, $sale_badge);
335
+ $conditions = $this->getConditions();
336
+ $filter_passed_user_role = $filter_passed_user_list = $user_role_passed = $user_list_passed = false;
337
+ if($filter_passed){
338
+ if(!empty($conditions)){
339
+ foreach($conditions as $condition){
340
+ $cart = array();
341
+ $options = isset($condition->options) ? $condition->options : array();
342
+ if( $condition->type == 'user_role' ){
343
+ $user_role_passed = true;
344
+ if (!empty($options) && isset($this->available_conditions[$condition->type]['object'])) {
345
+ $this->available_conditions[$condition->type]['object']->rule = $this;
346
+ $filter_passed_user_role = $this->available_conditions[$condition->type]['object']->check($cart, $options);
347
+ }
348
+ }
349
+ if( $condition->type == 'user_list'){
350
+ $user_list_passed = true;
351
+ if (!empty($options) && isset($this->available_conditions[$condition->type]['object'])) {
352
+ $this->available_conditions[$condition->type]['object']->rule = $this;
353
+ $filter_passed_user_list = $this->available_conditions[$condition->type]['object']->check($cart, $options);
354
+ }
355
+ }
356
+ }
357
+ }
358
+ if($user_role_passed || $user_list_passed){
359
+ if($filter_passed_user_role || $filter_passed_user_list){
360
+ return $filter_passed;
361
+ }else{
362
+ return false;
363
+ }
364
+ }
365
+ if(!$user_role_passed && !$user_list_passed){
366
+ return $filter_passed;
367
+ }
368
+ }
369
+ return $filter_passed;
370
+ } else {
371
+ return true;
372
+ }
373
+ }
374
+
375
+ /**
376
+ * check the rule has filter
377
+ * @return bool
378
+ */
379
+ function hasFilter()
380
+ {
381
+ if (isset($this->rule->filters)) {
382
+ if (empty($this->rule->filters) || $this->rule->filters == '{}' || $this->rule->filters == '[]') {
383
+ return false;
384
+ } else {
385
+ return true;
386
+ }
387
+ }
388
+ return false;
389
+ }
390
+
391
+ /**
392
+ * get the rule filter
393
+ * @return array|bool|mixed|object
394
+ */
395
+ function getFilter()
396
+ {
397
+ if ($this->hasFilter()) {
398
+ return json_decode($this->rule->filters);
399
+ }
400
+ return false;
401
+ }
402
+
403
+ /**
404
+ * get filter type
405
+ * @param $filter
406
+ * @return null
407
+ */
408
+ function getFilterType($filter)
409
+ {
410
+ if (is_object($filter) && isset($filter->type)) {
411
+ return $filter->type;
412
+ } elseif (is_array($filter) && isset($filter['type'])) {
413
+ return $filter['type'];
414
+ }
415
+ return NULL;
416
+ }
417
+
418
+ /**
419
+ * get filter method
420
+ * @param $filter
421
+ * @return null
422
+ */
423
+ function getFilterMethod($filter)
424
+ {
425
+ if (is_object($filter) && isset($filter->method)) {
426
+ return $filter->method;
427
+ } elseif (is_array($filter) && isset($filter['method'])) {
428
+ return $filter['method'];
429
+ }
430
+ return NULL;
431
+ }
432
+
433
+ /**
434
+ * get filter method
435
+ * @param $filter
436
+ * @return null
437
+ */
438
+ function getFilterOptionValue($filter)
439
+ {
440
+ if (is_object($filter) && isset($filter->value)) {
441
+ return $filter->value;
442
+ } elseif (is_array($filter) && isset($filter['value'])) {
443
+ return $filter['value'];
444
+ }
445
+ return array();
446
+ }
447
+
448
+ /**
449
+ * get filter parent product id for sale batch
450
+ * @param $filter
451
+ * @return null
452
+ */
453
+ function getFilterOptionParentValue($filter)
454
+ {
455
+ if (is_object($filter) && isset($filter->product_variants_for_sale_badge)) {
456
+ return $filter->product_variants_for_sale_badge;
457
+ } elseif (is_array($filter) && isset($filter['product_variants_for_sale_badge'])) {
458
+ return $filter['product_variants_for_sale_badge'];
459
+ }
460
+ return array();
461
+ }
462
+
463
+ /**
464
+ * get the rule relationship
465
+ * @param $type
466
+ * @param $default
467
+ * @return mixed
468
+ */
469
+ function getRelationship($type, $default)
470
+ {
471
+ $relations = $this->getAdditionalRuleData();
472
+ if (isset($relations[$type . '_relationship']) && !empty($relations[$type . '_relationship'])) {
473
+ return $relations[$type . '_relationship'];
474
+ }
475
+ return $default;
476
+ }
477
+
478
+ /**
479
+ * get the show hide bulk or set table
480
+ * @param $default
481
+ * @return mixed
482
+ */
483
+ function showBulkDiscountsTable($default)
484
+ {
485
+ $bulk_table_display = $this->getAdditionalRuleData();
486
+ if (isset($bulk_table_display['bulk_table_display']) && !empty($bulk_table_display['bulk_table_display'])) {
487
+ return $bulk_table_display['bulk_table_display'];
488
+ }
489
+ return $default;
490
+ }
491
+
492
+ /**
493
+ * get additional column data
494
+ * @return array|mixed|object
495
+ */
496
+ function getAdditionalRuleData()
497
+ {
498
+ $additional = array();
499
+ if (isset($this->rule->additional)) {
500
+ if (!empty($this->rule->additional) && $this->rule->additional != '{}' && !$this->rule->additional != '[]') {
501
+ $additional = json_decode($this->rule->additional, true);
502
+ }
503
+ }
504
+ return $additional;
505
+ }
506
+
507
+ /**
508
+ * check the rule has advanced discount message/layout
509
+ * @return bool
510
+ */
511
+ function hasAdvancedDiscountMessage()
512
+ {
513
+ if (isset($this->rule->advanced_discount_message)) {
514
+ if (empty($this->rule->advanced_discount_message) || $this->rule->advanced_discount_message == '{}' || $this->rule->advanced_discount_message == '[]') {
515
+ return false;
516
+ } else {
517
+ return true;
518
+ }
519
+ }
520
+ return false;
521
+ }
522
+
523
+ /**
524
+ * get the badge settings
525
+ * @param $key
526
+ * @param $default
527
+ * @return array|bool|mixed|object
528
+ */
529
+ function getAdvancedDiscountMessage($key, $default = false)
530
+ {
531
+ if (empty($key)) {
532
+ return false;
533
+ }
534
+ if ($this->hasAdvancedDiscountMessage()) {
535
+ $badge_settings = json_decode($this->rule->advanced_discount_message);
536
+ if ($key == 'badge_text' && isset($badge_settings->badge_text) && !empty($badge_settings->badge_text)) {
537
+ return htmlspecialchars_decode($badge_settings->badge_text);
538
+ }
539
+ if (isset($badge_settings->$key) && !empty($badge_settings->$key)) {
540
+ return $badge_settings->$key;
541
+ } else {
542
+ return $default;
543
+ }
544
+ }
545
+ return false;
546
+ }
547
+
548
+ /**
549
+ * Calculate the discount
550
+ * @param $quantity
551
+ * @param $product_price
552
+ * @param $product
553
+ * @param $price_display_condition
554
+ * @param $is_cart
555
+ * @param $ajax_price
556
+ * @param $cart_item
557
+ * @return int
558
+ */
559
+ function calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item = array(), $price_display_condition, $is_cart=true)
560
+ {
561
+ $product_id = self::$woocommerce_helper->getProductId($product);
562
+ self::$simple_discounts[$product_id] = 0;
563
+ self::$bulk_discounts[$product_id] = 0;
564
+ self::$set_discounts[$product_id] = 0;
565
+ $product_discount = 0;
566
+ if ($this->hasProductDiscount()) {
567
+ $product_discount = $this->calculateProductDiscount($product_price, $product, $product_id, $price_display_condition, $is_cart);
568
+ self::$simple_discounts[$product_id] = $product_discount;
569
+ }
570
+ if ($this->hasCartDiscount()) {
571
+ return $this->calculateCartDiscount($product_price);
572
+ }
573
+ $product_bulk_discount = 0;
574
+ if ($this->hasBulkDiscount()) {
575
+ $product_bulk_discount = $this->calculateProductBulkDiscount($product_price, $quantity, $product, $price_display_condition, $is_cart);
576
+ self::$bulk_discounts[$product_id] = $product_bulk_discount;
577
+ }
578
+ $rule = $this;
579
+ $discounts = array(
580
+ 'product_discount' => $product_discount,
581
+ 'product_bulk_discount' => $product_bulk_discount
582
+ );
583
+
584
+ $discounts = apply_filters('advanced_woo_discount_rules_discounts_of_each_rule', $discounts, $rule, $product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart);
585
+
586
+ $total_discount = array_sum($discounts);
587
+ if ($total_discount <= 0) {
588
+ return false;
589
+ }
590
+ $max_discount = $this->getMaxDiscountSum();
591
+ if (!empty($max_discount) && $total_discount > $max_discount) {
592
+ return $max_discount;
593
+ }
594
+ return $total_discount;
595
+ }
596
+
597
+ /**
598
+ * check the rule has product discount
599
+ * @return bool
600
+ */
601
+ function hasProductDiscount()
602
+ {
603
+ if (isset($this->rule->product_adjustments)) {
604
+ if (!empty($this->rule->product_adjustments) && $this->rule->product_adjustments != '{}' && $this->rule->product_adjustments != '[]') {
605
+ return true;
606
+ }
607
+ }
608
+ return false;
609
+ }
610
+
611
+ /**
612
+ * Calculate the product discount
613
+ * @param $price
614
+ * @param $product
615
+ * @param $product_id
616
+ * @param $price_display_condition
617
+ * @param $is_cart
618
+ * @return float|int
619
+ */
620
+ function calculateProductDiscount($price, $product, $product_id, $price_display_condition, $is_cart)
621
+ {
622
+ $quantity = $cart_quantity = 0;
623
+ $cart_items = self::$woocommerce_helper->getCart();
624
+ $discount = $this->getProductAdjustments();
625
+ if($discount){
626
+ if(($price_display_condition == "show_when_matched" && !$is_cart) || ($price_display_condition == "show_dynamically" && !$is_cart)){
627
+ $quantity = 1;
628
+ }else if($price_display_condition == "show_after_matched" || $is_cart){
629
+ if(!empty($cart_items)){
630
+ foreach ($cart_items as $cart_item){
631
+ $current_product_parent_id = self::$woocommerce_helper->getProductParentId($product);
632
+ $cart_product_id = isset($cart_item['product_id']) ? $cart_item['product_id'] : 0;
633
+ $cart_variation_id = isset($cart_item['variation_id']) ? $cart_item['variation_id'] : 0;
634
+ if(empty($cart_variation_id)){
635
+ if(!empty($cart_product_id) && $cart_product_id == $product_id){
636
+ $cart_quantity = isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
637
+ }
638
+ }
639
+ if(!empty($cart_variation_id)){
640
+ if(!empty($cart_product_id) && $cart_product_id == $current_product_parent_id){
641
+ $cart_quantity = isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
642
+ }
643
+ }
644
+ }
645
+ $quantity = $cart_quantity;
646
+ }
647
+ }
648
+
649
+ if ( $quantity > 0) {
650
+ return $this->calculator($discount->type, $price, $discount->value);
651
+ } else {
652
+ return 0;
653
+ }
654
+ }
655
+ return 0;
656
+ }
657
+
658
+ /**
659
+ * Calculate the product bulk discount
660
+ * @param $price
661
+ * @param $quantity
662
+ * @param $product
663
+ * @param $ajax_price
664
+ * @param $is_cart
665
+ * @return float|int
666
+ */
667
+ function calculateProductBulkDiscount($price, $quantity, $product, $price_display_condition, $is_cart)
668
+ {
669
+ if ($bulk_discount_data = $this->getBulkAdjustments()) {
670
+ if (!isset($bulk_discount_data->ranges) || !isset($bulk_discount_data->operator) || empty($bulk_discount_data->ranges)) {
671
+ return 0;
672
+ }
673
+ return $this->getMatchedBulkDiscount($product, $price, $bulk_discount_data->operator, $bulk_discount_data->ranges, $quantity, $bulk_discount_data, $price_display_condition, $is_cart);
674
+ } else {
675
+ return 0;
676
+ }
677
+ }
678
+
679
+ /**
680
+ * get the matched bulk discount (& set discount) row's value
681
+ * @param $operator
682
+ * @param $ranges
683
+ * @param $quantity
684
+ * @param $bulk_discount_data
685
+ * @param $product
686
+ * @param boolean $ajax_price
687
+ * @param $price
688
+ * @param $is_cart
689
+ * @return float|int
690
+ */
691
+ function getMatchedBulkDiscount( $product, $price, $operator, $ranges, $quantity, $bulk_discount_data, $price_display_condition, $is_cart)
692
+ {
693
+ if (empty($ranges)) {
694
+ return 0;
695
+ }
696
+ $cart_items = self::$woocommerce_helper->getCart();
697
+ if($price_display_condition == "show_when_matched" && !$is_cart){
698
+ $quantity = 1;
699
+ }else if($price_display_condition == "show_after_matched" || $is_cart){
700
+ $quantity = 0;
701
+ }
702
+ switch ($operator) {
703
+ case 'product_cumulative':
704
+ $quantity += $this->getProductCumulativeDiscountQuantity($cart_items);
705
+ break;
706
+ case 'variation':
707
+ $quantity += $this->getProductVariationDiscountQuantity($product, $cart_items);
708
+ break;
709
+ default:
710
+ case 'product':
711
+ $product_id = self::$woocommerce_helper->getProductId($product);
712
+ if(!empty($cart_items)){
713
+ foreach ($cart_items as $cart_item){
714
+ $cart_item_product_id = self::$woocommerce_helper->getProductIdFromCartItem($cart_item);
715
+ if($cart_item_product_id == $product_id){
716
+ $quantity += isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
717
+ }
718
+ }
719
+ }
720
+ break;
721
+ }
722
+ if (empty($quantity)) {
723
+ return 0;
724
+ }
725
+ $matched_row = $this->getBulkDiscountFromRanges($ranges, $quantity);
726
+ if(is_object($matched_row)){
727
+ $type = (isset($matched_row->type) && !empty($matched_row->type)) ? $matched_row->type : false;
728
+ $value = (isset($matched_row->value) && !empty($matched_row->value)) ? $matched_row->value : 0;
729
+ if ($type && !empty($value)) {
730
+ return $this->calculator($matched_row->type, $price, $matched_row->value);
731
+ }
732
+ return 0;
733
+ }
734
+ return 0;
735
+ }
736
+
737
+ /**
738
+ * Get quantity based on Count adjustment
739
+ *
740
+ * @param $operator string
741
+ * @param $quantity integer
742
+ * @param $product object
743
+ * @param $is_cart boolean
744
+ *
745
+ * @return integer
746
+ * */
747
+ public function getQuantityBasedOnCountAdjustment($operator, $quantity, $product, $is_cart = true){
748
+ $cart_items = self::$woocommerce_helper->getCart();
749
+ switch ($operator) {
750
+ case 'product_cumulative':
751
+ $quantity = $this->getProductCumulativeDiscountQuantity($cart_items, $is_cart, $product, $quantity);
752
+ break;
753
+ case 'variation':
754
+ $quantity = $this->getProductVariationDiscountQuantity($product, $cart_items, $is_cart, $quantity);
755
+ break;
756
+ default:
757
+ case 'product':
758
+ break;
759
+ }
760
+
761
+ return $quantity;
762
+ }
763
+
764
+ function getCartItemQuantity($cart_item){
765
+ return apply_filters('advanced_woo_discount_rules_cart_item_quantity', $cart_item['quantity'], $cart_item, $this->rule);
766
+ }
767
+
768
+ /**
769
+ * get bulk/set product cumulative discount quantities
770
+ * @param $cart_items
771
+ * @return int
772
+ */
773
+ function getProductCumulativeDiscountQuantity($cart_items, $is_cart = true, $product = null, $current_product_quantity = 0)
774
+ {
775
+ $quantity = 0;
776
+ foreach ($cart_items as $cart_item) {
777
+ $include_cart_item = Helper::isCartItemConsideredForCalculation(true, $cart_item, "cumulative_count");
778
+ if($include_cart_item === true){
779
+ if ($this->isFilterPassed(isset($cart_item['data']) ? $cart_item['data'] : $cart_item)) {
780
+ if ($this->hasConditions()) {
781
+ if (!$this->isCartConditionsPassed($cart_items)) {
782
+ continue;
783
+ }
784
+ $quantity += $this->getCartItemQuantity($cart_item);
785
+ } else {
786
+ $quantity += $this->getCartItemQuantity($cart_item);
787
+ }
788
+ }
789
+ }
790
+ }
791
+ if(!$is_cart && !empty($product)){
792
+ if ($this->isFilterPassed($product)) {
793
+ if ($this->hasConditions()) {
794
+ if ($this->isCartConditionsPassed($cart_items)) {
795
+ $quantity += $current_product_quantity;
796
+ }
797
+
798
+ } else {
799
+ $quantity += $current_product_quantity;
800
+ }
801
+ }
802
+ }
803
+ return $quantity;
804
+ }
805
+
806
+ /**
807
+ * get bulk/set product variation discount quantities
808
+ * @param $product
809
+ * @param $cart_items
810
+ * @return int
811
+ */
812
+ function getProductVariationDiscountQuantity($product, $cart_items, $is_cart = true, $current_product_quantity = 0)
813
+ {
814
+ $quantity = 0;
815
+ $current_product_parent_id = self::$woocommerce_helper->getProductParentId($product);
816
+ if (!empty($current_product_parent_id)) {
817
+ foreach ($cart_items as $cart_item) {
818
+ $include_cart_item = Helper::isCartItemConsideredForCalculation(true, $cart_item, "product_variation_count");
819
+ if($include_cart_item === true){
820
+ $cart_item_parent_id = self::$woocommerce_helper->getProductParentId(isset($cart_item['data']) ? $cart_item['data'] : $cart_item);
821
+ if (!empty($cart_item_parent_id) && $cart_item_parent_id == $current_product_parent_id) {
822
+ $quantity += $this->getCartItemQuantity($cart_item);
823
+ }
824
+ }
825
+ }
826
+ } else {
827
+ $product_id = self::$woocommerce_helper->getProductId($product);
828
+ if(!empty($cart_items)){
829
+ foreach ($cart_items as $cart_item){
830
+ $cart_item_product_id = self::$woocommerce_helper->getProductIdFromCartItem($cart_item);
831
+ if($cart_item_product_id == $product_id){
832
+ $quantity += isset($cart_item['quantity']) ? $cart_item['quantity'] : 0;
833
+ }
834
+ }
835
+ }
836
+ }
837
+ if(!$is_cart){
838
+ $quantity += $current_product_quantity;
839
+ }
840
+ return $quantity;
841
+ }
842
+
843
+ /**
844
+ * Get the discount value for bulk ranges
845
+ * @param $ranges
846
+ * @param $quantity
847
+ * @return float|int
848
+ */
849
+ function getBulkDiscountFromRanges($ranges, $quantity)
850
+ {
851
+ foreach ($ranges as $range) {
852
+ if (isset($range->value) && !empty($range->value)) {
853
+ $from = intval(isset($range->from) ? $range->from : 0);
854
+ $to = intval(isset($range->to) ? $range->to : 0);
855
+ if (empty($to) && empty($from)) {
856
+ continue;
857
+ }
858
+ if (empty($to) && !empty($from)) {
859
+ if ($quantity >= $from) {
860
+ return $range;
861
+ }
862
+ } elseif (!empty($to) && !empty($from)) {
863
+ if ($quantity >= $from && $quantity <= $to) {
864
+ return $range;
865
+ }
866
+ } elseif (!empty($to) && empty($from)) {
867
+ if ($quantity <= $to) {
868
+ return $range;
869
+ }
870
+ }
871
+ }
872
+ }
873
+ return 0;
874
+ }
875
+
876
+ /**
877
+ * get the product adjustment details
878
+ * @return array|bool|mixed|object
879
+ */
880
+ function getProductAdjustments()
881
+ {
882
+ if ($this->hasProductDiscount()) {
883
+ return json_decode($this->rule->product_adjustments);
884
+ }
885
+ return false;
886
+ }
887
+
888
+ /**
889
+ * Calculator to calculate discount price from original price
890
+ * @param $type
891
+ * @param $original_value
892
+ * @param $value
893
+ * @return float|int
894
+ */
895
+ function calculator($type, $original_value, $value)
896
+ {
897
+ $discount = 0;
898
+ if (empty($value)) {
899
+ return $discount;
900
+ }
901
+ $original_value = floatval($original_value);
902
+ $value = floatval($value);
903
+ switch ($type) {
904
+ case 'fixed_price':
905
+ $discount = $original_value - $value;
906
+ break;
907
+ case 'percentage':
908
+ if (!empty($value)) {
909
+ $discount = $original_value * ($value / 100);
910
+ }
911
+ break;
912
+ default:
913
+ case 'flat':
914
+ $discount = $value;
915
+ break;
916
+ }
917
+ return $discount;
918
+ }
919
+
920
+ /**
921
+ * get the maximum discount sum
922
+ * @return int
923
+ */
924
+ function getMaxDiscountSum()
925
+ {
926
+ if (isset($this->rule->max_discount_sum)) {
927
+ if (!empty($this->rule->max_discount_sum)) {
928
+ return $this->rule->max_discount_sum;
929
+ }
930
+ }
931
+ return 0;
932
+ }
933
+
934
+ /**
935
+ * Check the cart has pass the conditions
936
+ * @param $cart
937
+ * @return bool
938
+ */
939
+ function isCartConditionsPassed($cart)
940
+ {
941
+ /*if (empty($cart)) {
942
+ //if cart is empty then return with false
943
+ return false;
944
+ }*/
945
+ $conditions_result = array();
946
+ if ($conditions = $this->getConditions()) {
947
+ if (empty($conditions)) {
948
+ //If the rule has no condition then return true
949
+ return true;
950
+ }
951
+ $condition_relationship = $this->getRelationship('condition', 'and');
952
+ $dont_check_condition = apply_filters('advanced_woo_discount_rules_check_condition', false, $cart, $this, $condition_relationship);
953
+ if($dont_check_condition){
954
+ return true;
955
+ }
956
+ foreach ($conditions as $condition) {
957
+ $type = isset($condition->type) ? $condition->type : NULL;
958
+ $options = isset($condition->options) ? $condition->options : array();
959
+ if (!empty($type) && !empty($options)) {
960
+ //if condition available, then check the cart against the condition
961
+ if (isset($this->available_conditions[$type]['object'])) {
962
+ $this->available_conditions[$type]['object']->rule = $this;
963
+ $is_condition_passed = $this->available_conditions[$type]['object']->check($cart, $options);
964
+ }elseif(!isset($this->available_conditions[$type]['object'])){
965
+ $object_not_available = apply_filters('advanced_woo_discount_rules_condition_object_not_available', false, $cart, $this, $condition_relationship);
966
+ if($object_not_available){
967
+ $is_condition_passed = apply_filters('advanced_woo_discount_rules_set_condition_status', false, $cart, $this, $condition_relationship);
968
+ }else{
969
+ continue;
970
+ }
971
+ } elseif (isset($this->available_conditions['cart_item_products_taxonomy']['object'])) {
972
+ $this->available_conditions['cart_item_products_taxonomy']['object']->rule = $this;
973
+ $is_condition_passed = $this->available_conditions['cart_item_products_taxonomy']['object']->check($cart, $options);
974
+ } else {
975
+ $is_condition_passed = false;
976
+ }
977
+ //if relationship is "and" and if current condition get fails, no need to check any other conditions provided by admin.just return rule condition failed
978
+ if (isset($is_condition_passed) && !$is_condition_passed && $condition_relationship == "and") {
979
+ return false;
980
+ }
981
+ //if relationship is "or" and if current condition get pass, no need to check any other conditions provided by admin.just return rule condition passed
982
+ if (isset($is_condition_passed) && $is_condition_passed && $condition_relationship == "or") {
983
+ return true;
984
+ }
985
+ //Check if any conditions fails
986
+ if (isset($is_condition_passed) && !$is_condition_passed) {
987
+ $conditions_result[] = false;
988
+ }
989
+ } else {
990
+ //return false when particular condition not available
991
+ return false;
992
+ }
993
+ }
994
+ }
995
+ if (in_array(false, $conditions_result)) {
996
+ return false;
997
+ }
998
+ return true;
999
+ }
1000
+
1001
+ /**
1002
+ * get the rule conditions
1003
+ * @return array|bool|mixed|object
1004
+ */
1005
+ function getConditions()
1006
+ {
1007
+ if ($this->hasConditions()) {
1008
+ return json_decode($this->rule->conditions);
1009
+ }
1010
+ return false;
1011
+ }
1012
+
1013
+ /**
1014
+ * get the rule languages
1015
+ * @return array|bool|mixed|object
1016
+ */
1017
+ function getLanguages()
1018
+ {
1019
+ if ($this->hasLanguages()) {
1020
+ return json_decode($this->rule->rule_language);
1021
+ }
1022
+ return array();
1023
+ }
1024
+
1025
+ /**
1026
+ * check the rule has conditions
1027
+ * @return bool
1028
+ */
1029
+ function hasConditions()
1030
+ {
1031
+ if (isset($this->rule->conditions)) {
1032
+ if (empty($this->rule->conditions) || $this->rule->conditions == '{}' || $this->rule->conditions == '[]') {
1033
+ return false;
1034
+ } else {
1035
+ return true;
1036
+ }
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ /**
1042
+ * check the rule has conditions
1043
+ * @return bool
1044
+ */
1045
+ function hasLanguages()
1046
+ {
1047
+ if (isset($this->rule->rule_language)) {
1048
+ if (empty($this->rule->rule_language) || $this->rule->rule_language == '{}' || $this->rule->rule_language == '[]') {
1049
+ return false;
1050
+ } else {
1051
+ return true;
1052
+ }
1053
+ }
1054
+ return false;
1055
+ }
1056
+
1057
+ /**
1058
+ * Calculate the cart discount
1059
+ * @param $cart_subtotal
1060
+ * @return array
1061
+ */
1062
+ function calculateCartDiscount($product_price)
1063
+ {
1064
+ $discounts = array();
1065
+ if (empty($product_price)) {
1066
+ return $discounts;
1067
+ }
1068
+ if ($adjustment = $this->getCartAdjustments()) {
1069
+ if (!empty($adjustment)) {
1070
+ $type = isset($adjustment->type) ? $adjustment->type : 'flat';
1071
+ $value = isset($adjustment->value) ? $adjustment->value : 0;
1072
+ if (in_array($type, array('flat', 'percentage'))) {
1073
+ if (!empty($value)) {
1074
+ $label = isset($adjustment->label) ? $adjustment->label : __('discount', WDR_TEXT_DOMAIN);
1075
+ $discounts[] = array(
1076
+ 'free_shipping' => 0,
1077
+ 'discount' => $value,
1078
+ 'discount_type' => $type,
1079
+ 'label' => $label,
1080
+ 'discount_fee' => $this->calculator($type, $product_price, $value),
1081
+ );
1082
+ }
1083
+ } elseif($type == 'flat_in_subtotal'){
1084
+ if (!empty($value)) {
1085
+ $label = isset($adjustment->label) ? $adjustment->label : __('discount', WDR_TEXT_DOMAIN);
1086
+ $discounts[] = array(
1087
+ 'free_shipping' => 0,
1088
+ 'discount' => $value,
1089
+ 'discount_type' => $type,
1090
+ 'label' => $label,
1091
+ 'discount_fee' => $value,
1092
+ );
1093
+ }
1094
+ }else {
1095
+ $discounts[] = array(
1096
+ 'free_shipping' => 1
1097
+ );
1098
+ }
1099
+ }
1100
+ }
1101
+ return $discounts;
1102
+ }
1103
+
1104
+ /**
1105
+ * get the product adjustment details
1106
+ * @return array|bool|mixed|object
1107
+ */
1108
+ function getCartAdjustments()
1109
+ {
1110
+ if ($this->hasCartDiscount()) {
1111
+ return json_decode($this->rule->cart_adjustments);
1112
+ }
1113
+ return false;
1114
+ }
1115
+
1116
+ /**
1117
+ * check the rule has cart discount
1118
+ * @return bool
1119
+ */
1120
+ function hasCartDiscount()
1121
+ {
1122
+ if (isset($this->rule->cart_adjustments)) {
1123
+ if (!empty($this->rule->cart_adjustments) && $this->rule->cart_adjustments != '{}' && $this->rule->cart_adjustments != '[]') {
1124
+ return true;
1125
+ }
1126
+ }
1127
+ return false;
1128
+ }
1129
+
1130
+ /**
1131
+ * save rule
1132
+ * @param $post
1133
+ * @return array|int|null
1134
+ */
1135
+ function save($post)
1136
+ {
1137
+ $rule_id = $this->getFromArray($post, 'edit_rule', NULL);
1138
+ $title = $this->getFromArray($post, 'title', esc_html__('Untitled Rule', WDR_TEXT_DOMAIN));
1139
+ $enabled = $this->getFromArray($post, 'enabled', '0');
1140
+ $exclusive = $this->getFromArray($post, 'exclusive', '0');
1141
+ $date_from = $this->getFromArray($post, 'date_from', NULL);
1142
+ $date_from = (isset($date_from) && !empty($date_from)) ? $this->formatDate($date_from, 'Y-m-d H:i:s', true) : NULL;
1143
+ $date_to = $this->getFromArray($post, 'date_to', NULL);
1144
+ $date_to = (isset($date_to) && !empty($date_to)) ? $this->formatDate($date_to, 'Y-m-d H:i:s', true) : NULL;
1145
+ $usage_limits = $this->getFromArray($post, 'usage_limits', '');
1146
+ $rule_filters = $this->getFromArray($post, 'filters', array());
1147
+ $rule_conditions = $this->getFromArray($post, 'conditions', array());
1148
+ $awdr_coupon_names = array();
1149
+ if (!empty($rule_conditions)) {
1150
+ foreach ($rule_conditions as $coupon_key => $coupon_conditions) {
1151
+ $type = (isset($coupon_conditions['type']) && !empty($coupon_conditions['type'])) ? $coupon_conditions['type'] : '';
1152
+ $operator = (isset($coupon_conditions['options']['operator']) && !empty($coupon_conditions['options']['operator'])) ? $coupon_conditions['options']['operator'] : '';
1153
+ $awdr_woo_coupon_name = (isset($coupon_conditions['options']['value']) && !empty($coupon_conditions['options']['value'])) ? $coupon_conditions['options']['value'] : '';
1154
+ $coupon_name = (isset($coupon_conditions['options']['custom_value']) && !empty($coupon_conditions['options']['custom_value'])) ? $coupon_conditions['options']['custom_value'] : '';
1155
+ if ($type == 'cart_coupon' && $operator == 'custom_coupon' && $coupon_name != '') {
1156
+ $coupon_name = trim($coupon_name);
1157
+ //$coupon_name = str_replace(' ', '', $coupon_name);
1158
+ $coupon_name = apply_filters('woocommerce_coupon_code', $coupon_name);
1159
+ if (Woocommerce::checkCouponAlreadyExistsInWooCommerce($coupon_name)) {
1160
+ return array(
1161
+ 'rule_id' => $rule_id,
1162
+ 'coupon_exists' => 'coupon already exists in woocommerce'
1163
+ );
1164
+ } else {
1165
+ $rule_conditions[$coupon_key]['options']['custom_value'] = $coupon_name;
1166
+ }
1167
+ $awdr_coupon_names = array_merge($awdr_coupon_names,array($coupon_name));
1168
+ }else if($type == 'cart_coupon'){
1169
+ if(!empty($awdr_woo_coupon_name)){
1170
+ $awdr_coupon_names = array_merge($awdr_coupon_names,$awdr_woo_coupon_name);
1171
+ }
1172
+ }
1173
+ }
1174
+ }
1175
+ $rule_additional = $this->getFromArray($post, 'additional', array());
1176
+ $product_adjustments = $this->getFromArray($post, 'product_adjustments', array());
1177
+ $cart_adjustments = $this->getFromArray($post, 'cart_adjustments', array());
1178
+ $bulk_adjustments = $this->getFromArray($post, 'bulk_adjustments', array());
1179
+ $set_adjustments = $this->getFromArray($post, 'set_adjustments', array());
1180
+ $buyx_getx_adjustments = $this->getFromArray($post, 'buyx_getx_adjustments', array());
1181
+ $buy_x_get_y_adjustments = $this->getFromArray($post, 'buyx_gety_adjustments', array());
1182
+ if(!empty($buy_x_get_y_adjustments)){
1183
+ foreach ($buy_x_get_y_adjustments['ranges'] as $key => $range){
1184
+ $buy_x_get_y_adjustments['ranges'][$key]['product_varients'] = array();
1185
+ $buy_x_get_y_adjustments['ranges'][$key]['product_variants_for_sale_badge'] = array();
1186
+ if(isset($range['products']) && !empty($range['products'])){
1187
+ foreach ($range['products'] as $product_id){
1188
+ $variants = $this->getVariantsOfProducts(array($product_id));
1189
+ if(!empty($variants)){
1190
+ $buy_x_get_y_adjustments['ranges'][$key]['products_variants'][$product_id] = $variants;
1191
+ }
1192
+ $parent_id = $this->getParentOfVariant(array($product_id));
1193
+ if(!empty($parent_id)){
1194
+ $buy_x_get_y_adjustments['ranges'][$key]['product_variants_for_sale_badge'][] = $parent_id;
1195
+ }
1196
+ }
1197
+ }
1198
+ }
1199
+ }
1200
+ $rule_language = $this->getFromArray($post, 'rule_language', array());
1201
+ $discount_badge = $this->getFromArray($post, 'discount_badge', array());
1202
+ $discount_type = $this->getFromArray($post, 'discount_type', NULL);
1203
+ if (isset($_POST['discount_badge'])) {
1204
+ $discount_badge_text = (isset($_POST['discount_badge']['badge_text'])) ? $_POST['discount_badge']['badge_text'] : '';
1205
+ if (!empty($discount_badge_text)) {
1206
+ $discount_badge_text = stripslashes($discount_badge_text);
1207
+ $discount_badge['badge_text'] = $discount_badge_text;
1208
+ }
1209
+ }
1210
+
1211
+ if(!empty($awdr_coupon_names)){
1212
+ $awdr_coupon_names = array_unique($awdr_coupon_names);
1213
+ }
1214
+ $arg = array(
1215
+ 'title' => (empty($title)) ? esc_html__('Untitled Rule', WDR_TEXT_DOMAIN) : $title,
1216
+ 'enabled' => $enabled,
1217
+ 'exclusive' => $exclusive,
1218
+ 'usage_limits' => $usage_limits,
1219
+ 'date_from' => $date_from,
1220
+ 'date_to' => $date_to,
1221
+ 'filters' => json_encode($rule_filters),
1222
+ 'conditions' => json_encode($rule_conditions),
1223
+ 'additional' => json_encode($rule_additional),
1224
+ 'product_adjustments' => json_encode($product_adjustments),
1225
+ 'cart_adjustments' => json_encode($cart_adjustments),
1226
+ 'buy_x_get_x_adjustments' => json_encode($buyx_getx_adjustments),
1227
+ 'buy_x_get_y_adjustments' => json_encode($buy_x_get_y_adjustments),
1228
+ 'bulk_adjustments' => json_encode($bulk_adjustments),
1229
+ 'rule_language' => json_encode($rule_language),
1230
+ 'set_adjustments' => json_encode($set_adjustments),
1231
+ 'advanced_discount_message' => json_encode($discount_badge),
1232
+ 'discount_type' => $discount_type,
1233
+ 'used_coupons' => json_encode($awdr_coupon_names),
1234
+ );
1235
+ $arg = apply_filters( 'advanced_woo_discount_rules_before_save_rule_column', $arg, $rule_id, $post);
1236
+ $column_format = array('%s', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');
1237
+ $rule_id = DBTable::saveRule($column_format, $arg, $rule_id);
1238
+ if($rule_id){
1239
+ OnSaleShortCode::updateOnsaleRebuildPageStatus($rule_id);
1240
+ do_action('advanced_woo_discount_rules_after_save_rule', $rule_id, $post, $arg);
1241
+ }
1242
+ return $rule_id;
1243
+
1244
+ }
1245
+
1246
+ /**
1247
+ * Get data from array
1248
+ * @param $array
1249
+ * @param $key
1250
+ * @param $default
1251
+ * @return array|mixed
1252
+ */
1253
+ function getFromArray($array, $key, $default)
1254
+ {
1255
+ if (!is_array($array)) {
1256
+ return $default;
1257
+ }
1258
+ if (isset($array[$key])) {
1259
+ if ($key == 'filters') {
1260
+ return $this->addAdditionalDataForFilters($array[$key]);
1261
+ } else if ($key == 'conditions') {
1262
+ return $this->addAdditionalDataForConditions($array[$key]);
1263
+ }
1264
+ return $array[$key];
1265
+ }
1266
+ return $default;
1267
+ }
1268
+
1269
+ /**
1270
+ * Format filters
1271
+ *
1272
+ * @param $array_filters array
1273
+ * @return array
1274
+ * */
1275
+ function addAdditionalDataForFilters($array_filters)
1276
+ {
1277
+ if (!empty($array_filters)) {
1278
+ foreach ($array_filters as $key => $array_filter) {
1279
+ if (isset($array_filter['type']) && isset($array_filter['value'])) {
1280
+ $array_filters[$key]['product_variants'] = array();
1281
+ if ($array_filter['type'] == 'products' && !empty($array_filter['value'])) {
1282
+ if (is_array($array_filter['value'])) {
1283
+ $variants = $this->getVariantsOfProducts($array_filter['value']);
1284
+ if(empty($variants)){
1285
+ $array_filters[$key]['product_variants_for_sale_badge'] = $this->getParentOfVariant($array_filter['value']);
1286
+ }
1287
+ $array_filters[$key]['product_variants'] = $variants;
1288
+ }
1289
+ }
1290
+ }
1291
+ }
1292
+ }
1293
+ return $array_filters;
1294
+ }
1295
+
1296
+ /**
1297
+ * Format filters
1298
+ *
1299
+ * @param $array_filters array
1300
+ * @return array
1301
+ * */
1302
+ function addAdditionalDataForConditions($array_filters)
1303
+ {
1304
+ if (!empty($array_filters)) {
1305
+ foreach ($array_filters as $key => $array_filter) {
1306
+ if (isset($array_filter['type']) && isset($array_filter['options'])) {
1307
+ if (in_array($array_filter['type'], array('cart_item_product_combination', 'cart_item_products', 'purchase_previous_orders_for_specific_product')) && !empty($array_filter['options'])) {
1308
+ $product_field_key = 'product';
1309
+ if ($array_filter['type'] == 'cart_item_products') {
1310
+ $product_field_key = 'value';
1311
+ } elseif ($array_filter['type'] == 'purchase_previous_orders_for_specific_product') {
1312
+ $product_field_key = 'products';
1313
+ }
1314
+ if (is_array($array_filter['options']) && isset($array_filter['options'][$product_field_key])) {
1315
+ $array_filters[$key]['options']['product_variants'] = array();
1316
+ if (is_array($array_filter['options'][$product_field_key]) && !empty($array_filter['options'][$product_field_key])) {
1317
+ $variants = $this->getVariantsOfProducts($array_filter['options'][$product_field_key]);
1318
+ $array_filters[$key]['options']['product_variants'] = $variants;
1319
+ }
1320
+ }
1321
+ }
1322
+ }
1323
+ }
1324
+ }
1325
+ return $array_filters;
1326
+ }
1327
+
1328
+ /**
1329
+ * Get variants of the products
1330
+ *
1331
+ * @param $product_ids array
1332
+ * @return array
1333
+ */
1334
+ function getVariantsOfProducts($product_ids)
1335
+ {
1336
+ $variants = array();
1337
+ if (!empty($product_ids)) {
1338
+ foreach ($product_ids as $product_id) {
1339
+ $product = Woocommerce::getProduct($product_id);
1340
+ if (method_exists($product, 'is_type')) {
1341
+ if ($product->is_type(array('variable', 'variable-subscription'))) {
1342
+ $additional_variants = Woocommerce::getProductChildren($product);
1343
+ if (!empty($additional_variants) && is_array($additional_variants)) {
1344
+ $variants = array_merge($variants, $additional_variants);
1345
+ }
1346
+ }
1347
+ }
1348
+ }
1349
+ }
1350
+ return $variants;
1351
+ }
1352
+
1353
+ /**
1354
+ * Get siblings of the variants
1355
+ *
1356
+ * @param $product_ids array
1357
+ * @return array
1358
+ */
1359
+ function getParentOfVariant($product_ids)
1360
+ {
1361
+ $variants = array();
1362
+ if (!empty($product_ids)) {
1363
+ foreach ($product_ids as $product_id) {
1364
+ $parent_id = Woocommerce::getProductParentId((int)$product_id);
1365
+ if(!empty($parent_id)) {
1366
+ $variants = array_merge($variants, array($parent_id));
1367
+ }
1368
+ }
1369
+ }
1370
+ if(!empty($variants)){
1371
+ $variants = array_unique($variants);
1372
+ }
1373
+ return $variants;
1374
+ }
1375
+
1376
+ /**
1377
+ * search rule by rulename
1378
+ * @param $name
1379
+ * @param $available_conditions
1380
+ * @return array|\stdClass
1381
+ */
1382
+ function searchRuleByName($name, $available_conditions)
1383
+ {
1384
+ $rule = DBTable::getRules(null, $name);
1385
+ if (empty($rule)) {
1386
+ echo "<script> alert('No Records Found!'); </script>";
1387
+ return $this->getRuleObject(DBTable::getRules(), $available_conditions);
1388
+ }
1389
+ return $this->getRuleObject($rule, $available_conditions);
1390
+ }
1391
+
1392
+ /**
1393
+ * Export all rules
1394
+ * @return array|\stdClass
1395
+ */
1396
+ function exportRuleByName($names)
1397
+ {
1398
+ return DBTable::getRules(null, null, $names);
1399
+ }
1400
+
1401
+ /**
1402
+ * Hide Discount blocks if values get empty
1403
+ * @param $discount_obj
1404
+ * @return int
1405
+ */
1406
+ function showHideDiscount($discount_obj)
1407
+ {
1408
+ $show_discount_block = 0;
1409
+ if (!empty($discount_obj)) {
1410
+ foreach ($discount_obj as $discount_object) {
1411
+ $show_discount_block = $discount_object->value;
1412
+ if (!empty($show_discount_block)) {
1413
+ return $show_discount_block;
1414
+ }
1415
+ }
1416
+ }
1417
+ return $show_discount_block;
1418
+ }
1419
+
1420
+ /**
1421
+ * get all custom coupons
1422
+ * @return array
1423
+ */
1424
+ function getAllDynamicCoupons()
1425
+ {
1426
+ $available_rules = DBTable::getRules();
1427
+ $custom_coupons = array();
1428
+ foreach ($available_rules as $rule) {
1429
+ if (isset($rule->conditions) && !empty($rule->conditions) && $rule->conditions != '{}' && $rule->conditions != '[]') {
1430
+ $conditions = json_decode($rule->conditions);
1431
+ foreach ($conditions as $condition) {
1432
+ $option_obj = (isset($condition->options) && !empty($condition->options) ? $condition->options : '');
1433
+ $type = (isset($condition->type) && !empty($condition->type) ? $condition->type : '');
1434
+ $operator = (isset($option_obj->operator) && !empty($option_obj->operator) ? $option_obj->operator : '');
1435
+ $custom_value = (isset($option_obj->custom_value) && !empty($option_obj->custom_value) ? $option_obj->custom_value : '');
1436
+ if ($type == 'cart_coupon' && $operator == 'custom_coupon' && $custom_value != '') {
1437
+ $custom_coupons[] = $custom_value;
1438
+ }
1439
+ }
1440
+ }
1441
+ }
1442
+ return $custom_coupons;
1443
+ }
1444
+
1445
+ /**
1446
+ * get all custom coupons
1447
+ * @return array
1448
+ */
1449
+ function getCouponsFromDiscountRules()
1450
+ {
1451
+ $available_rules = DBTable::getRules();
1452
+ $custom_coupons = array();
1453
+ $woo_coupons = array();
1454
+ if (!empty($available_rules)) {
1455
+ foreach ($available_rules as $rule) {
1456
+ if (isset($rule->conditions) && !empty($rule->conditions) && $rule->conditions != '{}' && $rule->conditions != '[]') {
1457
+ $conditions = json_decode($rule->conditions);
1458
+ foreach ($conditions as $condition) {
1459
+ $option_obj = (isset($condition->options) && !empty($condition->options) ? $condition->options : '');
1460
+ $type = (isset($condition->type) && !empty($condition->type) ? $condition->type : '');
1461
+ $operator = (isset($option_obj->operator) && !empty($option_obj->operator) ? $option_obj->operator : '');
1462
+ $custom_value = (isset($option_obj->custom_value) && !empty($option_obj->custom_value) ? $option_obj->custom_value : '');
1463
+ $value = (isset($option_obj->value) && !empty($option_obj->value) ? $option_obj->value : '');
1464
+ if ($type == 'cart_coupon' && $operator == 'custom_coupon' && !empty($custom_value)) {
1465
+ $custom_coupons[] = $custom_value;
1466
+ } elseif ($type == 'cart_coupon' && $operator != 'custom_coupon' && !empty($value)) {
1467
+ $woo_coupons[] = $value;
1468
+ }
1469
+ }
1470
+ }
1471
+ }
1472
+ }
1473
+ return array('custom_coupons' => $custom_coupons, 'woo_coupons' => $woo_coupons);
1474
+ }
1475
+
1476
+ /**
1477
+ * The rule valid status
1478
+ * @return bool|string
1479
+ */
1480
+ function getRuleVaildStatus()
1481
+ {
1482
+ $valid_rule = false;
1483
+ $current_time = current_time('timestamp');
1484
+ $rule_start_date = $this->getStartDate(true);
1485
+ $rule_end_date = $this->getEndDate(true);
1486
+ if (!is_null($rule_start_date) && $current_time < $rule_start_date) {
1487
+ $valid_rule = "in_future";
1488
+ } else if (!is_null($rule_end_date) && $current_time > $rule_end_date) {
1489
+ $valid_rule = "expired";
1490
+ }
1491
+ return $valid_rule;
1492
+ }
1493
+
1494
+ /**
1495
+ * check the rule has product discount
1496
+ * @return bool
1497
+ */
1498
+ function hasUsedCoupons()
1499
+ {
1500
+ if (isset($this->rule->used_coupons)) {
1501
+ if (!empty($this->rule->used_coupons) && $this->rule->used_coupons != '{}' && $this->rule->used_coupons != '[]') {
1502
+ return json_decode($this->rule->used_coupons);
1503
+ }
1504
+ }
1505
+ return false;
1506
+ }
1507
+ }
v2/App/Helpers/RuleForm.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ /**
8
+ * Helps to create a rule while migration/manually
9
+ * */
10
+ class RuleForm
11
+ {
12
+ protected $form = array();
13
+
14
+ /**
15
+ * Get form
16
+ * */
17
+ public function getForm(){
18
+ return $this->form;
19
+ }
20
+
21
+ public function __get( $key )
22
+ {
23
+ return $this->form[ $key ];
24
+ }
25
+
26
+ public function __set( $key, $value )
27
+ {
28
+ $this->form[ $key ] = $value;
29
+ }
30
+
31
+ /**
32
+ * reset
33
+ * */
34
+ public function reset(){
35
+ $this->form = array();
36
+ }
37
+
38
+ /**
39
+ * Set filter value
40
+ *
41
+ * @param $type string
42
+ * @param $method mixed
43
+ * @param $value mixed
44
+ * @param $additional_data array
45
+ * */
46
+ public function setFilter($type, $method = null, $value = array(), $additional_data = array()){
47
+ $filters = isset($this->form['filters'])? $this->form['filters']: array();
48
+ $filter['type'] = $type;
49
+ if($method !== null){
50
+ $filter['method'] = $method;
51
+ }
52
+ if(!empty($value)){
53
+ $filter['value'] = $value;
54
+ }
55
+ if(!empty($additional_data)){
56
+ foreach ($additional_data as $key => $values){
57
+ $filter[$key] = $values;
58
+ }
59
+ }
60
+ $filters[] = $filter;
61
+ $this->form['filters'] = $filters;
62
+ }
63
+
64
+ /**
65
+ * Set cumulative option
66
+ * @param $type string
67
+ * */
68
+ public function setCumulativeOption($type = 'product_cumulative'){
69
+ if(isset($this->form['discount_type'])){
70
+ $discount_type = $this->form['discount_type'];
71
+ $field_name = '';
72
+ if($discount_type == 'wdr_bulk_discount'){
73
+ $field_name = 'bulk_adjustments';
74
+ } elseif ($discount_type == 'wdr_set_discount'){
75
+ $field_name = 'set_adjustments';
76
+ } elseif ($discount_type == 'wdr_buy_x_get_y_discount'){
77
+ $field_name = 'buyx_gety_adjustments';
78
+ }
79
+ if($field_name != ''){
80
+ $bulk_adjustments = isset($this->form[$field_name])? $this->form[$field_name]: array();
81
+ $bulk_adjustments['operator'] = $type;
82
+ $this->form[$field_name] = $bulk_adjustments;
83
+ }
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Set buy x get y option
89
+ * @param $type string
90
+ * */
91
+ public function setBuyXGetYOption($type = 'bxgy_product', $mode = 'auto_add'){
92
+ $adjustments = isset($this->form['buyx_gety_adjustments'])? $this->form['buyx_gety_adjustments']: array();
93
+ $adjustments['type'] = $type;
94
+ $adjustments['mode'] = $mode;
95
+ $this->form['buyx_gety_adjustments'] = $adjustments;
96
+ }
97
+
98
+ /**
99
+ * Set bulk range
100
+ * @param $from int
101
+ * @param $to int
102
+ * @param $value mixed
103
+ * @param $type string
104
+ * @param $label string
105
+ * */
106
+ public function setBulkRange($from, $to, $value, $type = 'percentage', $label = ''){
107
+ $bulk_adjustments = isset($this->form['bulk_adjustments'])? $this->form['bulk_adjustments']: array();
108
+ $bulk_adjustments_ranges = isset($bulk_adjustments['ranges'])? $bulk_adjustments['ranges']: array();
109
+ $bulk_adjustments_ranges[] = array(
110
+ "from" => $from,
111
+ "to" => $to,
112
+ "type" => $type,
113
+ "value" => $value,
114
+ "label" => $label,
115
+ );
116
+ $bulk_adjustments['ranges'] = $bulk_adjustments_ranges;
117
+ $this->form['bulk_adjustments'] = $bulk_adjustments;
118
+ }
119
+
120
+ public function setProductAdjustment($type, $value, $apply_as_cart_rule = ''){
121
+ $this->form['product_adjustments'] = array(
122
+ "percentage" => $type,
123
+ "value" => $value,
124
+ "apply_as_cart_rule" => $apply_as_cart_rule,
125
+ );
126
+ }
127
+
128
+ public function setSetRange($from, $value, $type = 'fixed_set_price', $label = ''){
129
+ $adjustments = isset($this->form['set_adjustments'])? $this->form['set_adjustments']: array();
130
+ $adjustments_ranges = isset($adjustments['ranges'])? $adjustments['ranges']: array();
131
+ $adjustments_ranges[] = array(
132
+ "from" => $from,
133
+ "type" => $type,
134
+ "value" => $value,
135
+ "label" => $label,
136
+ );
137
+ $adjustments['ranges'] = $adjustments_ranges;
138
+ $this->form['set_adjustments'] = $adjustments;
139
+ }
140
+
141
+ public function setBuyXGetXRange($from, $free_qty, $to = '', $type = 'free_product', $value = '', $recursive = 0){
142
+ $adjustments = isset($this->form['buyx_getx_adjustments'])? $this->form['buyx_getx_adjustments']: array();
143
+ $adjustments_ranges = isset($adjustments['ranges'])? $adjustments['ranges']: array();
144
+ $adjustments_ranges[] = array(
145
+ "from" => $from,
146
+ "to" => $to,
147
+ "free_type" => $type,
148
+ "free_qty" => $free_qty,
149
+ "free_value" => $value,
150
+ "recursive" => $recursive,
151
+ );
152
+ $adjustments['ranges'] = $adjustments_ranges;
153
+ $this->form['buyx_getx_adjustments'] = $adjustments;
154
+ }
155
+
156
+ public function setBuyXGetYRange($from, $free_qty, $additional_values = array(), $to = '', $type = 'free_product', $value = '', $recursive = 0){
157
+ $adjustments = isset($this->form['buyx_gety_adjustments'])? $this->form['buyx_gety_adjustments']: array();
158
+ $adjustments_ranges = isset($adjustments['ranges'])? $adjustments['ranges']: array();
159
+ $adjustments_range_value = array(
160
+ "from" => $from,
161
+ "to" => $to,
162
+ "free_type" => $type,
163
+ "free_qty" => $free_qty,
164
+ "free_value" => $value,
165
+ "recursive" => $recursive,
166
+ );
167
+ if(!empty($additional_values) && is_array($additional_values)){
168
+ $adjustments_range_value = array_merge($adjustments_range_value, $additional_values);
169
+ }
170
+ $adjustments_ranges[] = $adjustments_range_value;
171
+ $adjustments['ranges'] = $adjustments_ranges;
172
+ $this->form['buyx_gety_adjustments'] = $adjustments;
173
+ }
174
+
175
+ /**
176
+ * Set discount badge
177
+ * @param $badge_text string
178
+ * @param $display boolean
179
+ * @param $badge_color_picker string
180
+ * @param $badge_text_color_picker string
181
+ * */
182
+ public function setDiscountBadge($badge_text, $display = true, $badge_color_picker = '#6aaef6', $badge_text_color_picker = '#ffffff'){
183
+ $this->form['discount_badge'] = array(
184
+ 'display' => $display,
185
+ 'badge_color_picker' => $badge_color_picker,
186
+ 'badge_text_color_picker' => $badge_text_color_picker,
187
+ 'badge_text' => $badge_text,
188
+ );
189
+ }
190
+
191
+ /**
192
+ * Set conditions
193
+ * @param $type string
194
+ * @param $options array
195
+ * @param $additional_data array
196
+ * */
197
+ public function setConditions($type, $options = array(), $additional_data = array()){
198
+ $conditions = isset($this->form['conditions'])? $this->form['conditions']: array();
199
+ $condition['type'] = $type;
200
+ $condition['options'] = $options;
201
+ if(!empty($additional_data)){
202
+ foreach ($additional_data as $key => $values){
203
+ $condition[$key] = $values;
204
+ }
205
+ }
206
+ $conditions[] = $condition;
207
+ $this->form['conditions'] = $conditions;
208
+ }
209
+
210
+ /**
211
+ * Set cart adjustment
212
+ * @param $value mixed
213
+ * @param $type string
214
+ * @param $label string
215
+ * */
216
+ public function setCartAdjustment($value, $type = 'percentage', $label = ''){
217
+ $cart_adjustments = isset($this->form['cart_adjustments'])? $this->form['cart_adjustments']: array();
218
+ $cart_adjustments['type'] = $type;
219
+ $cart_adjustments['value'] = $value;
220
+ $cart_adjustments['label'] = $label;
221
+ $this->form['cart_adjustments'] = $cart_adjustments;
222
+ }
223
+ }
v2/App/Helpers/SurveyForm.php ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Wdr\App\Helpers;
3
+
4
+ if (!defined('ABSPATH')) exit;
5
+
6
+ class SurveyForm
7
+ {
8
+ public $plugin, $plugin_text_domain, $name;
9
+ protected $token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NjYzODMxODAsImV4cCI6NDI4MDI3MzE4MH0.RzNuhNyCu9oydkY9NRGFhFmQI0ALWBP0B1AmHub57XE";
10
+ protected $endpoint = "https://feedback.flycart.org/.netlify/functions/feedback";
11
+
12
+ /**
13
+ * init the survey
14
+ * @param $plugin
15
+ * @param $text_domain
16
+ * @param $plugin_name
17
+ * @return null
18
+ */
19
+ function init($plugin, $plugin_name, $text_domain)
20
+ {
21
+ $this->plugin = $plugin;
22
+ $this->name = $plugin_name;
23
+ $this->plugin_text_domain = $text_domain;
24
+ if ($this->isPluginPage() || !$this->isDevelopmentSite()) {
25
+ add_action('admin_print_scripts', array($this, 'js'), 20);
26
+ add_action('admin_print_scripts', array($this, 'css'));
27
+ add_action('admin_footer', array($this, 'modal'));
28
+ }
29
+ return NULL;
30
+ }
31
+
32
+ /**
33
+ * Print the required js
34
+ */
35
+ function js()
36
+ {
37
+ $display_name = '';
38
+ if (is_user_logged_in()) {
39
+ if (function_exists('wp_get_current_user')) {
40
+ $user = wp_get_current_user();
41
+ } elseif (function_exists('get_currentuserinfo')) {
42
+ $user = get_currentuserinfo();
43
+ }
44
+ if (!empty($user)) {
45
+ $display_name = isset($user->display_name) ? $user->display_name : '';
46
+ }
47
+ }
48
+ ?>
49
+ <script type="text/javascript">
50
+ jQuery(function ($) {
51
+ var $deactivateLink = $('#the-list').find('[data-slug="<?php echo $this->plugin; ?>"] span.deactivate a'),
52
+ $overlay = $('#plugin-deactivate-survey-<?php echo $this->plugin; ?>'),
53
+ $form = $overlay.find('form'),
54
+ formOpen = false;
55
+ // Plugin listing table deactivate link.
56
+ $deactivateLink.on('click', function (event) {
57
+ event.preventDefault();
58
+ $overlay.css('display', 'table');
59
+ formOpen = true;
60
+ $form.find('.<?php echo $this->plugin; ?>-deactivate-survey-option:first-of-type input[type=radio]').focus();
61
+ });
62
+ // Survey radio option selected.
63
+ $form.on('change', 'input[type=radio]', function (event) {
64
+ event.preventDefault();
65
+ $form.find('input[type=text], .error').hide();
66
+ $form.find('.<?php echo $this->plugin; ?>-deactivate-survey-option').removeClass('selected');
67
+ $(this).closest('.<?php echo $this->plugin; ?>-deactivate-survey-option').addClass('selected').find('input[type=text]').show();
68
+ });
69
+ // Survey Skip & Deactivate.
70
+ $form.on('click', '.<?php echo $this->plugin; ?>-deactivate-survey-deactivate', function (event) {
71
+ event.preventDefault();
72
+ location.href = $deactivateLink.attr('href');
73
+ });
74
+ // close button
75
+ $form.on('click', '.<?php echo $this->plugin; ?>-deactivate-survey-close', function (event) {
76
+ event.preventDefault();
77
+ $overlay.css('display', 'none');
78
+ formOpen = false;
79
+ });
80
+ // Survey submit.
81
+ $form.submit(function (event) {
82
+ event.preventDefault();
83
+ if (!$form.find('input[type=radio]:checked').val()) {
84
+ $form.find('.<?php echo $this->plugin; ?>-deactivate-survey-footer').prepend('<span class="error"><?php echo esc_js(__('Please select an option', $this->plugin_text_domain)); ?></span>');
85
+ return;
86
+ }
87
+ $form.find('.<?php echo $this->plugin; ?>-deactivate-survey-submit').html('<?php echo esc_js(__('Sending Feedback', $this->plugin_text_domain)); ?>').attr("disabled", true).removeClass('button-primary');
88
+ var reason = $form.find('.selected .<?php echo $this->plugin; ?>-deactivate-survey-option-reason').val();
89
+ if (reason === "Other") {
90
+ reason = $form.find('.selected input[type=text]').val();
91
+ }
92
+ var request_data = {
93
+ subject: "Discount Rules for WooCommerce plugin deactivation survey form!",
94
+ message: reason,
95
+ url: '<?php echo esc_url(home_url()); ?>',
96
+ name: '<?php echo $display_name; ?>',
97
+ code: $form.find('.selected input[type=radio]').val(),
98
+ token: "<?php echo $this->token ?>"
99
+ };
100
+ var submitSurvey = $.ajax(
101
+ {
102
+
103
+ url: "<?php echo $this->endpoint; ?>",
104
+ type: "POST",
105
+ data: JSON.stringify(request_data),
106
+ dataType: 'json',
107
+ async: false,
108
+ success: function (msg) {
109
+ location.href = $deactivateLink.attr('href');
110
+ },
111
+ error: function (msg) {
112
+ location.href = $deactivateLink.attr('href');
113
+ }
114
+ }
115
+ )
116
+ });
117
+
118
+ // Exit key closes survey when open.
119
+ $(document).keyup(function (event) {
120
+ if (27 === event.keyCode && formOpen) {
121
+ $overlay.hide();
122
+ formOpen = false;
123
+ $deactivateLink.focus();
124
+ }
125
+ });
126
+ });
127
+ </script>
128
+ <?php
129
+ }
130
+
131
+ /**
132
+ * CSS required for survey form
133
+ */
134
+ function css()
135
+ {
136
+ ?>
137
+ <style type="text/css">
138
+ .<?php echo $this->plugin; ?>-deactivate-survey-modal {
139
+ display: none;
140
+ table-layout: fixed;
141
+ position: fixed;
142
+ z-index: 9999;
143
+ width: 100%;
144
+ height: 100%;
145
+ text-align: center;
146
+ font-size: 14px;
147
+ top: 0;
148
+ left: 0;
149
+ background: rgba(0, 0, 0, 0.8);
150
+ }
151
+
152
+ .<?php echo $this->plugin; ?>-deactivate-survey-wrap {
153
+ display: table-cell;
154
+ vertical-align: middle;
155
+ }
156
+
157
+ .<?php echo $this->plugin; ?>-deactivate-survey {
158
+ background-color: #fff;
159
+ max-width: 550px;
160
+ margin: 0 auto;
161
+ padding: 30px;
162
+ text-align: left;
163
+ }
164
+
165
+ .<?php echo $this->plugin; ?>-deactivate-survey .error {
166
+ display: block;
167
+ color: red;
168
+ margin: 0 0 10px 0;
169
+ }
170
+
171
+ .<?php echo $this->plugin; ?>-deactivate-survey-header {
172
+ display: block;
173
+ font-size: 18px;
174
+ font-weight: 700;
175
+ text-transform: uppercase;
176
+ border-bottom: 1px solid #ddd;
177
+ padding: 0 0 18px 0;
178
+ margin: 0 0 18px 0;
179
+ position: relative;
180
+ }
181
+
182
+ .<?php echo $this->plugin; ?>-deactivate-survey-title {
183
+ text-align: left;
184
+ }
185
+
186
+ .<?php echo $this->plugin; ?>-deactivate-survey-close {
187
+ text-align: right;
188
+ position: absolute;
189
+ right: 0px;
190
+ font-size: 24px;
191
+ cursor: pointer;
192
+ }
193
+
194
+ .<?php echo $this->plugin; ?>-deactivate-survey-title span {
195
+ color: #999;
196
+ margin-right: 10px;
197
+ }
198
+
199
+ .<?php echo $this->plugin; ?>-deactivate-survey-desc {
200
+ display: block;
201
+ font-weight: 600;
202
+ margin: 0 0 18px 0;
203
+ }
204
+
205
+ .<?php echo $this->plugin; ?>-deactivate-survey-option {
206
+ margin: 0 0 10px 0;
207
+ }
208
+
209
+ .<?php echo $this->plugin; ?>-deactivate-survey-option-input {
210
+ margin-right: 10px !important;
211
+ }
212
+
213
+ .<?php echo $this->plugin; ?>-deactivate-survey-option-details {
214
+ display: none;
215
+ width: 90%;
216
+ margin: 10px 0 0 30px;
217
+ }
218
+
219
+ .<?php echo $this->plugin; ?>-deactivate-survey-footer {
220
+ margin-top: 18px;
221
+ }
222
+
223
+ .<?php echo $this->plugin; ?>-deactivate-survey-deactivate {
224
+ float: right;
225
+ font-size: 13px;
226
+ color: #ccc;
227
+ text-decoration: none;
228
+ padding-top: 7px;
229
+ }
230
+ </style>
231
+ <?php
232
+ }
233
+
234
+ /**
235
+ * Modal window showing survey
236
+ */
237
+ function modal()
238
+ {
239
+ $options = array(
240
+ 1 => array(
241
+ 'title' => esc_html__('Upgrading to PRO.', $this->plugin_text_domain),
242
+ 'reason' => 'Upgrading to PRO.'
243
+ ),
244
+ 2 => array(
245
+ 'title' => esc_html__('I am switching to a different discount plugin.', $this->plugin_text_domain),
246
+ 'reason' => 'I am switching to a different discount plugin.'
247
+ ),
248
+ 3 => array(
249
+ 'title' => esc_html__('I could not get my discount rule to work.', $this->plugin_text_domain),
250
+ 'reason' => 'I could not get my discount rule to work.'
251
+ ),
252
+ 4 => array(
253
+ 'title' => esc_html__('It does not meet my discount requirements.', $this->plugin_text_domain),
254
+ 'reason' => 'It does not meet my discount requirements.'
255
+ ),
256
+ 5 => array(
257
+ 'title' => esc_html__('Plugin is complex.', $this->plugin_text_domain),
258
+ 'reason' => 'Plugin is complex.'
259
+ ),
260
+ 6 => array(
261
+ 'title' => esc_html__('I\'m trying to troubleshoot the plugin.', $this->plugin_text_domain),
262
+ 'reason' => 'I\'m trying to troubleshoot the plugin.'
263
+ ),
264
+ 7 => array(
265
+ 'title' => esc_html__('I was instructed to deactivate by Flycart Support.', $this->plugin_text_domain),
266
+ 'reason' => 'I was instructed to deactivate by Flycart Support.'
267
+ ),
268
+ 8 => array(
269
+ 'title' => esc_html__('I no longer use this plugin.', $this->plugin_text_domain),
270
+ 'reason' => 'I no longer use this plugin.'
271
+ ),
272
+ 9 => array(
273
+ 'title' => esc_html__('It\'s a temporary deactivation.', $this->plugin_text_domain),
274
+ 'reason' => 'It\'s a temporary deactivation.'
275
+ ),
276
+ 10 => array(
277
+ 'title' => esc_html__('Other', $this->plugin_text_domain),
278
+ 'reason' => 'Other',
279
+ 'details' => esc_html__('Please share the reason', $this->plugin_text_domain),
280
+ ),
281
+ );
282
+ ?>
283
+ <div class="<?php echo $this->plugin; ?>-deactivate-survey-modal"
284
+ id="plugin-deactivate-survey-<?php echo $this->plugin; ?>">
285
+ <div class="<?php echo $this->plugin; ?>-deactivate-survey-wrap">
286
+ <form class="<?php echo $this->plugin; ?>-deactivate-survey" method="post">
287
+ <span class="<?php echo $this->plugin; ?>-deactivate-survey-header">
288
+ <span class="dashicons dashicons-testimonial"></span>
289
+ <?php echo ' ' . esc_html__('Quick Feedback', $this->plugin_text_domain); ?>
290
+ <span title="<?php esc_attr_e('Close', $this->plugin_text_domain); ?> "
291
+ class="<?php echo $this->plugin; ?>-deactivate-survey-close">✕</span>
292
+ </span>
293
+
294
+ <span class="<?php echo $this->plugin; ?>-deactivate-survey-desc">
295
+ <?php
296
+ printf(
297
+ /* translators: %s - plugin name. */
298
+ esc_html__('If you have a moment, please share why you are deactivating %s:', $this->plugin_text_domain),
299
+ esc_html__('Discount Rules for WooCommerce', $this->plugin_text_domain)
300
+ );
301
+ ?>
302
+ </span>
303
+ <div class="<?php echo $this->plugin; ?>-deactivate-survey-options">
304
+ <?php foreach ($options as $id => $option) : ?>
305
+ <div class="<?php echo $this->plugin; ?>-deactivate-survey-option">
306
+ <label for="<?php echo $this->plugin; ?>-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>"
307
+ class="<?php echo $this->plugin; ?>-deactivate-survey-option-label">
308
+ <input id="<?php echo $this->plugin; ?>-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>"
309
+ class="<?php echo $this->plugin; ?>-deactivate-survey-option-input"
310
+ type="radio"
311
+ name="code" value="<?php echo $id; ?>"/>
312
+ <span class="<?php echo $this->plugin; ?>-deactivate-survey-option-title"><?php echo $option['title']; ?></span>
313
+ <input class="<?php echo $this->plugin; ?>-deactivate-survey-option-reason"
314
+ type="hidden"
315
+ value="<?php echo $option['reason']; ?>"/>
316
+ </label>
317
+ <?php if (!empty($option['details'])) : ?>
318
+ <input class="<?php echo $this->plugin; ?>-deactivate-survey-option-details"
319
+ type="text"
320
+ placeholder="<?php echo $option['details']; ?>"/>
321
+ <?php endif; ?>
322
+ </div>
323
+ <?php endforeach; ?>
324
+ </div>
325
+ <div class="<?php echo $this->plugin; ?>-deactivate-survey-footer">
326
+ <button type="submit"
327
+ class="<?php echo $this->plugin; ?>-deactivate-survey-submit button button-primary button-large"><?php echo esc_html__('Submit & Deactivate', $this->plugin_text_domain); ?></button>
328
+ <a href="#"
329
+ class="<?php echo $this->plugin; ?>-deactivate-survey-deactivate"><?php echo esc_html__('Skip & Deactivate', $this->plugin_text_domain); ?></a>
330
+ </div>
331
+ </form>
332
+ </div>
333
+ </div>
334
+ <?php
335
+ }
336
+
337
+ /**
338
+ * Check this page is plugin page or not
339
+ * @return bool
340
+ */
341
+ function isPluginPage()
342
+ {
343
+ $screen = function_exists('get_current_screen') ? get_current_screen() : false;
344
+ if (empty($screen)) {
345
+ return false;
346
+ }
347
+ return (!empty($screen->id) && in_array($screen->id, array('plugins', 'plugins-network'), true));
348
+ }
349
+
350
+ /**
351
+ * Checks if current site is a development one.
352
+ * @return bool
353
+ */
354
+ public function isDevelopmentSite()
355
+ {
356
+ // If it is an AM dev site, return false, so we can see them on our dev sites.
357
+ if (defined('AWESOMEMOTIVE_DEV_MODE') && AWESOMEMOTIVE_DEV_MODE) {
358
+ return false;
359
+ }
360
+ $url = network_site_url('/');
361
+ $is_local_url = false;
362
+ // Trim it up
363
+ $url = strtolower(trim($url));
364
+ // Need to get the host...so let's add the scheme so we can use parse_url
365
+ if (false === strpos($url, 'http://') && false === strpos($url, 'https://')) {
366
+ $url = 'http://' . $url;
367
+ }
368
+ $url_parts = parse_url($url);
369
+ $host = !empty($url_parts['host']) ? $url_parts['host'] : false;
370
+ if (!empty($url) && !empty($host)) {
371
+ if (false !== ip2long($host)) {
372
+ if (!filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
373
+ $is_local_url = true;
374
+ }
375
+ } else if ('localhost' === $host) {
376
+ $is_local_url = true;
377
+ }
378
+ $tlds_to_check = array('.dev', '.local', ':8888');
379
+ foreach ($tlds_to_check as $tld) {
380
+ if (false !== strpos($host, $tld)) {
381
+ $is_local_url = true;
382
+ continue;
383
+ }
384
+ }
385
+ if (substr_count($host, '.') > 1) {
386
+ $subdomains_to_check = array('dev.', '*.staging.', 'beta.', 'test.');
387
+ foreach ($subdomains_to_check as $subdomain) {
388
+ $subdomain = str_replace('.', '(.)', $subdomain);
389
+ $subdomain = str_replace(array('*', '(.)'), '(.*)', $subdomain);
390
+ if (preg_match('/^(' . $subdomain . ')/', $host)) {
391
+ $is_local_url = true;
392
+ continue;
393
+ }
394
+ }
395
+ }
396
+ }
397
+ return $is_local_url;
398
+ }
399
+ }
v2/App/Helpers/Template.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
6
+
7
+ class Template
8
+ {
9
+ private $path, $data = array();
10
+
11
+ /**
12
+ * set the file path
13
+ * @param $path
14
+ * @return $this
15
+ */
16
+ public function setPath($path)
17
+ {
18
+ $this->path = $path;
19
+ return $this;
20
+ }
21
+
22
+ /**
23
+ * Set data for template
24
+ * @param $data
25
+ * @return $this
26
+ */
27
+ public function setData($data)
28
+ {
29
+ $this->data = $data;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * get the file path
35
+ * @return mixed
36
+ */
37
+ public function getPath()
38
+ {
39
+ return $this->path;
40
+ }
41
+
42
+ /**
43
+ * return the template contents
44
+ */
45
+ function render()
46
+ {
47
+ return $this->templateContents();
48
+ }
49
+
50
+ /**
51
+ * Show the template contents
52
+ */
53
+ function display()
54
+ {
55
+ echo $this->templateContents();
56
+ }
57
+
58
+ /**
59
+ * process template contents
60
+ */
61
+ function templateContents()
62
+ {
63
+ ob_start();
64
+ if (file_exists($this->getPath())) {
65
+ extract($this->data);
66
+ /*if(isset($condition_site_languages)){
67
+ echo '<pre>';print_r($condition_site_languages);echo'</pre>';
68
+ $render_saved_condition =false;
69
+ echo $this->getPath();
70
+ include $this->getPath();
71
+ die;
72
+ }*/
73
+ include $this->getPath();
74
+ }
75
+ return ob_get_clean();
76
+ }
77
+ }
v2/App/Helpers/Woocommerce.php ADDED
@@ -0,0 +1,1525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Helpers;
4
+
5
+ use WC_Order;
6
+ use WC_Order_Refund;
7
+ use WC_Product;
8
+ use Wdr\App\Controllers\ManageDiscount;
9
+ use Wdr\App\Router;
10
+ use WP_Post;
11
+
12
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
13
+
14
+ class Woocommerce
15
+ {
16
+ /**
17
+ * Check product type is found in product
18
+ * @param $product - Woocommerce product object
19
+ * @param $type - product types
20
+ * @return bool
21
+ */
22
+ static $custom_taxonomies;
23
+ static $checkout_post = null;
24
+
25
+ protected static $products = array();
26
+
27
+ static function productTypeIs($product, $type)
28
+ {
29
+ if (method_exists($product, 'is_type')) {
30
+ return $product->is_type($type);
31
+ }
32
+ return false;
33
+ }
34
+
35
+ /**
36
+ * Check the order has particular shipping method
37
+ * @param $order
38
+ * @param $method
39
+ * @return bool
40
+ */
41
+ static function orderHasShippingMethod($order, $method)
42
+ {
43
+ if (method_exists($order, 'has_shipping_method')) {
44
+ return $order->has_shipping_method($method);
45
+ }
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Check the order has particular shipping method
51
+ * @param $order
52
+ * @return bool
53
+ */
54
+ static function getOrderTotal($order)
55
+ {
56
+ if (method_exists($order, 'get_total')) {
57
+ return $order->get_total();
58
+ }
59
+ return 0;
60
+ }
61
+
62
+ /**
63
+ * get order object from order id
64
+ * @param $order_id
65
+ * @return array|bool|WC_Order|WC_Order_Refund
66
+ */
67
+ static function getOrder($order_id)
68
+ {
69
+ if (empty($order_id)) {
70
+ return array();
71
+ }
72
+ if (function_exists('wc_get_order')) {
73
+ return wc_get_order($order_id);
74
+ }
75
+ return array();
76
+ }
77
+
78
+ /**
79
+ * get the product ID
80
+ * @param $product - woocommerce product object
81
+ * @return null
82
+ */
83
+ static function getProductId($product)
84
+ {
85
+ if (method_exists($product, 'get_id')) {
86
+ return $product->get_id();
87
+ } elseif (isset($product->id)) {
88
+ $product_id = $product->id;
89
+ if (isset($product->variation_id)) {
90
+ $product_id = $product->variation_id;
91
+ }
92
+ return $product_id;
93
+ } else {
94
+ return NULL;
95
+ }
96
+ }
97
+
98
+ /**
99
+ * get product id from cart item id
100
+ * */
101
+ public static function getProductIdFromCartItem($cart_item){
102
+ $product_id = null;
103
+ if(isset($cart_item['product_id'])){
104
+ $product_id = $cart_item['product_id'];
105
+ if(isset($cart_item['variation_id']) && !empty($cart_item['variation_id'])){
106
+ $product_id = $cart_item['variation_id'];
107
+ }
108
+ } else if(isset($cart_item['data'])){
109
+ $product_id = self::getProductId($cart_item['data']);
110
+ }
111
+
112
+ return $product_id;
113
+ }
114
+
115
+ /**
116
+ * Get the product from product id
117
+ * @param $product_id
118
+ * @return bool|false|WC_Product|null
119
+ */
120
+ static function getProduct($product_id)
121
+ {
122
+ if(isset(self::$products[$product_id])){
123
+ return self::$products[$product_id];
124
+ } else if (function_exists('wc_get_product')) {
125
+ self::$products[$product_id] = apply_filters('advanced_woo_discount_rules_get_wc_product', wc_get_product($product_id), $product_id);
126
+
127
+ return self::$products[$product_id];
128
+ }
129
+ return false;
130
+ }
131
+
132
+ /**
133
+ * Get the product from Cart item data/product id
134
+ * @param $cart_item object
135
+ * @param $product_id int
136
+ * @return mixed
137
+ */
138
+ static function getProductFromCartItem($cart_item, $product_id = 0)
139
+ {
140
+ $product = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
141
+ if (!is_a($product, 'WC_Product')) {
142
+ $product = self::getProduct($product_id);
143
+ }
144
+ if (is_a($product, 'WC_Product')) {
145
+ return apply_filters('advanced_woo_discount_rules_get_product_from_cart_item', $product, $cart_item);
146
+ }
147
+ return false;
148
+ }
149
+
150
+ /**
151
+ * Get the sale price of the product
152
+ * @param $product
153
+ * @return bool
154
+ */
155
+ static function getProductSalePrice($product)
156
+ {
157
+ if (self::isProductInSale($product)) {
158
+ if (method_exists($product, 'get_sale_price')) {
159
+ $price = $product->get_sale_price();
160
+ return apply_filters('advanced_woo_discount_rules_get_sale_price', $price, $product);
161
+ }
162
+ return false;
163
+ }
164
+ return false;
165
+ }
166
+
167
+ /**
168
+ * Check the produt in sale
169
+ * @param $product
170
+ * @return bool
171
+ */
172
+ static function isProductInSale($product)
173
+ {
174
+ if (method_exists($product, 'is_on_sale') && method_exists($product, 'get_sale_price')) {
175
+ if($product->is_on_sale('')){
176
+ if($product->get_sale_price()){
177
+ return apply_filters('advanced_woo_discount_rules_is_on_sale', true, $product);
178
+ }else{
179
+ return apply_filters('advanced_woo_discount_rules_is_on_sale', false, $product);
180
+ }
181
+ }
182
+ }
183
+ return false;
184
+ }
185
+
186
+ /**
187
+ * Get the regular price of the product
188
+ * @param $product
189
+ * @return bool
190
+ */
191
+ static function getProductRegularPrice($product)
192
+ {
193
+ if (method_exists($product, 'get_regular_price')) {
194
+ $price = $product->get_regular_price();
195
+ return apply_filters('advanced_woo_discount_rules_get_regular_price', $price, $product);
196
+ }
197
+ return false;
198
+ }
199
+
200
+ /**
201
+ * Get the actual price of the product
202
+ * @param $product
203
+ * @return bool
204
+ */
205
+ static function getProductPrice($product)
206
+ {
207
+ if (method_exists($product, 'get_price')) {
208
+ $price = $product->get_price();
209
+ return apply_filters('advanced_woo_discount_rules_get_price', $price, $product);
210
+ }
211
+ return false;
212
+ }
213
+
214
+ /**
215
+ * Get the categories of the product
216
+ * @param $product
217
+ * @return array
218
+ */
219
+ static function getProductCategories($product)
220
+ {
221
+ $categories = array();
222
+ if (method_exists($product, 'get_category_ids')) {
223
+ if (self::productTypeIs($product, 'variation')) {
224
+ $parent_id = self::getProductParentId($product);
225
+ $product = self::getProduct($parent_id);
226
+ }
227
+ $categories = $product->get_category_ids();
228
+ }
229
+ return apply_filters('advanced_woo_discount_rules_get_product_categories', $categories, $product);
230
+
231
+ }
232
+
233
+ /**
234
+ * Get product tags
235
+ * @param $product
236
+ * @return array
237
+ */
238
+ static function getProductTags($product)
239
+ {
240
+ if (method_exists($product, 'get_tag_ids')) {
241
+ return $product->get_tag_ids();
242
+ }
243
+ return array();
244
+ }
245
+
246
+ /**
247
+ * Get product attributes
248
+ * @param $product
249
+ * @return array
250
+ */
251
+ static function getProductAttributes($product)
252
+ {
253
+ if (method_exists($product, 'get_attributes')) {
254
+ return $product->get_attributes();
255
+ }
256
+ return array();
257
+ }
258
+
259
+ /**
260
+ * Get product attributes
261
+ * @param $product
262
+ * @return array
263
+ */
264
+ static function getProductChildren($product)
265
+ {
266
+ if (method_exists($product, 'get_children')) {
267
+ return $product->get_children();
268
+ }
269
+ return array();
270
+ }
271
+
272
+ /**
273
+ * Get product SKU
274
+ * @param $product
275
+ * @return bool
276
+ */
277
+ static function getProductSku($product)
278
+ {
279
+ if (method_exists($product, 'get_sku')) {
280
+ return $product->get_sku();
281
+ }
282
+ return NULL;
283
+ }
284
+
285
+ /**
286
+ * Get product price suffix
287
+ * @param $product
288
+ * @param $price
289
+ * @param $discount_prices
290
+ * @return bool
291
+ */
292
+ static function getProductPriceSuffix($product, $price = '', $discount_prices = array())
293
+ {
294
+ if (method_exists($product, 'get_price_suffix')) {
295
+ return apply_filters('advanced_woo_discount_rules_price_suffix', $product->get_price_suffix($price), $product, $price, $discount_prices);
296
+ }
297
+ return NULL;
298
+ }
299
+
300
+ /**
301
+ * Get attribute Name
302
+ * @param $attribute
303
+ * @return array
304
+ */
305
+ static function getAttributeName($attribute)
306
+ {
307
+ if (method_exists($attribute, 'get_name')) {
308
+ return $attribute->get_name();
309
+ }
310
+ return NULL;
311
+ }
312
+
313
+ /**
314
+ * Get attribute Option
315
+ * @param $attribute
316
+ * @return array
317
+ */
318
+ static function getAttributeOption($attribute)
319
+ {
320
+ if (method_exists($attribute, 'get_options')) {
321
+ return $attribute->get_options();
322
+ }
323
+ return array();
324
+ }
325
+
326
+ /**
327
+ * Get product custom taxonomy
328
+ * @return array|null
329
+ */
330
+ static function getCustomProductTaxonomies()
331
+ {
332
+ if (!empty(self::$custom_taxonomies)) {
333
+ return self::$custom_taxonomies;
334
+ }
335
+ if (function_exists('get_taxonomies')) {
336
+ self::$custom_taxonomies = array_filter(get_taxonomies(array(
337
+ 'show_ui' => true,
338
+ 'show_in_menu' => true,
339
+ 'object_type' => array('product'),
340
+ ), 'objects'), function ($tax) {
341
+ return !in_array($tax->name, array('product_cat', 'product_tag'));
342
+ });
343
+ self::$custom_taxonomies = apply_filters('advanced_woo_discount_rules_get_custom_taxonomies', self::$custom_taxonomies);
344
+ }
345
+ return self::$custom_taxonomies;
346
+ }
347
+
348
+ /**
349
+ * Format the sale price
350
+ * @param $price1
351
+ * @param $price2
352
+ * @return string|null
353
+ */
354
+ static function formatSalePrice($price1, $price2)
355
+ {
356
+ if (function_exists('wc_format_sale_price')) {
357
+ return apply_filters('advanced_woo_discount_rules_format_sale_price', wc_format_sale_price($price1, $price2), $price1, $price2);
358
+ }
359
+ return NULL;
360
+ }
361
+
362
+ /**
363
+ * format the price //range
364
+ * @param $min_price
365
+ * @param $max_price
366
+ * @return string
367
+ */
368
+ static function formatPriceRange($min_price, $max_price)
369
+ {
370
+ if (function_exists('wc_format_price_range')) {
371
+ $html = wc_format_price_range($min_price, $max_price);
372
+ } else {
373
+ $html = self::formatPrice($min_price) . ' - ' . self::formatPrice($max_price);
374
+ }
375
+
376
+ return apply_filters('advanced_woo_discount_rules_format_sale_price_range', $html, $min_price, $max_price);
377
+ }
378
+
379
+ /**
380
+ * format the price
381
+ * @param $price
382
+ * @param $args
383
+ * @return string
384
+ */
385
+ static function formatPrice($price, $args = array())
386
+ {
387
+ if (function_exists('wc_price')) {
388
+ return wc_price($price, $args);
389
+ }
390
+ return $price;
391
+ }
392
+
393
+ /**
394
+ * format currency code
395
+ * @return string
396
+ */
397
+ static function get_currency_symbol($code = '')
398
+ {
399
+ if (function_exists('get_woocommerce_currency_symbol')) {
400
+ return get_woocommerce_currency_symbol($code);
401
+ }
402
+ return $code;
403
+ }
404
+
405
+ /**
406
+ * format given string to upper
407
+ * @param string $string String to format.
408
+ * @return string
409
+ */
410
+ static function formatStringToUpper($string)
411
+ {
412
+ if (function_exists('wc_strtoupper')) {
413
+ return wc_strtoupper($string);
414
+ } else{
415
+ return strtoupper($string);
416
+ }
417
+ }
418
+
419
+ /**
420
+ * format given string to lower case
421
+ * @param string $string String to format.
422
+ * @return string
423
+ */
424
+ static function formatStringToLower($string)
425
+ {
426
+ if (function_exists('wc_strtolower')) {
427
+ return wc_strtolower($string);
428
+ } else {
429
+ return strtolower($string);
430
+ }
431
+ }
432
+
433
+ /**
434
+ * get cart items
435
+ * @return array
436
+ */
437
+ static function getCart($recalculate_total = false)
438
+ {
439
+ if($recalculate_total){
440
+ self::reCalculateCartTotal();
441
+ }
442
+ $cart = array();
443
+ if (function_exists('WC')) {
444
+ if (method_exists(WC()->cart, 'get_cart')) {
445
+ $cart = WC()->cart->get_cart();
446
+ }
447
+ }
448
+ return apply_filters('advanced_woo_discount_rules_get_cart', $cart);
449
+ }
450
+
451
+ /**
452
+ * calculate totals
453
+ * @return array
454
+ */
455
+ static function calculateCartTotals()
456
+ {
457
+ if (function_exists('WC')) {
458
+ if (method_exists(WC()->cart, 'calculate_totals')) {
459
+ WC()->cart->calculate_totals();
460
+ }
461
+ }
462
+ }
463
+
464
+ static function reCalculateCartTotal(){
465
+ remove_action('woocommerce_before_calculate_totals', array(Router::$manage_discount, 'applyCartProductDiscount'), 1000);
466
+ self::calculateCartTotals();
467
+ add_action('woocommerce_before_calculate_totals', array(Router::$manage_discount, 'applyCartProductDiscount'), 1000);
468
+ }
469
+
470
+ /**
471
+ * get shipping packages
472
+ * @return array
473
+ */
474
+ static function get_shipping_packages()
475
+ {
476
+ if (function_exists('WC')) {
477
+ if (method_exists(WC()->cart, 'get_shipping_packages')) {
478
+ return WC()->cart->get_shipping_packages();
479
+ }
480
+ }
481
+ return null;
482
+ }
483
+
484
+ static function round($value){
485
+ if(function_exists('wc_get_price_decimals')){
486
+ return round( $value, wc_get_price_decimals() );
487
+ } else {
488
+ return round( $value, get_option( 'woocommerce_price_num_decimals', 2 ) );
489
+ }
490
+ }
491
+
492
+ /**
493
+ * Add cart item
494
+ *
495
+ * @access public
496
+ * @param int $product_id
497
+ * @param int $quantity
498
+ * @param int $variation_id
499
+ * @param array $variation
500
+ * @param array $cart_item_data
501
+ * @return boolean
502
+ */
503
+ public static function add_to_cart($product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array())
504
+ {
505
+ if (function_exists('WC')) {
506
+ if (method_exists(WC()->cart, 'add_to_cart')) {
507
+ return WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation, $cart_item_data);
508
+ }
509
+ }
510
+
511
+ return false;
512
+ }
513
+
514
+ /**
515
+ * set quantity
516
+ *
517
+ * @access public
518
+ * @param string $cart_item_key
519
+ * @param int $quantity
520
+ * @param boolean $refresh_totals
521
+ * @return boolean
522
+ */
523
+ public static function set_quantity( $cart_item_key, $quantity = 1, $refresh_totals = true ){
524
+ if (function_exists('WC')) {
525
+ if (method_exists(WC()->cart, 'set_quantity')) {
526
+ return WC()->cart->set_quantity($cart_item_key, $quantity, $refresh_totals);
527
+ }
528
+ }
529
+
530
+ return false;
531
+ }
532
+
533
+ /**
534
+ * Remove cart item
535
+ *
536
+ * @access public
537
+ * @return boolean
538
+ */
539
+ public static function remove_cart_item($_cart_item_key)
540
+ {
541
+ if (function_exists('WC')) {
542
+ if (method_exists(WC()->cart, 'remove_cart_item')) {
543
+ return WC()->cart->remove_cart_item( $_cart_item_key );
544
+ }
545
+ }
546
+
547
+ return false;
548
+ }
549
+
550
+ /**
551
+ * Remove coupon from cart
552
+ *
553
+ * @access public
554
+ * @param string $code
555
+ * @return boolean
556
+ */
557
+ public static function remove_coupon($code)
558
+ {
559
+ if (function_exists('WC')) {
560
+ if (method_exists(WC()->cart, 'remove_coupon')) {
561
+ return WC()->cart->remove_coupon( $code );
562
+ }
563
+ }
564
+
565
+ return false;
566
+ }
567
+
568
+ /**
569
+ * Add notice
570
+ *
571
+ * @access public
572
+ * @param $message string
573
+ * @param $type string
574
+ * @param $data array
575
+ */
576
+ public static function wc_add_notice($message, $type = 'success', $data = array())
577
+ {
578
+ if (function_exists('wc_add_notice')) {
579
+ wc_add_notice( $message, $type. $data);
580
+ }
581
+ }
582
+
583
+ /**
584
+ * Remove specific notice
585
+ *
586
+ * @access public
587
+ * @param $remove_message string
588
+ * @param $type string
589
+ */
590
+ public static function removeSpecificNoticeFromSession($remove_message, $type = 'success')
591
+ {
592
+ $all_notices = self::getSession('wc_notices', array());
593
+ if(!empty($all_notices)){
594
+ foreach ($all_notices as $key => $messages){
595
+ if($key == $type){
596
+ if(!empty($messages)){
597
+ foreach ($messages as $msg_key => $message){
598
+ if(isset($message['notice'])){
599
+ if($message['notice'] == $remove_message){
600
+ unset($all_notices[$key][$msg_key]);
601
+ break;
602
+ }
603
+ }
604
+ }
605
+ }
606
+ }
607
+ }
608
+ }
609
+
610
+ self::setSession('wc_notices', $all_notices);
611
+ }
612
+
613
+
614
+ /**
615
+ * get the parent id of the particular product
616
+ * @param $product
617
+ * @return int
618
+ */
619
+ static function getProductParentId($product)
620
+ {
621
+ $parent_id = 0;
622
+ if (is_int($product)) {
623
+ $product = self::getProduct($product);
624
+ }
625
+ if (method_exists($product, 'get_parent_id')) {
626
+ $parent_id = $product->get_parent_id();
627
+ }
628
+ return apply_filters('advanced_woo_discount_rules_get_product_parent_id', $parent_id, $product);
629
+ }
630
+
631
+ /**
632
+ * get cart items
633
+ * @param $cart
634
+ * @return array
635
+ */
636
+ static function getCartItems($cart)
637
+ {
638
+ $cart_items = array();
639
+ if (method_exists($cart, 'get_cart_contents')) {
640
+ $cart_items = $cart->get_cart_contents();
641
+ }
642
+ return apply_filters('advanced_woo_discount_rules_get_cart_items', $cart_items, $cart);
643
+ }
644
+
645
+ /**
646
+ * get cart items
647
+ * @return array
648
+ */
649
+ static function getCartSubtotal()
650
+ {
651
+ if (function_exists('WC')) {
652
+ $subtotal = 0;
653
+ if (method_exists(WC()->cart, 'get_subtotal')) {
654
+ $subtotal = WC()->cart->get_subtotal();
655
+ } elseif (isset(WC()->cart->subtotal)) {
656
+ $subtotal = WC()->cart->subtotal;
657
+ }
658
+ return apply_filters('advanced_woo_discount_rules_get_cart_subtotal', $subtotal);
659
+ }
660
+
661
+ return 0;
662
+ }
663
+
664
+ /**
665
+ * get line item subtotal
666
+ * @return array
667
+ */
668
+ static function getCartLineItemSubtotal($cart_item)
669
+ {
670
+ $tax_display_type = get_option('woocommerce_tax_display_cart');
671
+ if ($tax_display_type === 'excl') {
672
+ $line_subtotal = (isset($cart_item['line_subtotal'])) ? $cart_item['line_subtotal'] : 0;
673
+ } else {
674
+ $line_subtotal = (isset($cart_item['line_subtotal'])) ? $cart_item['line_subtotal'] : 0;
675
+ $line_subtotal_tax = (isset($cart_item['line_subtotal_tax'])) ? $cart_item['line_subtotal_tax'] : 0;
676
+ $line_subtotal = $line_subtotal+$line_subtotal_tax;
677
+ }
678
+
679
+ return $line_subtotal;
680
+ }
681
+
682
+ /**
683
+ * Add cart fee
684
+ * @param $cart
685
+ * @param $name
686
+ * @param $fee
687
+ * @return array
688
+ */
689
+ static function addCartFee($cart, $name, $fee)
690
+ {
691
+ if (method_exists($cart, 'add_fee')) {
692
+ return $cart->add_fee($name, $fee);
693
+ }
694
+ return array();
695
+ }
696
+
697
+ /**
698
+ * get coupon code from coupon object
699
+ * @param $coupon
700
+ * @return null
701
+ */
702
+ static function getCouponCode($coupon)
703
+ {
704
+ if (method_exists($coupon, 'get_code')) {
705
+ return $coupon->get_code();
706
+ }
707
+ return NULL;
708
+ }
709
+
710
+ /**
711
+ * get coupon code from coupon object
712
+ * @return null
713
+ */
714
+ static function getAppliedCoupons()
715
+ {
716
+ if (function_exists('WC')) {
717
+ if (method_exists(WC()->cart, 'get_applied_coupons')) {
718
+ return WC()->cart->get_applied_coupons();
719
+ }
720
+ }
721
+ return NULL;
722
+ }
723
+
724
+ /**
725
+ * Add cart fee
726
+ * @param $cart
727
+ * @param $code
728
+ * @return array
729
+ */
730
+ static function addCouponDiscount($cart, $code)
731
+ {
732
+ if (method_exists($cart, 'add_discount')) {
733
+ return $cart->add_discount($code);
734
+ }
735
+ return array();
736
+ }
737
+
738
+ /**
739
+ * Check the coupon already found in cart
740
+ * @param $cart
741
+ * @param $code
742
+ * @return array
743
+ */
744
+ static function hasCouponInCart($cart, $code)
745
+ {
746
+ if (method_exists($cart, 'has_discount')) {
747
+ return $cart->has_discount($code);
748
+ }
749
+ return array();
750
+ }
751
+
752
+ /**
753
+ * Set the cart item price
754
+ * @param $cart_item_object
755
+ * @param $price
756
+ * @return mixed
757
+ */
758
+ static function setCartProductPrice($cart_item_object, $price)
759
+ {
760
+ if (method_exists($cart_item_object, 'set_price')) {
761
+ return $cart_item_object->set_price($price);
762
+ }
763
+ return false;
764
+ }
765
+
766
+ /**
767
+ * print the notice
768
+ * @param $message
769
+ * @param $type
770
+ */
771
+ static function printNotice($message, $type)
772
+ {
773
+ if (function_exists('wc_print_notice')) {
774
+ wc_print_notice($message, $type);
775
+ }
776
+ }
777
+
778
+ /**
779
+ * Calculate including tax for product of price
780
+ * @param $product
781
+ * @param $original_price
782
+ * @param $quantity
783
+ * @return float
784
+ */
785
+ static function getIncludingTaxPrice($product, $original_price, $quantity)
786
+ {
787
+ if (function_exists('wc_get_price_including_tax')) {
788
+ $price = wc_get_price_including_tax($product, array('qty' => $quantity, 'price' => $original_price));
789
+ } else if (method_exists($product, 'get_price_including_tax')) {
790
+ $price = $product->get_price_including_tax($quantity, $original_price);
791
+ } else {
792
+ $price = $original_price;
793
+ }
794
+
795
+ return apply_filters('advanced_woo_discount_rules_get_price_including_tax', $price, $product, $original_price);
796
+ }
797
+
798
+ /**
799
+ * Calculate including tax for product of price
800
+ * @param $product
801
+ * @param $original_price
802
+ * @param $quantity
803
+ * @return float
804
+ */
805
+ static function getExcludingTaxPrice($product, $original_price, $quantity)
806
+ {
807
+ if (function_exists('wc_get_price_excluding_tax')) {
808
+ $price = wc_get_price_excluding_tax($product, array('qty' => $quantity, 'price' => $original_price));
809
+ } else if (method_exists($product, 'get_price_excluding_tax')) {
810
+ $price = $product->get_price_excluding_tax($quantity, $original_price);
811
+ } else {
812
+ $price = $original_price;
813
+ }
814
+
815
+ return apply_filters('advanced_woo_discount_rules_get_price_excluding_tax', $price, $product, $original_price);
816
+ }
817
+
818
+ /**
819
+ * get user roles
820
+ * @return array
821
+ */
822
+ static function getUserRolesList()
823
+ {
824
+ global $wp_roles;
825
+ if (isset($wp_roles->roles)) {
826
+ return $wp_roles->roles;
827
+ }
828
+ return array();
829
+ }
830
+
831
+ /**
832
+ * get countries from WC
833
+ * @return array
834
+ */
835
+ static function getCountriesList()
836
+ {
837
+ if (function_exists('WC')) {
838
+ if (isset(WC()->countries) && method_exists(WC()->countries, 'get_countries')) {
839
+ return WC()->countries->get_countries();
840
+ }
841
+ }
842
+ return array();
843
+ }
844
+
845
+ /**
846
+ * get States from WC
847
+ * @return array
848
+ */
849
+ static function getStatesList()
850
+ {
851
+ if (function_exists('WC')) {
852
+ if (isset(WC()->countries) && method_exists(WC()->countries, 'get_states')) {
853
+ return WC()->countries->get_states();
854
+ }
855
+ }
856
+ return array();
857
+ }
858
+
859
+ /**
860
+ * Get Payment Gateway Methods from WC
861
+ * @return array
862
+ */
863
+ static function getPaymentMethodList()
864
+ {
865
+ if (function_exists('WC')) {
866
+ if (method_exists(WC()->payment_gateways, 'payment_gateways')) {
867
+ return WC()->payment_gateways->payment_gateways();
868
+ }
869
+ }
870
+ return array();
871
+ }
872
+
873
+ /**
874
+ * Build week days
875
+ * @return array
876
+ */
877
+ static function getWeekDaysList()
878
+ {
879
+ return array(
880
+ 'sunday' => __('Sunday', WDR_TEXT_DOMAIN),
881
+ 'monday' => __('Monday', WDR_TEXT_DOMAIN),
882
+ 'tuesday' => __('Tuesday', WDR_TEXT_DOMAIN),
883
+ 'wednesday' => __('Wednesday', WDR_TEXT_DOMAIN),
884
+ 'thursday' => __('Thursday', WDR_TEXT_DOMAIN),
885
+ 'friday' => __('Friday', WDR_TEXT_DOMAIN),
886
+ 'saturday' => __('Saturday', WDR_TEXT_DOMAIN),
887
+ );
888
+ }
889
+
890
+ /**
891
+ * Build Banner position
892
+ * @return array
893
+ */
894
+ static function getBannerPositionList()
895
+ {
896
+ $banner_hooks = array(
897
+ 'woocommerce_before_main_content' => __('Woocommerce before main content(Archive / Shop / Cat Pages / single product)', WDR_TEXT_DOMAIN),
898
+ 'woocommerce_archive_description' => __('Woocommerce archive description(Archive / Shop / Cat Pages)', WDR_TEXT_DOMAIN),
899
+ 'woocommerce_before_shop_loop' => __('Woocommerce before shop loop(Archive / Shop / Cat Pages)', WDR_TEXT_DOMAIN),
900
+ 'woocommerce_after_shop_loop' => __('Woocommerce after shop loop(Archive / Shop / Cat Pages)', WDR_TEXT_DOMAIN),
901
+ 'woocommerce_after_main_content' => __('Woocommerce after main content(Archive / Shop / Cat Pages / single product)', WDR_TEXT_DOMAIN),
902
+ 'woocommerce_before_single_product' => __('Woocommerce before single product', WDR_TEXT_DOMAIN),
903
+ 'woocommerce_before_single_product_summary' => __('Woocommerce before single product summary', WDR_TEXT_DOMAIN),
904
+ 'woocommerce_after_single_product_summary' => __('Woocommerce after single product summary', WDR_TEXT_DOMAIN),
905
+ 'woocommerce_after_single_product' => __('Woocommerce after single product', WDR_TEXT_DOMAIN),
906
+ 'woocommerce_before_cart' => __('Woocommerce before cart', WDR_TEXT_DOMAIN),
907
+ 'woocommerce_before_cart_table' => __('Woocommerce before cart table', WDR_TEXT_DOMAIN),
908
+ 'woocommerce_before_cart_contents' => __('Woocommerce before cart contents', WDR_TEXT_DOMAIN),
909
+ 'woocommerce_cart_contents' => __('Woocommerce cart contents', WDR_TEXT_DOMAIN),
910
+ 'woocommerce_after_cart_contents' => __('Woocommerce after cart contents', WDR_TEXT_DOMAIN),
911
+ 'woocommerce_after_cart_table' => __('Woocommerce after cart table', WDR_TEXT_DOMAIN),
912
+ 'woocommerce_after_cart' => __('Woocommerce after cart', WDR_TEXT_DOMAIN),
913
+ 'woocommerce_before_checkout_form' => __('Woocommerce before checkout form', WDR_TEXT_DOMAIN),
914
+ //'woocommerce_checkout_before_customer_details' => __('Woocommerce checkout before customer details', WDR_TEXT_DOMAIN),
915
+ 'woocommerce_before_checkout_billing_form' => __('Woocommerce before checkout billing form', WDR_TEXT_DOMAIN),
916
+ 'woocommerce_after_checkout_billing_form' => __('Woocommerce after checkout billing form', WDR_TEXT_DOMAIN),
917
+ 'woocommerce_before_checkout_shipping_form' => __('Woocommerce before checkout shipping form', WDR_TEXT_DOMAIN),
918
+ 'woocommerce_after_checkout_shipping_form' => __('Woocommerce after checkout shipping form', WDR_TEXT_DOMAIN),
919
+ 'woocommerce_before_order_notes' => __('Woocommerce before order notes', WDR_TEXT_DOMAIN),
920
+ 'woocommerce_after_order_notes' => __('Woocommerce after order notes', WDR_TEXT_DOMAIN),
921
+ //'woocommerce_checkout_after_customer_details' => __('Woocommerce checkout after customer details', WDR_TEXT_DOMAIN),
922
+ //'woocommerce_checkout_before_order_review' => __('Woocommerce checkout before order review', WDR_TEXT_DOMAIN),
923
+ //'woocommerce_checkout_after_order_review' => __('Woocommerce checkout after order review', WDR_TEXT_DOMAIN),
924
+ );
925
+
926
+ return apply_filters('advanced_woo_discount_rules_get_banner_position_events', $banner_hooks);
927
+ }
928
+
929
+ /**
930
+ * get weight of the item
931
+ * @param $item
932
+ * @return int
933
+ */
934
+ static function getWeight($item)
935
+ {
936
+ if (!empty($item)) {
937
+ if (method_exists($item, 'get_weight')) {
938
+ return $item->get_weight();
939
+ }
940
+ }
941
+ return 0;
942
+ }
943
+
944
+ /**
945
+ * get woocommerce plugin url
946
+ */
947
+ static function getWooPluginUrl()
948
+ {
949
+ if (function_exists('WC')) {
950
+ return WC()->plugin_url();
951
+ }
952
+ return NULL;
953
+ }
954
+
955
+ /**
956
+ * get the user selected payment method
957
+ * @return array|string|null
958
+ */
959
+ static function getUserSelectedPaymentMethod()
960
+ {
961
+ return self::getSession('chosen_payment_method', NULL);
962
+ }
963
+
964
+ /**
965
+ * get the session value by key
966
+ * @param $key
967
+ * @param null $default
968
+ * @return array|string|null
969
+ */
970
+ static function getSession($key, $default = NULL)
971
+ {
972
+ if (function_exists('WC')) {
973
+ if (method_exists(WC()->session, 'get')) {
974
+ return WC()->session->get($key);
975
+ }
976
+ }
977
+ return $default;
978
+ }
979
+
980
+ /**
981
+ * set the session value by key
982
+ * @param $key
983
+ * @param $value mixed
984
+ */
985
+ static function setSession($key, $value)
986
+ {
987
+ if (function_exists('WC')) {
988
+ if (method_exists(WC()->session, 'set')) {
989
+ WC()->session->set($key, $value);
990
+ }
991
+ }
992
+ }
993
+
994
+ /**
995
+ * get the user role from user obj
996
+ * @param $user
997
+ * @return array
998
+ */
999
+ static function getRole($user)
1000
+ {
1001
+ if (!empty($user) && isset($user->user_login)) {
1002
+ return $user->roles;
1003
+ }
1004
+ return array();
1005
+ }
1006
+
1007
+ /**
1008
+ * get the shipping country of customer
1009
+ * @return string|null
1010
+ */
1011
+ static function getShippingCountry()
1012
+ {
1013
+ if (function_exists('WC') && WC()->customer) {
1014
+ if (method_exists(WC()->customer, 'get_shipping_country')) {
1015
+ return WC()->customer->get_shipping_country();
1016
+ }
1017
+ }
1018
+ return NULL;
1019
+ }
1020
+
1021
+ /**
1022
+ * get the shipping state of customer
1023
+ * @return string|null
1024
+ */
1025
+ static function getShippingState()
1026
+ {
1027
+ if (function_exists('WC') && WC()->customer) {
1028
+ if (method_exists(WC()->customer, 'get_shipping_state')) {
1029
+ return WC()->customer->get_shipping_state();
1030
+ }
1031
+ }
1032
+ return NULL;
1033
+ }
1034
+
1035
+ /**
1036
+ * get the shipping city of customer
1037
+ * @return string|null
1038
+ */
1039
+ static function getShippingCity()
1040
+ {
1041
+ if (function_exists('WC') && WC()->customer) {
1042
+ if (method_exists(WC()->customer, 'get_shipping_city')) {
1043
+ return WC()->customer->get_shipping_city();
1044
+ }
1045
+ }
1046
+ return NULL;
1047
+ }
1048
+
1049
+ /**
1050
+ * get the Billing city of customer
1051
+ * @return string|null
1052
+ */
1053
+ static function getBillingCity()
1054
+ {
1055
+ if (function_exists('WC') && WC()->customer) {
1056
+ if (method_exists(WC()->customer, 'get_billing_city')) {
1057
+ return WC()->customer->get_billing_city();
1058
+ }
1059
+ }
1060
+ return NULL;
1061
+ }
1062
+
1063
+ /**
1064
+ * get the shipping city of customer
1065
+ * @return string|null
1066
+ */
1067
+ static function getShippingZipCode()
1068
+ {
1069
+ if (function_exists('WC') && WC()->customer) {
1070
+ if (method_exists(WC()->customer, 'get_shipping_postcode')) {
1071
+ return WC()->customer->get_shipping_postcode();
1072
+ }
1073
+ }
1074
+ return NULL;
1075
+ }
1076
+
1077
+ /**
1078
+ * get orders list by condition
1079
+ * @param array $conditions
1080
+ * @return int[]|WP_Post[]
1081
+ */
1082
+ static function getOrdersByConditions($conditions = array())
1083
+ {
1084
+ $default_conditions = array(
1085
+ 'numberposts' => -1,
1086
+ 'post_type' => self::getOrderPostType(),
1087
+ 'post_status' => array_keys(self::getOrderStatusList()),
1088
+ 'orderby' => 'ID',
1089
+ 'order' => 'DESC'
1090
+ );
1091
+ if (is_object($conditions)) {
1092
+ $conditions = (array)$conditions;
1093
+ } elseif (!is_array($conditions)) {
1094
+ $conditions = array();
1095
+ }
1096
+ $final_conditions = array_merge($default_conditions, $conditions);
1097
+ return get_posts($final_conditions);
1098
+ }
1099
+
1100
+ /**
1101
+ * Get all order status lists
1102
+ * @param bool $key_only
1103
+ * @return array
1104
+ */
1105
+ static function getOrderPostType($key_only = false)
1106
+ {
1107
+ if (function_exists('wc_get_order_types')) {
1108
+ if ($key_only) {
1109
+ return array_keys(wc_get_order_types());
1110
+ }
1111
+ return wc_get_order_types();
1112
+ }
1113
+ return NULL;
1114
+ }
1115
+
1116
+ /**
1117
+ * get woocommerce order status
1118
+ * @return array
1119
+ */
1120
+ static function getOrderStatusList()
1121
+ {
1122
+ if (function_exists('wc_get_order_statuses')) {
1123
+ return wc_get_order_statuses();
1124
+ }
1125
+ return array();
1126
+ }
1127
+
1128
+ /**
1129
+ * get item ids of the particular order
1130
+ * @param $order
1131
+ * @return array
1132
+ */
1133
+ static function getOrderItemsId($order)
1134
+ {
1135
+ $order_items = self::getOrderItems($order);
1136
+ $order_items_id = array();
1137
+ if (!empty($order_items)) {
1138
+ foreach ($order_items as $item) {
1139
+ $order_items_id[] = self::getItemId($item);
1140
+ }
1141
+ }
1142
+ return array_filter($order_items_id);
1143
+ }
1144
+
1145
+ /**
1146
+ * get quantities of the particular order
1147
+ * @param $order
1148
+ * @return array
1149
+ */
1150
+ static function getOrderItemsQty($order)
1151
+ {
1152
+ $order_items = self::getOrderItems($order);
1153
+ $productIds = array();
1154
+ if (!empty($order_items)) {
1155
+ foreach ($order_items as $item) {
1156
+ $product_id = $item->get_product_id();
1157
+ $variant_id = $item->get_variation_id();
1158
+ $quantity = $item->get_quantity();
1159
+ if($variant_id){
1160
+ $productId = $variant_id;
1161
+ } else {
1162
+ $productId = $product_id;
1163
+ }
1164
+ if(isset($productIds[$productId])){
1165
+ $productIds[$productId] = $productIds[$productId]+$quantity;
1166
+ } else {
1167
+ $productIds[$productId] = $quantity;
1168
+ }
1169
+ }
1170
+ }
1171
+
1172
+ return $productIds;
1173
+ }
1174
+
1175
+ /**
1176
+ * get all items of the order
1177
+ * @param $order
1178
+ * @return array
1179
+ */
1180
+ static function getOrderItems($order)
1181
+ {
1182
+ if (method_exists($order, 'get_items')) {
1183
+ return $order->get_items();
1184
+ }
1185
+ return array();
1186
+ }
1187
+
1188
+ /**
1189
+ * get the order currency
1190
+ * @param $order
1191
+ * @return array
1192
+ */
1193
+ static function getOrderCurrency($order)
1194
+ {
1195
+ if (method_exists($order, 'get_currency')) {
1196
+ return $order->get_currency();
1197
+ }
1198
+ return NULL;
1199
+ }
1200
+
1201
+ /**
1202
+ * Set order item meta
1203
+ * @param $item
1204
+ * @param $key
1205
+ * @param $value
1206
+ * @return array
1207
+ */
1208
+ static function setOrderItemMeta($item, $key, $value)
1209
+ {
1210
+ if (method_exists($item, 'add_meta_data')) {
1211
+ return $item->add_meta_data($key, $value, true);
1212
+ }
1213
+ return NULL;
1214
+ }
1215
+
1216
+ /**
1217
+ * Set order item meta
1218
+ * @param $item
1219
+ * @param $key
1220
+ * @return array
1221
+ */
1222
+ static function getOrderItemMeta($item, $key)
1223
+ {
1224
+ if (method_exists($item, 'get_meta')) {
1225
+ return $item->get_meta($key);
1226
+ }
1227
+ return NULL;
1228
+ }
1229
+
1230
+ /**
1231
+ * get item id from the item object
1232
+ * @param $item
1233
+ * @return null
1234
+ */
1235
+ static function getItemId($item)
1236
+ {
1237
+ if (method_exists($item, 'get_product_id') && method_exists($item, 'get_variation_id')) {
1238
+ if ($product_id = $item->get_variation_id()) {
1239
+ return $product_id;
1240
+ } else {
1241
+ return $item->get_product_id();
1242
+ }
1243
+ }
1244
+ return NULL;
1245
+ }
1246
+
1247
+ /**
1248
+ * get term slug from category id
1249
+ * @param $id
1250
+ * @return bool
1251
+ */
1252
+ static function getCategorySlugByID($id)
1253
+ {
1254
+ if (function_exists('get_term_by')) {
1255
+ $term = get_term_by('id', $id, 'product_cat', 'ARRAY_A');
1256
+ return isset($term['slug']) ? $term['slug'] : NULL;
1257
+ }
1258
+ return NULL;
1259
+ }
1260
+
1261
+ /**
1262
+ * get term slug from tag id
1263
+ * @param $id
1264
+ * @return bool
1265
+ */
1266
+ static function getTagSlugByID($id)
1267
+ {
1268
+ $slug = false;
1269
+ if (function_exists('get_term_by')) {
1270
+ $term = get_term_by('id', $id, 'product_tag', 'ARRAY_A');
1271
+ $slug = $term['slug'];
1272
+ }
1273
+ return $slug;
1274
+ }
1275
+
1276
+ /**
1277
+ * get custom term slug from custom tag id
1278
+ * @param $id
1279
+ * @param $term_name
1280
+ * @return boo
1281
+ */
1282
+ static function getTermSlugByID($id, $term_name)
1283
+ {
1284
+ $slug = false;
1285
+ if (function_exists('get_term_by')) {
1286
+ $term = get_term_by('id', $id, $term_name, 'ARRAY_A');
1287
+ $slug = $term['slug'];
1288
+ }
1289
+ return $slug;
1290
+ }
1291
+
1292
+ /**
1293
+ * get product id by using sku
1294
+ * @param $sku
1295
+ * @return bool|int
1296
+ */
1297
+ static function getProductsBySku($sku)
1298
+ {
1299
+ if (empty($sku)) {
1300
+ return false;
1301
+ }
1302
+ if (function_exists('wc_get_product_id_by_sku')) {
1303
+ $id = wc_get_product_id_by_sku($sku);
1304
+ if (!empty($id)) {
1305
+ $product_id = Woocommerce::getProductParentId($id);
1306
+ if (empty($product_id)) {
1307
+ return $id;
1308
+ } else {
1309
+ return $product_id;
1310
+ }
1311
+ }
1312
+ }
1313
+ return false;
1314
+ }
1315
+
1316
+ /**
1317
+ * get on sale products ids
1318
+ * @return array|bool
1319
+ */
1320
+ static function getOnSaleProductsIds()
1321
+ {
1322
+ if (function_exists('wc_get_product_ids_on_sale')) {
1323
+ $on_sale_product_ids = wc_get_product_ids_on_sale();
1324
+ return apply_filters('advanced_woo_discount_rules_get_on_sale_product_ids', $on_sale_product_ids);
1325
+ }
1326
+
1327
+ return false;
1328
+ }
1329
+
1330
+ /**
1331
+ * get all available attributes details
1332
+ * @return array
1333
+ */
1334
+ static function getAllAvailableAttributeDetails()
1335
+ {
1336
+ global $wc_product_attributes;
1337
+ $attributes = array();
1338
+ $available_attr = array();
1339
+ if (function_exists('get_terms') && isset($wc_product_attributes) && is_array($wc_product_attributes) && !empty($wc_product_attributes)) {
1340
+ foreach ($wc_product_attributes as $attr_tax => $attr_value) {
1341
+ $terms = get_terms(array(
1342
+ 'taxonomy' => $attr_tax,
1343
+ 'hide_empty' => false,
1344
+ ));
1345
+ $attributes[$attr_tax] = $terms;
1346
+ if (is_array($terms) && !empty($terms)) {
1347
+ foreach ($terms as $term_detail) {
1348
+ if (is_object($term_detail)) {
1349
+ $term_id = isset($term_detail->term_id) ? $term_detail->term_id : '';
1350
+ if (!empty($term_id)) {
1351
+ $available_attr[$attr_tax]['id'][] = $term_id;
1352
+ $available_attr[$attr_tax]['slug'][$term_id] = $term_detail->slug;
1353
+ }
1354
+ }
1355
+ }
1356
+ }
1357
+ }
1358
+ }
1359
+ return array('terms' => $attributes, 'attr' => $available_attr);
1360
+ }
1361
+
1362
+ /**
1363
+ * get current cart quantities
1364
+ * @return int|mixed
1365
+ */
1366
+ static function getCartTotalQuantities()
1367
+ {
1368
+ $cart_items = self::getCart();
1369
+ $quantity = 0;
1370
+ if (!empty($cart_items)) {
1371
+ foreach ($cart_items as $cart_item) {
1372
+ $quantity += $cart_item['quantity'];
1373
+ }
1374
+ }
1375
+ return apply_filters('advanced_woo_discount_rules_get_cart_total_quantities', $quantity, $cart_items);
1376
+ }
1377
+
1378
+ /**
1379
+ * define product loop has started
1380
+ * @param bool $echo
1381
+ * @return string|null
1382
+ */
1383
+ static function productLoopStart($echo = true)
1384
+ {
1385
+ if (function_exists('woocommerce_product_loop_start')) {
1386
+ return woocommerce_product_loop_start($echo);
1387
+ }
1388
+ return NULL;
1389
+ }
1390
+
1391
+ /**
1392
+ * Set product loop as end
1393
+ * @param bool $echo
1394
+ * @return string|null
1395
+ */
1396
+ static function productLoopEnd($echo = true)
1397
+ {
1398
+ if (function_exists('woocommerce_product_loop_end')) {
1399
+ return woocommerce_product_loop_end($echo);
1400
+ }
1401
+ return NULL;
1402
+ }
1403
+
1404
+ /**
1405
+ * set product loop properties
1406
+ * @param $option
1407
+ * @param $value
1408
+ * @return void|null
1409
+ */
1410
+ static function setLoopProperties($option, $value)
1411
+ {
1412
+ if (function_exists('wc_set_loop_prop')) {
1413
+ return wc_set_loop_prop($option, $value);
1414
+ }
1415
+ return NULL;
1416
+ }
1417
+
1418
+ /**
1419
+ * Validate coupon
1420
+ *
1421
+ * @param string $coupon_name
1422
+ * @return boolean
1423
+ * */
1424
+ static function checkCouponAlreadyExistsInWooCommerce($coupon_name)
1425
+ {
1426
+ $coupon_args = array(
1427
+ 'name' => $coupon_name,
1428
+ 'post_type' => 'shop_coupon'
1429
+ );
1430
+ $posts = get_posts($coupon_args);
1431
+ if (!empty($posts) && count($posts) > 0) {
1432
+ return true;
1433
+ }
1434
+ return false;
1435
+ }
1436
+
1437
+ /**
1438
+ * Validate coupon
1439
+ *
1440
+ * @param string $coupon_name
1441
+ * @return array
1442
+ * */
1443
+ static function validateDynamicCoupon($coupon_name)
1444
+ {
1445
+ $result['status'] = false;
1446
+ if (!empty($coupon_name)) {
1447
+ $coupon_exists = self::checkCouponAlreadyExistsInWooCommerce($coupon_name);
1448
+ if ($coupon_exists) {
1449
+ $result['status'] = false;
1450
+ $result['message'] = esc_html__('Coupon already exists in WooCommerce. Please select another name', 'woo-discount-rules');
1451
+ } else {
1452
+ $result['status'] = true;
1453
+ }
1454
+ }
1455
+ $result['coupon'] = $coupon_name;
1456
+ return $result;
1457
+ }
1458
+
1459
+ /**
1460
+ * get current product price html
1461
+ * @param $product
1462
+ * @return bool
1463
+ */
1464
+ static function getPriceHtml($product){
1465
+ $html = false;
1466
+ if (method_exists('get_price_html')) {
1467
+ $html = $product->get_price_html();
1468
+ }
1469
+ return apply_filters('advanced_woo_discount_rules_get_price_html', $html, $product);
1470
+ }
1471
+
1472
+ /**
1473
+ * get parent product of current product
1474
+ * @param $product
1475
+ * @return bool|false|WC_Product|null
1476
+ */
1477
+ static function getParentProduct($product){
1478
+
1479
+ if (self::productTypeIs($product, 'variation')) {
1480
+ $parent_id = self::getProductParentId($product);
1481
+ $product = self::getProduct($parent_id);
1482
+ }
1483
+ return $product;
1484
+ }
1485
+
1486
+ public static function getCheckOutPostData(){
1487
+ if(self::$checkout_post === null){
1488
+ $input = new Input();
1489
+ $postData = $input->post('post_data', null, 'raw');
1490
+ $postDataArray = array();
1491
+ if($postData != ''){
1492
+ parse_str($postData, $postDataArray);
1493
+ }
1494
+ self::$checkout_post = $postDataArray;
1495
+ }
1496
+ return self::$checkout_post;
1497
+ }
1498
+
1499
+ /**
1500
+ * Get billing email from post data
1501
+ *
1502
+ * @return string
1503
+ * */
1504
+ public static function getBillingEmailFromPost(){
1505
+ $user_email = '';
1506
+ $postData = self::getCheckOutPostData();
1507
+ if(isset($postData['billing_email']) && !empty($postData['billing_email'])){
1508
+ $user_email = $postData['billing_email'];
1509
+ }
1510
+ if(empty($user_email)){
1511
+ if(function_exists('WC')){
1512
+ $session = WC()->session;
1513
+ if(!empty($session)){
1514
+ if(method_exists($session, 'get')){
1515
+ $customer = $session->get('customer');
1516
+ if(isset($customer['email']) && !empty($customer['email'])){
1517
+ $user_email = $customer['email'];
1518
+ }
1519
+ }
1520
+ }
1521
+ }
1522
+ }
1523
+ return $user_email;
1524
+ }
1525
+ }
v2/App/Models/DBTable.php ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App\Models;
4
+
5
+ use Wdr\App\Helpers\Language;
6
+
7
+ if (!defined('ABSPATH')) exit;
8
+
9
+ class DBTable
10
+ {
11
+ const RULES_TABLE_NAME = WDR_PLUGIN_PREFIX . 'rules', ORDER_DISCOUNT_TABLE_NAME = WDR_PLUGIN_PREFIX . 'order_discounts', ORDER_ITEM_DISCOUNT_TABLE_NAME = WDR_PLUGIN_PREFIX . 'order_item_discounts';
12
+
13
+ protected static $rules = array();
14
+
15
+ function createDBTables()
16
+ {
17
+ global $wpdb;
18
+ if (is_multisite()) {
19
+ // get ids of all sites
20
+ $blog_table = $wpdb->blogs;
21
+ $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$blog_table}");
22
+ foreach ($blog_ids as $blog_id) {
23
+ switch_to_blog($blog_id);
24
+ // create tables for each site
25
+ $this->createTable();
26
+ restore_current_blog();
27
+ }
28
+ } else {
29
+ // activated on a single site
30
+ $this->createTable();
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Create table while initializing plugin
36
+ */
37
+ public function createTable()
38
+ {
39
+ global $wpdb;
40
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
41
+ $charset_collate = $wpdb->get_charset_collate();
42
+ $rules_table_name = $wpdb->prefix . self::RULES_TABLE_NAME;
43
+ $rules_table_query = "CREATE TABLE IF NOT EXISTS $rules_table_name (
44
+ `id` int(11) NOT NULL AUTO_INCREMENT,
45
+ `enabled` tinyint(1) DEFAULT '1',
46
+ `deleted` tinyint(1) DEFAULT '0',
47
+ `exclusive` tinyint(1) DEFAULT '0',
48
+ `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
49
+ `priority` int(11) DEFAULT NULL,
50
+ `apply_to` text COLLATE utf8mb4_unicode_ci,
51
+ `filters` text COLLATE utf8mb4_unicode_ci NOT NULL,
52
+ `conditions` text COLLATE utf8mb4_unicode_ci,
53
+ `product_adjustments` text COLLATE utf8mb4_unicode_ci,
54
+ `cart_adjustments` text COLLATE utf8mb4_unicode_ci,
55
+ `buy_x_get_x_adjustments` text COLLATE utf8mb4_unicode_ci,
56
+ `buy_x_get_y_adjustments` text COLLATE utf8mb4_unicode_ci,
57
+ `bulk_adjustments` text COLLATE utf8mb4_unicode_ci NOT NULL,
58
+ `set_adjustments` text COLLATE utf8mb4_unicode_ci NOT NULL,
59
+ `other_discounts` text COLLATE utf8mb4_unicode_ci,
60
+ `date_from` int(11) DEFAULT NULL,
61
+ `date_to` int(11) DEFAULT NULL,
62
+ `usage_limits` int(11) DEFAULT NULL,
63
+ `rule_language` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
64
+ `used_limits` int(11) DEFAULT NULL,
65
+ `additional` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
66
+ `max_discount_sum` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
67
+ `advanced_discount_message` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
68
+ `discount_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
69
+ `used_coupons` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
70
+ PRIMARY KEY (`id`)
71
+ ) $charset_collate;";
72
+ $order_discount_table_name = $wpdb->prefix . self::ORDER_DISCOUNT_TABLE_NAME;
73
+ $order_discount_table_query = "CREATE TABLE IF NOT EXISTS $order_discount_table_name (
74
+ `id` int(11) NOT NULL AUTO_INCREMENT,
75
+ `order_id` int(11) DEFAULT NULL,
76
+ `has_free_shipping` enum('yes','no') NOT NULL DEFAULT 'no',
77
+ `discounts` text NOT NULL,
78
+ `created_at` datetime DEFAULT NULL,
79
+ `updated_at` datetime DEFAULT NULL,
80
+ `extra` longtext DEFAULT NULL,
81
+ PRIMARY KEY (`id`)
82
+ ) $charset_collate;";
83
+ $order_item_discount_table_name = $wpdb->prefix . self::ORDER_ITEM_DISCOUNT_TABLE_NAME;
84
+ $order_item_discount_table_query = "CREATE TABLE IF NOT EXISTS $order_item_discount_table_name (
85
+ `id` int(11) NOT NULL AUTO_INCREMENT,
86
+ `order_id` int(11) DEFAULT NULL,
87
+ `rule_id` int(11) DEFAULT NULL,
88
+ `item_id` int(11) DEFAULT NULL,
89
+ `item_price` float NOT NULL,
90
+ `discounted_price` float NOT NULL,
91
+ `discount` float NOT NULL,
92
+ `quantity` int(11) NOT NULL,
93
+ `simple_discount` float NOT NULL,
94
+ `bulk_discount` float NOT NULL,
95
+ `set_discount` float NOT NULL,
96
+ `cart_discount` float NOT NULL,
97
+ `has_free_shipping` enum('yes','no') NOT NULL DEFAULT 'no',
98
+ `cart_discount_label` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
99
+ `other_price` float NOT NULL DEFAULT '0',
100
+ `created_at` datetime DEFAULT NULL,
101
+ `updated_at` datetime DEFAULT NULL,
102
+ `extra` longtext DEFAULT NULL,
103
+ PRIMARY KEY (`id`)
104
+ ) $charset_collate;";
105
+ if($wpdb->get_var("show tables like '$rules_table_name'") != $rules_table_name){
106
+ dbDelta($rules_table_query);
107
+ }
108
+ if($wpdb->get_var("show tables like '$order_discount_table_name'") != $order_discount_table_name){
109
+ dbDelta($order_discount_table_query);
110
+ }
111
+ if($wpdb->get_var("show tables like '$order_item_discount_table_name'") != $order_item_discount_table_name){
112
+ dbDelta($order_item_discount_table_query);
113
+ }
114
+ }
115
+
116
+ /**
117
+ * get all available rules
118
+ * @param null $rule_id
119
+ * @param null $rule_name
120
+ * @param null $export
121
+ * @return mixed
122
+ */
123
+ static function getRules($rule_id = NULL, $rule_name = NULL, $export = NULL, $cache = true)
124
+ {
125
+ global $wpdb;
126
+ $rules_table_name = $wpdb->prefix . self::RULES_TABLE_NAME;
127
+ /**
128
+ * Need for Frontend
129
+ */
130
+ if (!is_admin()) {
131
+ if(isset(self::$rules['front_end']) && $cache === true){
132
+ return self::$rules['front_end'];
133
+ }
134
+ $current_time = current_time('timestamp');
135
+ $current_language = Language::getCurrentLanguage();
136
+ $language_query = '';
137
+ if (!empty($current_language)) {
138
+ $language_query = ' AND (rule_language IS NULL OR rule_language = "[]" OR rule_language LIKE \'%"' . $current_language . '"%\')';
139
+ }
140
+ $query = "SELECT * FROM {$rules_table_name} WHERE enabled = %d AND deleted = %d AND (date_from <= %d OR date_from IS NULL) AND (date_to >= %d OR date_to IS NULL) AND (usage_limits > used_limits OR used_limits IS NULL OR usage_limits = 0) {$language_query} ORDER BY priority ASC";
141
+ return self::$rules['front_end'] = $wpdb->get_results($wpdb->prepare($query, array(1, 0, $current_time, $current_time)), OBJECT);
142
+ }
143
+ /**
144
+ * Need for Admin
145
+ */
146
+ if (is_admin()) {
147
+ if (!is_null($rule_id) && is_null($rule_name) && is_null($export)) {
148
+ if(isset(self::$rules['admin_based_on_rule_id']) && $cache === true){
149
+ return self::$rules['admin_based_on_rule_id'];
150
+ }
151
+ if(is_array($rule_id)){
152
+ $rule_id = array_map('absint', $rule_id);
153
+ $rule_id = implode(",", $rule_id);
154
+ return self::$rules['admin_based_on_rule_id'] = $wpdb->get_results("SELECT * FROM {$rules_table_name} WHERE id IN ({$rule_id})");
155
+ } else {
156
+ return self::$rules['admin_based_on_rule_id'] = $wpdb->get_row("SELECT * FROM {$rules_table_name} WHERE id={$rule_id}");
157
+ }
158
+ } elseif (is_null($rule_id) && !is_null($rule_name) && is_null($export)) {
159
+ if(isset(self::$rules['admin_based_on_rule_name']) && $cache === true){
160
+ return self::$rules['admin_based_on_rule_name'];
161
+ }
162
+ return self::$rules['admin_based_on_rule_name'] = $wpdb->get_results("SELECT * FROM {$rules_table_name} WHERE deleted = 0 AND title LIKE '%{$rule_name}%'");
163
+ } else {
164
+ if(isset(self::$rules['admin_all']) && $cache === true){
165
+ return self::$rules['admin_all'];
166
+ }
167
+ return self::$rules['admin_all'] = $wpdb->get_results("SELECT * FROM {$rules_table_name} WHERE deleted = 0 ORDER BY priority ASC");
168
+ }
169
+ }
170
+ return false;
171
+ }
172
+
173
+ /**
174
+ * save new rule
175
+ * @param $format
176
+ * @param $values
177
+ * @param null $rule_id
178
+ * @return int|null
179
+ */
180
+ static function saveRule($format, $values, $rule_id = NULL)
181
+ {
182
+
183
+ global $wpdb;
184
+ if (!is_null($rule_id) && !empty($rule_id)) {
185
+ $wpdb->update($wpdb->prefix . self::RULES_TABLE_NAME, $values, array('id' => $rule_id), $format, array('%d'));
186
+ } else {
187
+ $wpdb->insert($wpdb->prefix . self::RULES_TABLE_NAME, $values, $format);
188
+ $rule_id = $wpdb->insert_id;
189
+ $wpdb->update($wpdb->prefix . self::RULES_TABLE_NAME, array('priority' => $rule_id), array('id' => $rule_id), array('%d'), array('%d'));
190
+ }
191
+ return $rule_id;
192
+ }
193
+
194
+ /**
195
+ * @param $order_id
196
+ * @param $free_shipping
197
+ * @param $discounts
198
+ * @return int
199
+ */
200
+ static function saveOrderDiscounts($order_id, $free_shipping, $discounts)
201
+ {
202
+ global $wpdb;
203
+ $order_discount_table_name = $wpdb->prefix . self::ORDER_DISCOUNT_TABLE_NAME;
204
+ $select_query = "SELECT id FROM {$order_discount_table_name} WHERE order_id=" . $order_id;
205
+ $order_discounts = $wpdb->get_row($select_query, OBJECT);
206
+ $current_time = current_time('mysql', true);
207
+ if (empty($order_discounts)) {
208
+ $insert_query = "INSERT INTO {$order_discount_table_name} (order_id, has_free_shipping, discounts, created_at) VALUES ({$order_id}, '{$free_shipping}', '{$discounts}', '{$current_time}')";
209
+ $wpdb->query($insert_query);
210
+ $row_id = $wpdb->insert_id;
211
+ } else {
212
+ $row_id = $order_discounts->id;
213
+ $update_query = "UPDATE {$order_discount_table_name} SET has_free_shipping = '{$free_shipping}', discounts = '{$discounts}', updated_at = '{$current_time}' WHERE id={$row_id}";
214
+ $wpdb->query($update_query);
215
+ }
216
+ return $row_id;
217
+ }
218
+
219
+ /**
220
+ * Updating the used limits of rules
221
+ * @param $rule_id
222
+ * @param $used_count
223
+ */
224
+ static function updateRuleUsedCount($rule_id, $used_count)
225
+ {
226
+ global $wpdb;
227
+ $wpdb->update($wpdb->prefix . self::RULES_TABLE_NAME, array('used_limits' => $used_count), array('id' => $rule_id), array('%d'), array('%d'));
228
+ }
229
+
230
+ /**
231
+ * save the order item discount
232
+ * @param $order_id
233
+ * @param $item_id
234
+ * @param $item_price
235
+ * @param $discounted_price
236
+ * @param $discount
237
+ * @param $quantity
238
+ * @return int
239
+ */
240
+ static function saveOrderItemDiscounts($order_id, $item_id, $item_price, $discounted_price, $discount, $quantity, $rule_id, $simple_discount, $bulk_discount, $set_discount, $cart_discount, $cart_discount_label, $cart_shipping_method )
241
+ {
242
+ global $wpdb;
243
+ $order_item_discount_table_name = $wpdb->prefix . self::ORDER_ITEM_DISCOUNT_TABLE_NAME;
244
+ $select_query = "SELECT id FROM {$order_item_discount_table_name} WHERE order_id= {$order_id} AND item_id={$item_id} AND rule_id={$rule_id}";
245
+ $order_discounts = $wpdb->get_row($select_query, OBJECT);
246
+ $current_time = current_time('mysql', true);
247
+
248
+ if (empty($order_discounts)) {
249
+ $insert_query = "INSERT INTO {$order_item_discount_table_name} (order_id, rule_id, item_id, item_price, discounted_price, discount, quantity, simple_discount, bulk_discount, set_discount, cart_discount, has_free_shipping, cart_discount_label, created_at, updated_at) VALUES ({$order_id}, {$rule_id}, {$item_id}, {$item_price}, {$discounted_price}, {$discount}, {$quantity}, {$simple_discount}, {$bulk_discount}, {$set_discount}, {$cart_discount}, '{$cart_shipping_method}', '{$cart_discount_label}', '{$current_time}', '{$current_time}')";
250
+ $wpdb->query($insert_query);
251
+ $row_id = $wpdb->insert_id;
252
+ } else {
253
+ $row_id = $order_discounts->id;
254
+ $update_query = "UPDATE {$order_item_discount_table_name} SET order_id={$order_id}, rule_id={$rule_id}, item_id={$item_id}, item_price={$item_price}, discounted_price={$discounted_price}, discount={$discount}, quantity={$quantity}, simple_discount={$simple_discount}, bulk_discount={$bulk_discount}, set_discount={$set_discount}, cart_discount={$cart_discount}, has_free_shipping='{$cart_shipping_method}', cart_discount_label='{$cart_discount_label}', updated_at='{$current_time}' WHERE id={$row_id}";
255
+ $wpdb->query($update_query);
256
+ }
257
+ return $row_id;
258
+ }
259
+
260
+ /**
261
+ * @param $from
262
+ * @param $to
263
+ * @param $option
264
+ * @return array|object|null|bool
265
+ */
266
+ /*static function getRulesByPeriod($from, $to, $option='basic')
267
+ {
268
+ global $wpdb;
269
+ $rules_table_name = $wpdb->prefix.self::RULES_TABLE_NAME;
270
+ $order_item_discount_table_name = $wpdb->prefix.self::ORDER_ITEM_DISCOUNT_TABLE_NAME;
271
+ $result = false;
272
+ if(empty($from) || empty($to)){
273
+ return $result;
274
+ }
275
+ switch ($option) {
276
+ case 'all':
277
+ break;
278
+ case 'simple':
279
+ break;
280
+ case 'bulk':
281
+ break;
282
+ case 'set':
283
+ break;
284
+ default:
285
+ case 'basic':
286
+ $query = "SELECT discount_table.order_id, discount_table.rule_id, discount_table.created_at, SUM(discount_table.quantity * discount_table.discount) as amount , rules.title FROM {$order_item_discount_table_name} as discount_table INNER JOIN {$rules_table_name} as rules ON discount_table.rule_id=rules.id WHERE (discount_table.created_at BETWEEN {$from} AND {$to}) GROUP BY discount_table.rule_id,discount_table.order_id ORDER BY discount_table.id ASC";
287
+ $result = $wpdb->get_results($query, OBJECT);
288
+ break;
289
+ }
290
+ return $result;
291
+ }*/
292
+
293
+ /**
294
+ * @param $params
295
+ * @return array|bool|object|null
296
+ */
297
+ public static function get_rules_rows_summary( $params ) {
298
+ global $wpdb;
299
+ $params = array_merge( array(
300
+ 'from' => '',
301
+ 'to' => '',
302
+ 'limit' => 5,
303
+ 'include_amount' => true,
304
+ 'include_cart_discount' => false,
305
+ //'include_shipping' => false,
306
+ //'include_gifted_amount' => false,
307
+ //'include_gifted_qty' => false,
308
+ ), $params );
309
+
310
+ if ( empty( $params['from'] ) || empty( $params['to'] ) ) {
311
+ return false;
312
+ }
313
+
314
+
315
+
316
+ $summary_components = array();
317
+ if ( $params['include_gifted_qty'] ) {
318
+ $summary_components[] = 'rules_stats.gifted_qty';
319
+ } else {
320
+ if ( $params['include_amount'] ) {
321
+ $summary_components[] = 'rules_stats.discount';
322
+ }
323
+ if ( $params['include_cart_discount'] ) {
324
+ $summary_components[] = 'rules_stats.cart_discount';
325
+ }
326
+ if ( $params['include_shipping'] ) {
327
+ $summary_components[] = 'rules_stats.shipping';
328
+ }
329
+ if ( $params['include_gifted_amount'] ) {
330
+ $summary_components[] = 'rules_stats.gifted_amount';
331
+ }
332
+ }
333
+ if ( empty( $summary_components ) ) {
334
+ return false;
335
+ }
336
+ $summary_field = implode( '+', $summary_components );
337
+ $table_items = $wpdb->prefix.self::RULES_TABLE_NAME;
338
+ $table_stats = $wpdb->prefix.self::ORDER_ITEM_DISCOUNT_TABLE_NAME;
339
+
340
+ $query_total = $wpdb->prepare(
341
+ "SELECT rules.id AS rule_id, SUM({$summary_field}) AS value
342
+ FROM {$table_items} AS rules LEFT JOIN {$table_stats} AS rules_stats
343
+ ON rules.id = rules_stats.rule_id
344
+ WHERE DATE(rules_stats.created_at) BETWEEN %s AND %s
345
+ GROUP BY rules.id
346
+ HAVING value>0
347
+ ORDER BY value DESC
348
+ LIMIT %d",
349
+ array( $params['from'], $params['to'], (int) $params['limit'] )
350
+ );
351
+
352
+ $top = $wpdb->get_col( $query_total );
353
+ if ( empty( $top ) ) {
354
+ return false;
355
+ }
356
+
357
+ $placeholders = array_fill( 0, count( $top ), '%d' );
358
+ $placeholders = implode( ', ', $placeholders );
359
+
360
+ $query = $wpdb->prepare(
361
+ "SELECT DATE(rules_stats.created_at) as date_rep, rules.id AS rule_id, CONCAT('#', rules.id, ' ', rules.title) AS title, SUM({$summary_field}) AS value
362
+ FROM {$table_items} AS rules LEFT JOIN {$table_stats} AS rules_stats
363
+ ON rules.id = rules_stats.rule_id
364
+ WHERE DATE(rules_stats.created_at) BETWEEN %s AND %s AND rules.id IN ({$placeholders})
365
+ GROUP BY date_rep, rule_id, title
366
+ HAVING value>0
367
+ ORDER BY value DESC",
368
+ array_merge( array( $params['from'], $params['to'] ), $top )
369
+ );
370
+
371
+ $rows = $wpdb->get_results( $query );
372
+
373
+ return $rows;
374
+ }
375
+ }
v2/App/Router.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Wdr\App;
4
+
5
+ use Wdr\App\Controllers\Admin\Settings;
6
+ use Wdr\App\Controllers\Admin\WDRAjax;
7
+ use Wdr\App\Controllers\Admin\Tabs;
8
+ use Wdr\App\Controllers\ManageDiscount;
9
+ use Wdr\App\Controllers\ShortCodeManager;
10
+
11
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
12
+
13
+ class Router
14
+ {
15
+ /**
16
+ * Contains all major class objects to manage plugin
17
+ * @var
18
+ */
19
+ public static $admin, $manage_discount, $ajax_requests, $chart_data_request, $short_code_manager;
20
+
21
+ /**
22
+ * Router constructor.
23
+ */
24
+ public function __construct()
25
+ {
26
+ self::$admin = (!empty(self::$admin)) ? self::$admin : new Settings();
27
+ self::$ajax_requests = (!empty(self::$ajax_requests)) ? self::$ajax_requests : new WDRAjax();
28
+ self::$chart_data_request = (!empty(self::$chart_data_request)) ? self::$chart_data_request : new Tabs\Statistics();
29
+ do_action('advanced_woo_discount_rules_before_initialize');
30
+ $this->init();
31
+ do_action('advanced_woo_discount_rules_after_initialize');
32
+ }
33
+
34
+ /**
35
+ *Init the plugin hooks after plugin loaded
36
+ */
37
+ function init()
38
+ {
39
+ $compatibility = Tabs\Compatible::getInstance();
40
+ $compatibility->runCompatibilityScripts();
41
+ //admin ajax requests
42
+ add_action('wp_ajax_wdr_ajax', array(self::$ajax_requests, 'wdr_ajax_requests'));
43
+ add_action('wp_ajax_awdr_get_product_discount', array(self::$ajax_requests, 'awdr_get_discount_of_a_product'));
44
+ // All hooks needed for Admin
45
+ if (is_admin() || wp_doing_ajax()) {
46
+ add_action('admin_menu', array(self::$admin, 'AddMenu'));
47
+ add_action('admin_enqueue_scripts', array(self::$admin, 'adminScripts'), 100);
48
+ add_filter('plugin_action_links_' . WDR_PLUGIN_BASENAME, array( self::$admin, 'wdr_action_link' ));
49
+ add_action('admin_notices', array(self::$admin, 'adminNotices'), 100);
50
+ add_action('wp_ajax_wdr_admin_statistics', array( self::$chart_data_request, 'ajax' ));
51
+ add_filter('woocommerce_screen_ids', function($screen_ids){
52
+ $screen_ids[] = 'woocommerce_page_woo_discount_rules';
53
+ return $screen_ids;
54
+ });
55
+ }
56
+ add_action('admin_init', array(self::$admin, 'setupSurveyForm'), 10);
57
+ /**
58
+ * All hooks needed for both admin and site
59
+ */
60
+ $manage_discount_class = self::$manage_discount = (!empty(self::$manage_discount)) ? self::$manage_discount : new ManageDiscount();
61
+ add_filter('advanced_woo_discount_rules_get_product_discount_price', array(self::$manage_discount, 'calculateProductDiscountPrice'), 100, 3);
62
+ add_filter('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', array(self::$manage_discount, 'calculateProductDiscountPrice'), 100, 5);
63
+ //Showing you saved text
64
+ $display_saving_text = $manage_discount_class::$config->getConfig('display_saving_text', 'disabled');
65
+ add_action('woocommerce_checkout_create_order_line_item', array(self::$manage_discount, 'onCreateWoocommerceOrderLineItem'), 10, 4);
66
+ if ($display_saving_text != "disabled") {
67
+ //Savings per line item
68
+ if (in_array($display_saving_text, array('on_each_line_item', 'both_line_item_and_after_total'))) {
69
+ add_action('woocommerce_after_order_itemmeta', array(self::$manage_discount, 'orderItemMetaDiscountDetails'), 1000, 3);
70
+ add_filter('woocommerce_cart_item_subtotal', array(self::$manage_discount, 'getCartProductSubtotalPriceHtml'), 10, 3);
71
+ add_filter('woocommerce_order_formatted_line_subtotal', array(self::$manage_discount, 'orderSubTotalDiscountDetails'), 1000, 3);
72
+ }
73
+ //Display total savings of order
74
+ if (in_array($display_saving_text, array('after_total', 'both_line_item_and_after_total'))) {
75
+ add_filter('woocommerce_cart_totals_order_total_html', array(self::$manage_discount, 'getCartTotalPriceHtml'), 10, 1);
76
+ add_action('woocommerce_get_formatted_order_total', array(self::$manage_discount, 'displayTotalSavingsInOrderAfterOrderTotal'), 10,2);
77
+ }
78
+ }
79
+ /**
80
+ * All hooks needed for front End
81
+ */
82
+ if (!is_admin() || wp_doing_ajax()) {
83
+ //Suppress third party plugins from modifying the price
84
+ $suppress_other_discount_plugins = $manage_discount_class::$config->getConfig('suppress_other_discount_plugins', 0);
85
+ if (!empty($suppress_other_discount_plugins)) {
86
+ add_action("wp_loaded", array(self::$manage_discount, 'suppressOtherDiscountPlugins'));
87
+ }
88
+
89
+ // Add required Styles
90
+ add_action('wp_enqueue_scripts', array(self::$manage_discount, 'loadAssets'));
91
+ add_action('wp_ajax_nopriv_wdr_ajax', array(self::$ajax_requests, 'wdr_ajax_requests'));
92
+ // Set price for catalog and single product view
93
+ add_filter('woocommerce_get_price_html', array(self::$manage_discount, 'getPriceHtml'), 100, 2);
94
+ add_filter('woocommerce_get_price_html', array(self::$manage_discount, 'getPriceHtmlSalePriceAdjustment'), 9, 2);
95
+ add_filter('woocommerce_variable_price_html', array(self::$manage_discount, 'getVariablePriceHtml'), 100, 2);
96
+
97
+ //Show on sale badge
98
+ $show_on_sale_badge = $manage_discount_class::$config->getConfig('show_on_sale_badge', 'disabled');
99
+ if (in_array($show_on_sale_badge, array('when_condition_matches', 'at_least_has_any_rules'))) {
100
+ add_filter('woocommerce_product_is_on_sale', array(self::$manage_discount, 'isProductInSale'), 100, 2);
101
+ $customize_on_sale_badge = $manage_discount_class::$config->getConfig('customize_on_sale_badge', '');
102
+ if($customize_on_sale_badge == 1){
103
+ //For changing the sale tag text
104
+ add_filter( 'woocommerce_sale_flash', array(self::$manage_discount, 'replaceSaleTagText'), 100, 3);
105
+ }
106
+ $force_override_on_sale_badge = $manage_discount_class::$config->getConfig('force_override_on_sale_badge', '');
107
+ if($force_override_on_sale_badge == 1){
108
+ add_action( "wp_loaded", array( self::$manage_discount, 'removeOnSaleFlashEvent' ) );
109
+ // change template of sale tag
110
+ add_filter('wc_get_template', array( self::$manage_discount, 'changeTemplateForSaleTag'), 10, 5);
111
+ }
112
+ }
113
+
114
+ //Fix mini cart strikeout not displays while remove an cart item in cart.
115
+ add_action('woocommerce_before_mini_cart', array(self::$manage_discount, 'reCalculateCartTotal'), 10);
116
+ //cart
117
+ add_action('woocommerce_before_calculate_totals', array(self::$manage_discount, 'applyCartProductDiscount'), 1000);
118
+ add_action('woocommerce_cart_item_price', array(self::$manage_discount, 'getCartProductPriceHtml'), 1000, 3);
119
+ add_filter('woocommerce_cart_totals_coupon_label', array(self::$manage_discount, 'overwriteCouponLabel'), 10, 2);
120
+ add_action('woocommerce_cart_calculate_fees', array(self::$manage_discount, 'applyCartDiscount'));
121
+ add_filter('woocommerce_get_shop_coupon_data', array(self::$manage_discount, 'checkCouponToApply'), 10, 2);
122
+ add_filter('woocommerce_cart_totals_coupon_html', array(self::$manage_discount, 'hideZeroCouponValue'), 10, 2);
123
+ $show_rule_message = $manage_discount_class::$config->getConfig('show_applied_rules_message_on_cart', 0);
124
+ if (!empty($show_rule_message)) {
125
+ //Show discount applied message
126
+ add_action('woocommerce_before_cart', array(self::$manage_discount, 'showAppliedRulesMessages'), 10);
127
+ add_action('woocommerce_before_checkout_form', array(self::$manage_discount, 'displayPromotionMessagesInCheckoutContainer'), 10);
128
+ add_action('woocommerce_review_order_before_cart_contents', array(self::$manage_discount, 'displayPromotionMessagesInCheckout'), 10);
129
+ }
130
+ //After place order button clicked
131
+ add_action('woocommerce_checkout_update_order_meta', array(self::$manage_discount, 'orderItemsSaved'), 10, 2);
132
+ //Showing the bulk table
133
+ $show_bulk_table = $manage_discount_class::$config->getConfig('show_bulk_table', 0);
134
+ $position_to_show_bulk_table = $manage_discount_class::$config->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form');
135
+ if (!empty($show_bulk_table)) {
136
+ add_action($position_to_show_bulk_table, array(self::$manage_discount, 'showBulkTableInPosition'));
137
+ }
138
+ $position_to_show_discount_bar = $manage_discount_class::$config->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form');
139
+
140
+ add_action($position_to_show_discount_bar, array(self::$manage_discount, 'showAdvancedTableInPosition'));
141
+
142
+ //Short code manager
143
+ self::$short_code_manager = (!empty(self::$short_code_manager)) ? self::$short_code_manager : new ShortCodeManager();
144
+ add_shortcode('awdr_sale_items_list', array(self::$short_code_manager, 'saleItemsList'));
145
+
146
+ $display_banner_text = $manage_discount_class::$config->getConfig('display_banner_text', '');
147
+ if($display_banner_text != '' && is_array($display_banner_text) && !empty($display_banner_text)){
148
+ foreach ($display_banner_text as $display_hook){
149
+ add_action($display_hook, array(self::$short_code_manager, 'bannerContent'));
150
+ }
151
+ }
152
+ add_shortcode('awdr_banner_content', array(self::$short_code_manager, 'bannerContent'));
153
+ }
154
+ }
155
+ }
v2/App/Views/Admin/Menu.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ ?>
4
+ <div class="wdr">
5
+ <div class="wdr-alert-top-right" id="notify-msg-holder"></div>
6
+ <h2 class="wdr_tabs_container nav-tab-wrapper">
7
+ <?php foreach ($tabs as $tab_key => $tab_handler) {
8
+ $params = array(
9
+ 'page' => WDR_SLUG,
10
+ 'tab' => $tab_key
11
+ );
12
+ $target = '';
13
+ $link = admin_url('admin.php?' . http_build_query($params));
14
+ if ($tab_key === 'help') {
15
+ $link = 'https://docs.flycart.org/en/collections/2195266-discount-rules-2-0?utm_source=woo-discount-rules-v2&utm_campaign=doc&utm_medium=text-click&utm_content=documentation';
16
+ $target = 'target="_blank"';
17
+ }
18
+ ?>
19
+ <a class="nav-tab <?php echo($tab_key === $current_tab ? 'nav-tab-active' : ''); ?>"
20
+ style="<?php echo ($tab_key === 'help') ? 'background: cornflowerblue;color: white;' : ''; ?>"
21
+ href="<?php echo $link; ?>" <?php echo $target; ?>><?php echo $tab_handler->title; ?></a>
22
+ <?php } ?>
23
+ <span class="awdr_version_text"> <?php echo 'v' . (defined('WDR_VERSION') ? WDR_VERSION : '2.0.0 + ') . ' ';
24
+ _e("<span style='color: #FF8C00 ; padding: 3px; border-radius: 4px'> (public beta) </span>", WDR_TEXT_DOMAIN); ?> </span>
25
+ <?php
26
+ if (isset($on_sale_page_rebuild['available']) && $on_sale_page_rebuild['available']) {
27
+ $additional_class_for_rebuild = '';
28
+ if ($on_sale_page_rebuild['required_rebuild'] === true) {
29
+ $additional_class_for_rebuild = ' need_attention';
30
+ }
31
+ ?>
32
+ <span class="awdr_rebuild_on_sale_rule_page_con<?php echo $additional_class_for_rebuild; ?>">
33
+ <button type="button" class="btn btn-danger"
34
+ id="awdr_rebuild_on_sale_list_on_rule_page"><?php esc_html_e('Rebuild index', WDR_TEXT_DOMAIN); ?></button>
35
+ </span>
36
+ <?php
37
+ }
38
+
39
+ do_action('advanced_woo_discount_rules_content_next_to_tabs');
40
+ ?>
41
+ </h2>
42
+
43
+ <div class="wdr_settings">
44
+ <div class="wdr_settings_container">
45
+ <?php
46
+ $handler->render($page);
47
+ ?>
48
+ </div>
49
+ <div class="woo_discount_loader">
50
+ <div class="lds-ripple">
51
+ <div></div><div></div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ <div class="clear"></div>
56
+ </div>
v2/App/Views/Admin/Rules/Conditions/Cart/LineItemCount.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ $operator = isset($options->operator) ? $options->operator : 'less_than';
6
+ $calculate_from = isset($options->calculate_from) ? $options->calculate_from : 'from_cart';
7
+ echo ($render_saved_condition == true) ? '' : '<div class="cart_line_items_count">';
8
+ ?>
9
+ <div class="wdr_cart_line_item_count_group wdr-condition-type-options">
10
+ <div class="wdr-cart-subtotal wdr-select-filed-hight">
11
+ <select name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][operator]" class="awdr-left-align">
12
+ <option value="less_than" <?php echo ($operator == "less_than") ? "selected" : ""; ?>><?php _e('Less than ( &lt; )', WDR_TEXT_DOMAIN) ?></option>
13
+ <option value="less_than_or_equal" <?php echo ($operator == "less_than_or_equal") ? "selected" : ""; ?>><?php _e('Less than or equal ( &lt;= )', WDR_TEXT_DOMAIN) ?></option>
14
+ <option value="greater_than_or_equal" <?php echo ($operator == "greater_than_or_equal") ? "selected" : ""; ?>><?php _e('Greater than or equal ( &gt;= )', WDR_TEXT_DOMAIN) ?></option>
15
+ <option value="greater_than" <?php echo ($operator == "greater_than") ? "selected" : ""; ?>><?php _e('Greater than ( &gt; )', WDR_TEXT_DOMAIN) ?></option>
16
+ </select>
17
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Line item count should be', WDR_TEXT_DOMAIN); ?></span>
18
+ </div>
19
+
20
+ <div class="cart-subtotal-value wdr-input-filed-hight">
21
+ <input name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][value]" type="text" class="number_only_field awdr-left-align"
22
+ value="<?php echo (isset($options->value)) ? $options->value : '' ?>" placeholder="<?php _e('1', WDR_TEXT_DOMAIN);?>">
23
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Line item count', WDR_TEXT_DOMAIN); ?></span>
24
+ </div>
25
+ <div class="cart-subtotal-methods wdr-select-filed-hight">
26
+ <select name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][calculate_from]" class="calculate_cart_from awdr-left-align">
27
+ <option value="from_cart" <?php echo ($calculate_from == "from_cart") ? "selected" : ""; ?>><?php _e('Count all items in cart', WDR_TEXT_DOMAIN) ?></option>
28
+ <option value="from_filter" <?php echo ($calculate_from == "from_filter") ? "selected" : ""; ?>><?php _e('Only count items chosen in the filters set for this rule', WDR_TEXT_DOMAIN) ?></option>
29
+ </select>
30
+ <span class="wdr_desc_text awdr-clear-both "><?php _e('How to calculate the line item count', WDR_TEXT_DOMAIN); ?></span>
31
+ </div>
32
+ </div>
33
+ <?php echo ($render_saved_condition == true) ? '' : '</div>'; ?>
v2/App/Views/Admin/Rules/Conditions/Cart/Subtotal.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ $operator = isset($options->operator) ? $options->operator : 'less_than';
6
+ $calculate_from = isset($options->calculate_from) ? $options->calculate_from : 'from_cart';
7
+ echo ($render_saved_condition == true) ? '' : '<div class="cart_subtotal">';
8
+ ?>
9
+ <div class="wdr_cart_subtotal_group wdr-condition-type-options">
10
+ <div class="wdr_cart_subtotal_group">
11
+ <div class="cart-subtotal-methods wdr-select-filed-hight">
12
+ <select name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][operator]" class="awdr-left-align">
13
+ <option value="less_than" <?php echo ($operator == "less_than") ? "selected" : ""; ?>><?php _e('Less than ( &lt; )', WDR_TEXT_DOMAIN) ?></option>
14
+ <option value="less_than_or_equal" <?php echo ($operator == "less_than_or_equal") ? "selected" : ""; ?>><?php _e('Less than or equal ( &lt;= )', WDR_TEXT_DOMAIN) ?></option>
15
+ <option value="greater_than_or_equal" <?php echo ($operator == "greater_than_or_equal") ? "selected" : ""; ?>><?php _e('Greater than or equal ( &gt;= )', WDR_TEXT_DOMAIN) ?></option>
16
+ <option value="greater_than" <?php echo ($operator == "greater_than") ? "selected" : ""; ?>><?php _e('Greater than ( &gt; )', WDR_TEXT_DOMAIN) ?></option>
17
+ </select>
18
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Subtotal should be', WDR_TEXT_DOMAIN); ?></span>
19
+ </div>
20
+
21
+ <div class="cart-subtotal-value wdr-input-filed-hight">
22
+ <input name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][value]" type="text" class="float_only_field awdr-left-align"
23
+ value="<?php echo (isset($options->value)) ? $options->value : '' ?>" placeholder="<?php _e('0.00', WDR_TEXT_DOMAIN);?>" min="0">
24
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Subtotal Amount ', WDR_TEXT_DOMAIN); ?></span>
25
+ </div>
26
+
27
+ <div class="cart-subtotal-methods wdr-select-filed-hight">
28
+ <select name="conditions[<?php echo (isset($i)) ? $i : '{i}' ?>][options][calculate_from]" class="calculate_cart_from awdr-left-align">
29
+ <option value="from_cart" <?php echo ($calculate_from == "from_cart") ? "selected" : ""; ?>><?php _e('Count all items in cart', WDR_TEXT_DOMAIN) ?></option>
30
+ <option value="from_filter" <?php echo ($calculate_from == "from_filter") ? "selected" : ""; ?>><?php _e('Only count items chosen in the filters set for this rule', WDR_TEXT_DOMAIN) ?></option>
31
+ </select>
32
+ <span class="wdr_desc_text awdr-clear-both "><?php _e('How to calculate the subtotal', WDR_TEXT_DOMAIN); ?></span>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <?php echo ($render_saved_condition == true) ? '' : '</div>'; ?>
v2/App/Views/Admin/Rules/Conditions/Main.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <div class="wdr-rule-menu">
7
+ <h2><?php _e('Rules (Optional)', WDR_TEXT_DOMAIN); ?></h2>
8
+ <div class="awdr-rules-content">
9
+ <p><?php _e('Include additional conditions (if necessary) to apply discount for product filters.', WDR_TEXT_DOMAIN); ?></p>
10
+ </div>
11
+ </div>
12
+ <div class="wdr-rule-options-con"><?php
13
+ if ($conditions = $rule->getConditions()) {
14
+ $condition_relationship = $rule->getRelationship('condition', 'and');
15
+ $wdr_product_conditions = $base->getProductConditionsTypes();?>
16
+ <!--Product Condition Start-->
17
+ <div class="wdr-condition-template">
18
+ <div class="wdr-block">
19
+ <div class="wdr-conditions-relationship">
20
+ <label><b><?php _e('Conditions Relationship ', WDR_TEXT_DOMAIN); ?></b></label>&nbsp;&nbsp;&nbsp;&nbsp;
21
+ <label><input type="radio" name="additional[condition_relationship]"
22
+ value="and" <?php echo ($condition_relationship == 'and') ? 'checked' : '' ?>
23
+ ><?php _e('Match All', WDR_TEXT_DOMAIN); ?></label>
24
+ <label><input type="radio" name="additional[condition_relationship]"
25
+ value="or" <?php echo ($condition_relationship == 'or') ? 'checked' : '' ?>><?php _e('Many Any', WDR_TEXT_DOMAIN); ?>
26
+ </label>
27
+ </div>
28
+ <div class="wdr-condition-group-items">
29
+ <div class="wdr-conditions-container wdr-condition-group" data-index="1"></div><?php
30
+ $i = 2;
31
+ $render_saved_condition = false;
32
+ foreach ($conditions as $condition) {
33
+ $type = isset($condition->type) ? $condition->type : NULL;
34
+ if (!empty($type) && isset($rule->available_conditions[$type]['object'])) {
35
+ $template = $rule->available_conditions[$type]['template'];
36
+ $extra_params = isset($rule->available_conditions[$type]['extra_params']) ? $rule->available_conditions[$type]['extra_params'] : array();
37
+ if (file_exists($template)) {
38
+ $options = isset($condition->options) ? $condition->options : array(); ?>
39
+ <div class="wdr-grid wdr-conditions-container wdr-condition-group" data-index="<?php echo $i; ?>">
40
+ <div class="wdr-condition-type">
41
+ <select name="conditions[<?php echo $i; ?>][type]"
42
+ class="wdr-product-condition-type awdr-left-align"
43
+ style="width: 100%"><?php
44
+ if (isset($wdr_product_conditions) && !empty($wdr_product_conditions)) {
45
+ foreach ($wdr_product_conditions as $wdr_condition_key => $wdr_condition_value) {
46
+ ?>
47
+ <optgroup
48
+ label="<?php _e($wdr_condition_key, WDR_TEXT_DOMAIN); ?>"><?php
49
+ foreach ($wdr_condition_value as $key => $value) {
50
+ ?>
51
+ <option
52
+ <?php
53
+ if(isset($value['enable']) && $value['enable'] === false){
54
+ ?>
55
+ disabled="disabled"
56
+ <?php
57
+ } else {
58
+ ?>
59
+ value="<?php echo $key; ?>"
60
+ <?php
61
+ }
62
+ ?>
63
+ <?php if ($key == $type) {
64
+ echo 'selected';
65
+ } ?>><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
66
+ } ?>
67
+ </optgroup><?php
68
+ }
69
+ } ?>
70
+ </select>
71
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Condition Type', WDR_TEXT_DOMAIN); ?></span>
72
+ </div><?php
73
+ extract($extra_params);
74
+ $render_saved_condition = true;
75
+ include $template;
76
+ $i++;
77
+ ?>
78
+ <div class="wdr-btn-remove" style="float: left">
79
+ <span class="dashicons dashicons-no-alt remove-current-row"></span>
80
+ </div>
81
+ </div>
82
+ <?php
83
+ }
84
+ }
85
+ } ?>
86
+ </div>
87
+ <div class="add-condition add-condition-and-filters">
88
+ <button type="button"
89
+ class="button add-product-condition"><?php _e('Add condition', WDR_TEXT_DOMAIN); ?></button>
90
+ </div>
91
+ </div>
92
+ </div><?php
93
+ } else {?>
94
+ <div class="wdr-condition-template">
95
+ <div class="wdr-block">
96
+ <div class="wdr-conditions-relationship">
97
+ <label><b><?php _e('Conditions Relationship', WDR_TEXT_DOMAIN); ?></b></label>&nbsp;&nbsp;&nbsp;&nbsp;
98
+ <label><input type="radio" name="additional[condition_relationship]"
99
+ value="and" checked><?php _e('Match All', WDR_TEXT_DOMAIN); ?></label>
100
+ <label><input type="radio" name="additional[condition_relationship]"
101
+ value="or"><?php _e('Many Any', WDR_TEXT_DOMAIN); ?>
102
+ </label>
103
+ </div>
104
+ <div class="wdr-condition-group-items">
105
+ <div class="wdr-conditions-container wdr-condition-group" data-index="1"></div>
106
+ </div>
107
+ <div class="wdp-block add-condition">
108
+ <button type="button"
109
+ class="button add-product-condition"><?php _e('Add condition', WDR_TEXT_DOMAIN); ?></button>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ <?php } ?>
114
+ <!--Product Condition End-->
115
+ <!--Rule Limit Start-->
116
+ <div class="wdr-condition-template">
117
+ <div class="wdr-block">
118
+ <div class="wdr-conditions-relationship">
119
+ <label><b><?php _e('Rule Limits', WDR_TEXT_DOMAIN); ?></b>
120
+ <span class="awdr-rule-limit-timestamp">
121
+ <?php
122
+ if(!empty($current_time)) echo sprintf(esc_html__('Current date and time: %s', WDR_TEXT_DOMAIN), '<b>' . date('Y-m-d H:i', $current_time) . '</b>'); ?>
123
+ </span>
124
+ </label>
125
+
126
+ </div>
127
+ <div class="awdr-general-settings-section">
128
+ <div class="wdr-rule-setting">
129
+ <div class="wdr-apply-to" style="float:left;"><?php
130
+ $usage_limits = $rule->getUsageLimits();?>
131
+ <select class="wdr-title" name="usage_limits">
132
+ <option value="0" <?php echo ($usage_limits == 0) ? 'selected' : ''; ?>><?php _e('Unlimited', WDR_TEXT_DOMAIN); ?></option><?php
133
+ for ($limit = 1; $limit <= 20; $limit++) {
134
+ ?>
135
+ <option
136
+ value="<?php echo $limit; ?>" <?php echo ($usage_limits == $limit) ? 'selected' : ''; ?>><?php _e($limit, WDR_TEXT_DOMAIN); ?></option><?php
137
+ } ?>
138
+ </select><span
139
+ class="wdr_desc_text"><?php _e('Maximum usage limit', WDR_TEXT_DOMAIN); ?></span>
140
+ </div>
141
+ <div class="wdr-rule-date-valid">
142
+ <div class="wdr-dateandtime-value">
143
+ <input type="text"
144
+ name="date_from"
145
+ class="wdr-condition-date wdr-title"
146
+ data-class="start_datetimeonly"
147
+ placeholder="<?php _e('Rule Vaild From', WDR_TEXT_DOMAIN); ?>"
148
+ data-field="date"
149
+ autocomplete="off"
150
+ id="rule_datetime_from"
151
+ value="<?php echo $rule->getStartDate(false, 'Y-m-d H:i'); ?>">
152
+ <span class="wdr_desc_text"><?php _e('Vaild from', WDR_TEXT_DOMAIN); ?></span>
153
+ </div>
154
+ <div class="wdr-dateandtime-value">
155
+ <input type="text"
156
+ name="date_to"
157
+ class="wdr-condition-date wdr-title"
158
+ data-class="end_datetimeonly"
159
+ placeholder="<?php _e('Rule Valid To', WDR_TEXT_DOMAIN); ?>"
160
+ data-field="date" autocomplete="off"
161
+ id="rule_datetime_to"
162
+ value="<?php echo $rule->getEndDate(false, 'Y-m-d H:i'); ?>">
163
+ <span class="wdr_desc_text"><?php _e('Vaild to', WDR_TEXT_DOMAIN); ?></span>
164
+ </div>
165
+ </div>
166
+ <?php
167
+ if (!empty($site_languages) && is_array($site_languages) && count($site_languages) > 1) {
168
+ ?>
169
+ <div class="wdr-language-value">
170
+ <select multiple
171
+ class="edit-preloaded-values"
172
+ data-list="site_languages"
173
+ data-field="preloaded"
174
+ data-placeholder="<?php _e('Select values', WDR_TEXT_DOMAIN) ?>"
175
+ name="rule_language[]"><?php
176
+ $chosen_languages = $rule->getLanguages();
177
+ foreach ($site_languages as $language_key => $name) {
178
+ if (in_array($language_key, $chosen_languages)) {
179
+ ?>
180
+ <option value="<?php echo $language_key; ?>"
181
+ selected><?php echo $name; ?></option>
182
+ <?php
183
+ }
184
+ }
185
+ ?>
186
+ </select>
187
+ <span class="wdr_desc_text"><?php _e('Language', WDR_TEXT_DOMAIN); ?></span>
188
+ </div>
189
+ <?php
190
+ } ?>
191
+ </div>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ <!--Rule Limit End-->
196
+ </div>
v2/App/Views/Admin/Rules/DiscountBatch/Main.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use Wdr\App\Helpers\Helper;
4
+
5
+ if (!defined('ABSPATH')) {
6
+ exit; // Exit if accessed directly
7
+ }
8
+ $is_pro = Helper::hasPro();
9
+ ?>
10
+ <button class="awdr-accordion <?php echo ($badge_display) ? 'awdr-accordion-active' : ''; ?>"><?php _e("Discount Bar (Optional)", WDR_TEXT_DOMAIN); ?></button>
11
+ <div class="awdr-discount-batch-container awdr-accordion-panel"
12
+ style="<?php echo ($badge_display) ? 'display: block;' : ''; ?>">
13
+ <div class="awdr-discount-batch-row">
14
+ <div class="wdr-rule-filters-and-options-con">
15
+ <div class="wdr-rule-menu">
16
+ <div class="awdr-discount-bar-content">
17
+ <p><?php _e("It helps to display discount information in product pages.", WDR_TEXT_DOMAIN); ?> <a href="https://docs.flycart.org/en/articles/3946529-discount-bar" target="_blank" ><?php _e("Read docs.", WDR_TEXT_DOMAIN); ?></a> </p>
18
+ <b><?php _e('Preview', WDR_TEXT_DOMAIN); ?></b><br><br>
19
+ <div class="awdr_admin_discount_bar awdr_row_0" style="background-color:<?php echo ($badge_bg_color) ? $badge_bg_color : '#ffffff' ?>;color:<?php echo ($badge_text_color) ? $badge_text_color : '#000000' ?>;">
20
+ <?php echo ($badge_text) ? $badge_text : 'Discount Text'; ?>
21
+ </div>
22
+ <p><b><?php _e('Note:', WDR_TEXT_DOMAIN); ?></b><?php _e('Preview contains sample result for original result see product page.', WDR_TEXT_DOMAIN); ?></p>
23
+ </div>
24
+ </div>
25
+ <div class="wdr-rule-options-con">
26
+ <div class="wdr-advanced-layout-block">
27
+ <div class="wdr-block">
28
+ <div class="wdr-row">
29
+ <div class="wdr-advanced-layout-groups">
30
+ <table class="form-table awdr-discount-badge">
31
+ <tbody style="background-color: #fff;">
32
+ <tr>
33
+ <td scope="row">
34
+ <label for=""
35
+ class="awdr-left-align"><b><?php _e('Show Discount Bar?', WDR_TEXT_DOMAIN); ?></b></label>
36
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Show/hide discount bar on product pages', WDR_TEXT_DOMAIN); ?></span>
37
+ </td>
38
+ <td>
39
+ <?php if($is_pro) { ?>
40
+ <input type="radio" name="discount_badge[display]"
41
+ id="show_applied_rules_message_on_cart"
42
+ value="1" <?php echo ($badge_display) ? 'checked' : ''; ?>><label
43
+ for="show_applied_rules_message_on_cart"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
44
+
45
+ <input type="radio"
46
+ name="discount_badge[display]" <?php echo (!$badge_display) ? 'checked' : ''; ?>
47
+ id="dont_show_applied_rules_message_on_cart" value="0"><label
48
+ for="dont_show_applied_rules_message_on_cart"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
49
+ <?php } else {
50
+ _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN);
51
+ } ?>
52
+ </td>
53
+ </tr>
54
+ <tr>
55
+ <td scope="row">
56
+ <label for=""
57
+ class="awdr-left-align"><b><?php _e('Badge Background Color', WDR_TEXT_DOMAIN); ?></b></label>
58
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Choose background color to be shown in product pages.', WDR_TEXT_DOMAIN); ?></span>
59
+ </td>
60
+ <td>
61
+ <?php if($is_pro) { ?>
62
+ <input type="color" id="badge_colorpicker"
63
+ name="discount_badge[badge_color_picker]"
64
+ pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"
65
+ value="<?php echo ($badge_bg_color) ? $badge_bg_color : '#ffffff'; ?>">
66
+ <input type="text" name="discount_badge[badge_color_picker]"
67
+ pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"
68
+ value="<?php echo ($badge_bg_color) ? $badge_bg_color : '#ffffff'; ?>"
69
+ id="badge_hexcolor" class="wdr_color_picker">
70
+ <?php } else {
71
+ _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN);
72
+ } ?>
73
+ </td>
74
+ </tr>
75
+ <tr>
76
+ <td scope="row">
77
+ <label for=""
78
+ class="awdr-left-align"><b><?php _e('Badge Text Color', WDR_TEXT_DOMAIN); ?></b></label>
79
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Choose text color to be shown in product pages.', WDR_TEXT_DOMAIN); ?></span>
80
+ </td>
81
+ <td>
82
+ <?php if($is_pro) { ?>
83
+ <input type="color" id="text_colorpicker"
84
+ name="discount_badge[badge_text_color_picker]"
85
+ pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"
86
+ value="<?php echo ($badge_text_color) ? $badge_text_color : '#000000'; ?>">
87
+ <input type="text" name="discount_badge[badge_text_color_picker]"
88
+ pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"
89
+ value="<?php echo ($badge_text_color) ? $badge_text_color : '#000000'; ?>"
90
+ id="text_hexcolor" class="wdr_color_picker">
91
+ <?php } else {
92
+ _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN);
93
+ } ?>
94
+ </td>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td scope="row">
99
+ <label for=""
100
+ class="awdr-left-align"><b><?php _e('Badge Text ', WDR_TEXT_DOMAIN); ?></b></label>
101
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Customise the text that you want to display. <br><b>Note</b> : You can also use shortcodes to show discount amount.', WDR_TEXT_DOMAIN); ?></span>
102
+ </td>
103
+ <td>
104
+ <?php if($is_pro) { ?>
105
+ <textarea
106
+ name="discount_badge[badge_text]"
107
+ class="awdr_discount_msg"
108
+ id="awdr_discount_bar_content"
109
+ rows="4"
110
+ cols="50"
111
+ placeholder="<?php _e('Discount Text', WDR_TEXT_DOMAIN); ?>"><?php echo ($badge_text) ? $badge_text : ''; ?></textarea>
112
+ <br/><span class="wdr_adv_msg_shortcode_text">
113
+ <b class="adv-msg-title">{{title}} -&gt; <?php _e(' Rule Title,', WDR_TEXT_DOMAIN); ?></b>&nbsp;&nbsp;&nbsp;&nbsp;
114
+ <?php
115
+ if(0){ //Disabled for now
116
+ ?>
117
+ <b class="adv-msg-discount">{{discount}} -&gt; <?php _e(' Discount (if percentage eg: 20% or Flat, Fixed Price eg:$20),', WDR_TEXT_DOMAIN); ?></b>&nbsp;&nbsp;&nbsp;&nbsp;
118
+ <b class="adv-msg-discount-price">{{discounted_price}} -&gt; <?php _e(' Discounted Product Price,', WDR_TEXT_DOMAIN); ?></b>&nbsp;&nbsp;&nbsp;&nbsp;
119
+ <b class="adv-msg-min-qty">{{min_quantity}} -&gt; <?php _e(' Minimum quantity (shows only for bluk and set discount range),', WDR_TEXT_DOMAIN); ?></b>&nbsp;&nbsp;&nbsp;&nbsp;
120
+ <b class="adv-msg-max-qty">{{max_quantity}} -&gt; <?php _e(' Maximum quantity (shows only for bulk discount range)', WDR_TEXT_DOMAIN); ?></b>&nbsp;&nbsp;&nbsp;&nbsp;
121
+ <?php
122
+ }
123
+ ?>
124
+ </span>
125
+ <?php } else {
126
+ _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN);
127
+ } ?>
128
+ </td>
129
+ </tr>
130
+
131
+ </tbody>
132
+ </table>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </div>
v2/App/Views/Admin/Rules/Discounts/Bulk.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
6
+ ?>
7
+ <div class="wdr-discount-group" data-index="<?php echo $bulk_index; ?>">
8
+ <div class="range_setter_inner">
9
+ <div class="bulk-row-main">
10
+ <div class="bulk-row-start wdr-input-filed-hight bulk-row-inner">
11
+ <div class="dashicons dashicons-menu awdr-sort-icon"></div>
12
+ <div class="bulk-min">
13
+ <input type="number"
14
+ name="bulk_adjustments[ranges][<?php echo $bulk_index; ?>][from]"
15
+ class="bulk_discount_min awdr_value_selector awdr_next_value"
16
+ placeholder="<?php _e('min', WDR_TEXT_DOMAIN); ?>"
17
+ min="0"
18
+ step="any"
19
+ value="<?php if (isset($range_value->from) && !empty($range_value->from)) {
20
+ echo $range_value->from;
21
+ } ?>">
22
+ <span class="wdr_desc_text"><?php _e('Minimum Quantity ', WDR_TEXT_DOMAIN); ?></span>
23
+ </div>
24
+ <div class="bulk-max">
25
+ <input type="number"
26
+ name="bulk_adjustments[ranges][<?php echo $bulk_index; ?>][to]"
27
+ class="bulk_discount_max awdr_value_selector awdr_auto_add_value"
28
+ placeholder="<?php _e('max', WDR_TEXT_DOMAIN); ?>"
29
+ min="0"
30
+ step="any"
31
+ value="<?php if (isset($range_value->to) && !empty($range_value->to)) {
32
+ echo $range_value->to;
33
+ } ?>">
34
+ <span class="wdr_desc_text"><?php _e('Maximum Quantity ', WDR_TEXT_DOMAIN); ?></span>
35
+ </div>
36
+ <div class="bulk_gen_disc_type wdr-select-filed-hight">
37
+ <select name="bulk_adjustments[ranges][<?php echo $bulk_index; ?>][type]"
38
+ class="bulk-discount-type bulk_discount_select">
39
+ <option value="percentage" <?php if (isset($range_value->type) && $range_value->type == 'percentage') {
40
+ echo 'selected';
41
+ } ?>><?php _e('Percentage discount', WDR_TEXT_DOMAIN) ?></option>
42
+ <option value="flat" <?php if (isset($range_value->type) && $range_value->type == 'flat') {
43
+ echo 'selected';
44
+ } ?>><?php _e('Fixed discount', WDR_TEXT_DOMAIN) ?></option>
45
+ <?php if($is_pro){ ?>
46
+ <option value="fixed_price" <?php if (isset($range_value->type) && $range_value->type == 'fixed_price') {
47
+ echo 'selected';
48
+ } ?>><?php _e('Fixed price for item', WDR_TEXT_DOMAIN) ?></option>
49
+ <?php } else { ?>
50
+ <option disabled><?php _e('Fixed price for item - PRO -', WDR_TEXT_DOMAIN) ?></option>
51
+ <?php } ?>
52
+ </select>
53
+ <span class="wdr_desc_text"><?php _e('Discount Type', WDR_TEXT_DOMAIN); ?></span>
54
+ </div>
55
+ <div class="bulk_amount">
56
+ <input type="number"
57
+ name="bulk_adjustments[ranges][<?php echo $bulk_index; ?>][value]"
58
+ class="bulk_discount_value bulk_value_selector awdr_value_selector"
59
+ placeholder="<?php _e('Discount', WDR_TEXT_DOMAIN); ?>"
60
+ min="0"
61
+ step="any"
62
+ value="<?php if (isset($range_value->value) && !empty($range_value->value)) {
63
+ echo $range_value->value;
64
+ } ?>">
65
+ <span class="wdr_desc_text"><?php _e('Discount Value', WDR_TEXT_DOMAIN); ?></span>
66
+ </div>
67
+ <div class="bulk_amount">
68
+ <input type="text" name="bulk_adjustments[ranges][<?php echo $bulk_index; ?>][label]"
69
+ class="bulk_value_selector awdr_value_selector"
70
+ placeholder="<?php _e('Label', WDR_TEXT_DOMAIN); ?>" min="0"
71
+ value="<?php if (isset($range_value->label) && !empty($range_value->label)) {
72
+ echo $range_value->label;
73
+ } ?>">
74
+ <span class="wdr_desc_text"><?php _e('Title column For Bulk Table', WDR_TEXT_DOMAIN); ?></span>
75
+ </div>
76
+ <div class="wdr-btn-remove">
77
+ <span class="dashicons dashicons-no-alt wdr_discount_remove" data-rmdiv="bulk_range_group"></span>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ </div>
v2/App/Views/Admin/Rules/Discounts/Cart.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
6
+ ?>
7
+ <div class="wdr_cart_discount">
8
+ <div class="wdr-discount-group" data-index="1">
9
+ <div class="wdr-cart-discount-main">
10
+ <div class="wdr-cart-discount-inner" style="padding-bottom: 10px;">
11
+ <div class="cart_discount_option wdr-select-filed-hight">
12
+ <select class="cart_free_shipping awdr-left-align"
13
+ name="cart_adjustments[type]">
14
+ <option value="percentage" <?php echo (!empty($cart_adjustment) && $cart_adjustment->type == 'percentage') ? 'selected' : ''; ?>><?php _e('Percentage discount', WDR_TEXT_DOMAIN); ?></option>
15
+ <option value="flat_in_subtotal" <?php echo (!empty($cart_adjustment) && $cart_adjustment->type == 'flat_in_subtotal') ? 'selected' : ''; ?>><?php _e('Fixed discount', WDR_TEXT_DOMAIN); ?></option>
16
+ <?php if($is_pro){ ?>
17
+ <option value="flat" <?php echo (!empty($cart_adjustment) && $cart_adjustment->type == 'flat') ? 'selected' : ''; ?>><?php _e('Fixed discount per product', WDR_TEXT_DOMAIN); ?></option>
18
+ <?php } else {
19
+ ?>
20
+ <option disabled><?php _e('Fixed discount per product -PRO-', WDR_TEXT_DOMAIN); ?></option>
21
+ <?php
22
+ }?>
23
+ </select>
24
+ <span class="wdr_desc_text awdr-clear"><?php _e('Discount Type', WDR_TEXT_DOMAIN); ?></span>
25
+ </div>
26
+ <div class="cart_discount_value wdr-input-filed-hight">
27
+ <input name="cart_adjustments[value]"
28
+ type="number"
29
+ class="cart_discount_value awdr-left-align"
30
+ value="<?php echo (isset($cart_adjustment->value)) ? $cart_adjustment->value : ''; ?>"
31
+ placeholder="0.00" min="0" step="any"
32
+ style="width: 100%;">
33
+ <span class="wdr_desc_text awdr-clear"><?php _e('Value', WDR_TEXT_DOMAIN); ?></span>
34
+ </div>
35
+ <div class="cart_discount_lable wdr-input-filed-hight">
36
+ <input name="cart_adjustments[label]"
37
+ type="text"
38
+ class="cart_discount_value awdr-left-align"
39
+ value="<?php echo (isset($cart_adjustment->label)) ? $cart_adjustment->label : ''; ?>"
40
+ placeholder="<?php _e('Discount label', WDR_TEXT_DOMAIN); ?>"
41
+ style="width: 100%;">
42
+ <span class="wdr_desc_text awdr-clear"><?php _e('Discount Label', WDR_TEXT_DOMAIN); ?></span>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ </div>
v2/App/Views/Admin/Rules/Discounts/Main.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <div class="add_bulk_range" style="display:none;">
7
+ <?php
8
+ $bulk_index = "{i}";
9
+ include 'Bulk.php';
10
+ ?>
11
+ </div>
12
+ <!-- Bulk discount Start-->
13
+ <div class="wdr_bulk_discount" style="display:none;">
14
+ <div class="wdr-simple-discount-main wdr-bulk-discount-main">
15
+ <div class="wdr-simple-discount-inner">
16
+ <div class="bulk_general_adjustment wdr-select-filed-hight">
17
+ <label class="label_font_weight"><?php _e('Count by:', WDR_TEXT_DOMAIN); ?></label>
18
+ <select name="bulk_adjustments[operator]"
19
+ class="wdr-bulk-type bulk_discount_select awdr_mode_of_operator">
20
+ <option value="product_cumulative" <?php if ($bulk_adj_operator == 'product_cumulative') {
21
+ echo 'selected';
22
+ } ?>><?php _e('Product filters together', WDR_TEXT_DOMAIN) ?></option>
23
+ <option value="product" <?php if ($bulk_adj_operator == 'product') {
24
+ echo 'selected';
25
+ } ?>><?php _e('Individual product', WDR_TEXT_DOMAIN) ?></option>
26
+ <option value="variation" <?php if ($bulk_adj_operator == 'variation') {
27
+ echo 'selected';
28
+ } ?>><?php _e('All variants in each product together', WDR_TEXT_DOMAIN) ?></option>
29
+ </select>
30
+ </div>
31
+ <div class="awdr-example"></div>
32
+ </div>
33
+ <div class="bulk_range_setter_group" >
34
+ <?php
35
+ $bulk_index = 1;
36
+ if ($bulk_adj_ranges) {
37
+ foreach ($bulk_adj_ranges as $range_value) {
38
+ include 'Bulk.php';
39
+ $bulk_index++;
40
+ }
41
+ } else {
42
+ include 'Bulk.php';
43
+ }
44
+ ?>
45
+ </div>
46
+ <div class="add-condition-and-filters awdr-discount-add-row">
47
+ <button type="button" class="button add_discount_elements"
48
+ data-discount-method="add_bulk_range"
49
+ data-next-starting-value = ".wdr-discount-group"
50
+ data-append="bulk_range_setter"><?php _e('Add Range', WDR_TEXT_DOMAIN) ?></button>
51
+ </div>
52
+ <div class="apply_discount_as_cart_section">
53
+ <div class="page__toggle apply_as_cart_checkbox">
54
+ <label class="toggle">
55
+ <input class="toggle__input apply_fee_coupon_checkbox" type="checkbox"
56
+ name="bulk_adjustments[apply_as_cart_rule]" <?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? 'checked' : '' ?> value="1">
57
+ <span class="toggle__label"><span
58
+ class="toggle__text toggle_tic"><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
59
+ </label>
60
+ </div>
61
+ <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($bulk_adj_as_cart) && !empty($bulk_adj_as_cart)) ? '' : 'display: none;' ?>">
62
+ <input name="bulk_adjustments[cart_label]"
63
+ type="text"
64
+ value="<?php echo (isset($bulk_adj_as_cart_label)) ? $bulk_adj_as_cart_label : ''; ?>"
65
+ placeholder="Discount Label">
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ <!-- Bulk discount End-->
v2/App/Views/Admin/Rules/Discounts/simple.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
6
+ ?>
7
+ <div class="wdr_simple_discount">
8
+ <div class="wdr-discount-group" data-index="{i}">
9
+ <div class="wdr-simple-discount-main">
10
+ <div class="wdr-simple-discount-inner">
11
+ <div class="simple_discount_option wdr-select-filed-hight">
12
+ <select name="product_adjustments[type]" class="product_discount_option awdr-left-align">
13
+ <option value="percentage" <?php echo (isset($product_adjustments->type) && $product_adjustments->type == 'percentage') ? 'selected' : ''; ?>><?php _e('Percentage discount', WDR_TEXT_DOMAIN); ?></option>
14
+ <option value="flat" <?php echo (isset($product_adjustments->type) && $product_adjustments->type == 'flat') ? 'selected' : ''; ?>><?php _e('Fixed discount', WDR_TEXT_DOMAIN); ?></option>
15
+ <?php if($is_pro){ ?>
16
+ <option value="fixed_price" <?php echo (isset($product_adjustments->type) && $product_adjustments->type == 'fixed_price') ? 'selected' : ''; ?>><?php _e('Fixed price per item', WDR_TEXT_DOMAIN); ?></option>
17
+ <?php } else {
18
+ ?>
19
+ <option disabled><?php _e('Fixed price per item -PRO-', WDR_TEXT_DOMAIN); ?></option>
20
+ <?php
21
+ }?>
22
+ </select>
23
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Discount Type', WDR_TEXT_DOMAIN); ?></span>
24
+ </div>
25
+ <div class="simple_discount_value wdr-input-filed-hight">
26
+ <input name="product_adjustments[value]"
27
+ type="number"
28
+ class="product_discount_value"
29
+ value="<?php echo (isset($product_adjustments->value)) ? $product_adjustments->value : ''; ?>"
30
+ placeholder="0.00" min="0" step="any" style="width: 100%;">
31
+ <span class="wdr_desc_text"><?php _e('Value', WDR_TEXT_DOMAIN); ?></span>
32
+ </div>
33
+ </div>
34
+ <div class="apply_discount_as_cart_section">
35
+ <div class="page__toggle apply_as_cart_checkbox">
36
+ <label class="toggle">
37
+ <input class="toggle__input apply_fee_coupon_checkbox" type="checkbox"
38
+ name="product_adjustments[apply_as_cart_rule]" <?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? 'checked' : '' ?> value="1">
39
+ <span class="toggle__label"><span
40
+ class="toggle__text toggle_tic"><?php _e('Show discount in cart as coupon instead of changing the product price ?', WDR_TEXT_DOMAIN); ?></span></span>
41
+ </label>
42
+ </div>
43
+ <div class="simple_discount_value wdr-input-filed-hight apply_fee_coupon_label" style="<?php echo (isset($product_adjustments->apply_as_cart_rule) && !empty($product_adjustments->apply_as_cart_rule)) ? '' : 'display: none;' ?>">
44
+ <input name="product_adjustments[cart_label]"
45
+ type="text"
46
+ value="<?php echo (isset($product_adjustments->cart_label)) ? $product_adjustments->cart_label : ''; ?>"
47
+ placeholder="Discount Label">
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
v2/App/Views/Admin/Rules/Filters/AllProducts.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <div class="all_products">
7
+ <!--<div class="all_products_group">
8
+ <div class="wdr-product_filter_method">
9
+ <select name="filters[{i}][method]" style="cursor: none;" disabled>
10
+ <option value="in_list" selected><?php /*_e('In List', WDR_TEXT_DOMAIN); */ ?></option>
11
+ <option value="not_in_list"><?php /*_e('Not In List', WDR_TEXT_DOMAIN); */ ?></option>
12
+ </select>
13
+ </div>
14
+ <div class="wdr-product-selector">
15
+ <select multiple="" class="cat_search" name="filters[{i}][value][]"
16
+ data-placeholder="Search a product…"
17
+ data-action="woocommerce_json_search_products_and_variations" tabindex="-1"
18
+ style="width: 100%; max-width: 400px; min-width: 180px;" disabled>
19
+ </select>
20
+ </div>
21
+ </div>-->
22
+ </div>
v2/App/Views/Admin/Rules/Filters/Main.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <!--Product Filter-->
7
+ <div class="wdr-filter-block" id="wdr-filter-block">
8
+ <div class="wdr-block">
9
+ <div class="wdr-row">
10
+ <div class="wdr-filter-group-items">
11
+ <input type="hidden" name="edit_rule"
12
+ value="<?php echo ($rule->getId()) ? $rule->getId() : ''; ?>"><?php
13
+ if ($rule->hasFilter()) {
14
+ $filters = $rule->getFilter();
15
+ $filter_row_count = 1;
16
+ foreach ($filters as $filter) {
17
+ ?>
18
+ <div class="wdr-grid wdr-filter-group" data-index="<?php echo $filter_row_count; ?>">
19
+ <div class="wdr-filter-type">
20
+ <select name="filters[<?php echo $filter_row_count; ?>][type]"
21
+ class="wdr-product-filter-type"><?php
22
+ if (isset($product_filters) && !empty($product_filters)) {
23
+ foreach ($product_filters as $wdr_filter_key => $wdr_filter_value) {
24
+ ?>
25
+ <optgroup label="<?php _e($wdr_filter_key, WDR_TEXT_DOMAIN); ?>" ><?php
26
+ foreach ($wdr_filter_value as $key => $value) {
27
+ ?>
28
+ <option
29
+ <?php
30
+ if(isset($value['active']) && $value['active'] == false){
31
+ ?>
32
+ disabled="disabled"
33
+ <?php
34
+ } else {
35
+ ?>
36
+ value="<?php echo $key; ?>"
37
+ <?php
38
+ }
39
+ ?>
40
+ <?php echo ($filter->type == $key) ? 'selected' : ''; ?>><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
41
+ } ?>
42
+ </optgroup><?php
43
+ }
44
+ } ?>
45
+ </select>
46
+ </div>
47
+ <?php if ($filter->type != 'all_products') {?>
48
+ <div class="products_group wdr-products_group"><?php
49
+ if(in_array($filter->type, array('products'))){
50
+ ?>
51
+ <div class="wdr-product_filter_method">
52
+ <select name="filters[<?php echo $filter_row_count; ?>][method]">
53
+ <option value="in_list"
54
+ <?php echo (isset($filter->method) && $filter->method == 'in_list') ? 'selected' : ''; ?>><?php _e('In List', WDR_TEXT_DOMAIN); ?></option>
55
+ <option value="not_in_list" <?php echo (isset($filter->method) && $filter->method == 'not_in_list') ? 'selected' : ''; ?>><?php _e('Not In List', WDR_TEXT_DOMAIN); ?></option>
56
+ </select>
57
+ </div>
58
+ <div class="awdr-product-selector">
59
+ <?php
60
+ $placeholder = '';
61
+ if (!empty($filter->value) && is_array($filter->value)) {
62
+ $item_name = '';
63
+ $selected_options = '';
64
+ foreach ($filter->value as $option) {
65
+ switch ($filter->type) {
66
+ case 'products':
67
+ $item_name = get_the_title($option);
68
+ $placeholder = 'Products';
69
+ break;
70
+ }
71
+ if (!empty($item_name)) {
72
+ $selected_options .= "<option value={$option} selected>{$item_name}</option>";
73
+ }
74
+ }
75
+ }
76
+ ?>
77
+ <select multiple
78
+ class="edit-filters"
79
+ data-list="<?php echo $filter->type; ?>"
80
+ data-field="autocomplete"
81
+ data-placeholder="<?php _e('Select ' . $placeholder, WDR_TEXT_DOMAIN); ?>"
82
+ name="filters[<?php echo $filter_row_count; ?>][value][]">
83
+ <?php echo $selected_options; ?>
84
+ </select>
85
+ </div>
86
+ <?php
87
+ }
88
+ do_action('advanced_woo_discount_rules_admin_filter_fields', $rule, $filter, $filter_row_count);
89
+ ?>
90
+ </div>
91
+ <?php } ?>
92
+ <div class="wdr-btn-remove wdr_filter_remove">
93
+ <span class="dashicons dashicons-no-alt remove-current-row wdr-filter-alert"></span>
94
+ </div><?php
95
+ switch($filter->type) {
96
+ case "products": ?>
97
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose products that get the discount using "In List". If you want to exclude a few products, choose "Not In List" and select the products you wanted to exclude from discount. (You can add multiple filters)', WDR_TEXT_DOMAIN); ?></span></div>
98
+ <?php break;
99
+ case "product_category": ?>
100
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose categories that get the discount using "In List". If you want to exclude a few categories, choose "Not In List" and select the categories you wanted to exclude from discount. (You can add multiple filters of same type)', WDR_TEXT_DOMAIN); ?></span></div>
101
+ <?php break;
102
+ case "product_attributes": ?>
103
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose attributes that get the discount using "In List". If you want to exclude a few attributes, choose "Not In List" and select the attributes you wanted to exclude from discount. (You can add multiple filters of same type)', WDR_TEXT_DOMAIN); ?></span></div>
104
+ <?php break;
105
+ case "product_tags": ?>
106
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose tags that get the discount using "In List". If you want to exclude a few tags, choose "Not In List" and select the tags you wanted to exclude from discount. (You can add multiple filters of same type)', WDR_TEXT_DOMAIN); ?></span></div>
107
+ <?php break;
108
+ case "product_sku": ?>
109
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose SKUs that get the discount using "In List". If you want to exclude a few SKUs, choose "Not In List" and select the SKUs you wanted to exclude from discount. (You can add multiple filters of same type)', WDR_TEXT_DOMAIN); ?></span></div>
110
+ <?php break;
111
+ case "product_on_sale": ?>
112
+ <div class="wdr_filter_desc_text"><span><?php _e('Choose whether you want to include (or exclude) products on sale (those having a sale price) for the discount ', WDR_TEXT_DOMAIN); ?></span></div>
113
+ <?php break;
114
+ case "all_products": ?>
115
+ <div class="wdr_filter_desc_text"><span><?php _e('Discount applies to all eligible products in the store', WDR_TEXT_DOMAIN); ?></span></div>
116
+ <?php break;
117
+ default:
118
+ ?>
119
+ <div class="wdr_filter_desc_text"><span><?php _e('Discount applies to custom taxonomy', WDR_TEXT_DOMAIN); ?></span></div>
120
+ <?php break;
121
+ }
122
+ ?>
123
+ </div>
124
+ <?php
125
+ $filter_row_count++;
126
+ }
127
+ } else { ?>
128
+ <div class="wdr-grid wdr-filter-group" data-index="1">
129
+ <div class="wdr-filter-type wdr-filter-all-product">
130
+ <select name="filters[1][type]" class="wdr-product-filter-type"><?php
131
+ if (isset($product_filters) && !empty($product_filters)) {
132
+ foreach ($product_filters as $wdr_filter_key => $wdr_filter_value) {
133
+ ?>
134
+ <optgroup label="<?php _e($wdr_filter_key, WDR_TEXT_DOMAIN); ?>"><?php
135
+ foreach ($wdr_filter_value as $key => $value) {
136
+ ?>
137
+ <option
138
+ <?php
139
+ if(isset($value['active']) && $value['active'] == false){
140
+ ?>
141
+ disabled="disabled"
142
+ <?php
143
+ } else {
144
+ ?>
145
+ value="<?php echo $key; ?>"
146
+ <?php
147
+ }
148
+ ?>
149
+ ><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
150
+ } ?>
151
+ </optgroup><?php
152
+ }
153
+ } ?>
154
+ </select>
155
+ </div>
156
+ <div class="wdr-btn-remove wdr_filter_remove">
157
+ <span class="dashicons dashicons-no-alt remove-current-row wdr-filter-alert"></span>
158
+ </div>
159
+ <div class="wdr_filter_desc_text">
160
+ <span>
161
+ <?php _e('Discount applies to all eligible products in the store', WDR_TEXT_DOMAIN); ?>
162
+ </span>
163
+ </div>
164
+ </div>
165
+ <?php
166
+ }
167
+ ?>
168
+ </div>
169
+ </div>
170
+ <div class="wdr-add-condition add-condition-and-filters">
171
+ <button type="button"
172
+ class="button add-product-filter"><?php _e('Add filter', WDR_TEXT_DOMAIN); ?></button>
173
+ </div>
174
+ </div>
175
+ </div>
176
+
v2/App/Views/Admin/Rules/Filters/Products.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <div class="products wdr-condition-type-options">
7
+ <div class="products_group wdr-products_group">
8
+ <div class="wdr-product_filter_method">
9
+ <select name="filters[{i}][method]">
10
+ <option value="in_list" selected><?php _e('In List', WDR_TEXT_DOMAIN); ?></option>
11
+ <option value="not_in_list"><?php _e('Not In List', WDR_TEXT_DOMAIN); ?></option>
12
+ <!--<option value="exclude"><?php /*_e('Exclude Product', WDR_TEXT_DOMAIN); */?></option>-->
13
+ </select>
14
+ </div>
15
+ <div class="awdr-product-selector">
16
+ <select multiple="" name="filters[{i}][value][]"
17
+ data-placeholder="<?php _e('Select Products', WDR_TEXT_DOMAIN);?>"
18
+ data-list="products"
19
+ data-field="autocomplete"
20
+ style="width: 100%; max-width: 400px; min-width: 180px;">
21
+ </select>
22
+ </div>
23
+ </div>
24
+ </div>
v2/App/Views/Admin/Rules/Manage.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ ?>
4
+ <div style="overflow:auto">
5
+ <div class="awdr-container"><br/>
6
+ <?php
7
+ $current_time = '';
8
+ if (function_exists('current_time')) {
9
+ $current_time = current_time('timestamp');
10
+ }
11
+ $rule_status = $rule->getRuleVaildStatus();
12
+ $rule_id = $rule->getId();
13
+ if ($rule_status == 'in_future') { ?>
14
+ <div class="notice inline notice notice-warning notice-alt">
15
+ <p>
16
+ <b><?php esc_html_e('This rule is not running currently: ', WDR_TEXT_DOMAIN); ?></b><?php esc_html_e(' Start date and time is set in the future date', WDR_TEXT_DOMAIN); ?>
17
+ </p>
18
+ </div><?php
19
+ } elseif ($rule_status == 'expired') {
20
+ ?>
21
+ <div class="notice inline notice notice-warning notice-alt">
22
+ <p>
23
+ <b><?php esc_html_e('This rule is not running currently: ', WDR_TEXT_DOMAIN); ?></b><?php esc_html_e(' Validity expired', WDR_TEXT_DOMAIN); ?>
24
+ </p>
25
+ </div><?php
26
+ }
27
+ /*if(isset($on_sale_page_rebuild['available']) && $on_sale_page_rebuild['available']){
28
+ $additional_class_for_rebuild = '';
29
+ if($on_sale_page_rebuild['required_rebuild'] === true){
30
+ $additional_class_for_rebuild = ' need_attention';
31
+ }
32
+ */?><!--
33
+ <div class="awdr_rebuild_on_sale_rule_page_con<?php /*echo $additional_class_for_rebuild; */?>">
34
+ <button type="button" class="btn btn-danger" id="awdr_rebuild_on_sale_list_on_rule_page"><?php /*esc_html_e('Rebuild index', WDR_TEXT_DOMAIN); */?></button>
35
+ </div>
36
+ --><?php
37
+ /* }*/
38
+ ?>
39
+
40
+ <form id="wdr-save-rule" name="rule_generator">
41
+ <div class="wdr-sticky-header" id="ruleHeader">
42
+ <div class="wdr-enable-rule">
43
+ <div class="wdr-field-title" style="width: 45%">
44
+ <input class="wdr-title" type="text" name="title" placeholder="Rule Title"
45
+ value="<?php echo esc_attr($rule->getTitle()); ?>">
46
+ </div>
47
+ <div class="page__toggle">
48
+ <label class="toggle">
49
+ <input class="toggle__input" type="checkbox"
50
+ name="enabled" <?php echo ($rule->isEnabled()) ? 'checked' : '' ?> value="1">
51
+ <span class="toggle__label"><span
52
+ class="toggle__text"><?php _e('Enable?', WDR_TEXT_DOMAIN); ?></span></span>
53
+ </label>
54
+
55
+ </div>
56
+ <div class="page__toggle">
57
+ <label class="toggle">
58
+ <input class="toggle__input" type="checkbox"
59
+ name="exclusive" <?php echo ($rule->isExclusive()) ? 'checked' : '' ?> value="1">
60
+ <span class="toggle__label"><span
61
+ class="toggle__text"><?php _e('Apply this rule if matched and ignore all other rules', WDR_TEXT_DOMAIN); ?></span></span>
62
+ </label>
63
+
64
+ </div>
65
+
66
+
67
+ <?php
68
+ if (isset($rule_id) && !empty($rule_id)) { ?>
69
+ <span class="wdr_desc_text awdr_valide_date_in_desc">
70
+ <?php esc_html_e('#Rule ID: ', WDR_TEXT_DOMAIN); ?><b><?php echo $rule_id; ?></b>
71
+ </span><?php
72
+ } ?>
73
+ <div class="awdr-common-save">
74
+ <button type="submit" class="btn btn-primary wdr_save_stay">
75
+ <?php _e('Save', WDR_TEXT_DOMAIN); ?></button>
76
+ <button type="button" class="btn btn-success wdr_save_close">
77
+ <?php _e('Save & Close', WDR_TEXT_DOMAIN); ?></button>
78
+ <a href="<?php echo admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules'))); ?>"
79
+ class="btn btn-danger" style="text-decoration: none">
80
+ <?php _e('Cancel', WDR_TEXT_DOMAIN); ?></a>
81
+ </div>
82
+ </div>
83
+ <div class="awdr_discount_type_section">
84
+ <?php
85
+ $wdr_product_discount_types = $base->getDiscountTypes();
86
+ $rule_discount_type = $rule->getRuleDiscountType();
87
+ ?>
88
+ <div class="wdr-discount-type">
89
+ <select name="discount_type" class="awdr-product-discount-type wdr-discount-type-selector"
90
+ data-placement="wdr-discount-template-placement">
91
+ <optgroup label="">
92
+ <option value="not_selected"><?php _e("Select Discount Type", WDR_TEXT_DOMAIN); ?></option>
93
+ </optgroup><?php
94
+ if (isset($wdr_product_discount_types) && !empty($wdr_product_discount_types)) {
95
+ foreach ($wdr_product_discount_types as $wdr_discount_key => $wdr_discount_value) {
96
+ ?>
97
+ <optgroup label="<?php echo $wdr_discount_key; ?>">
98
+ <?php
99
+ foreach ($wdr_discount_value as $key => $value) {
100
+ $enable_option = true;
101
+ if (isset($value['enable']) && $value['enable'] === false) {
102
+ $enable_option = false;
103
+ }
104
+ ?>
105
+ <option
106
+ <?php if ($enable_option) {
107
+ ?>
108
+ value="<?php echo $key; ?>"
109
+ <?php
110
+ } else {
111
+ ?>
112
+ disabled="disabled"
113
+ <?php
114
+ } ?>
115
+ <?php echo ($rule_discount_type && $rule_discount_type == $key) ? 'selected' : ''; ?>><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
116
+ } ?>
117
+ </optgroup><?php
118
+ }
119
+ } ?>
120
+ </select>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ <div class="awdr-hidden-new-rule" style="<?php echo (is_null($rule_id)) ? "display:none;" : "" ?>">
125
+
126
+ <!-- ------------------------Rule Filter Section Start------------------------ -->
127
+ <div class="wdr-rule-filters-and-options-con awdr-filter-section">
128
+ <div class="wdr-rule-menu">
129
+ <h2 class="awdr-filter-heading"><?php _e("Filter", WDR_TEXT_DOMAIN); ?></h2>
130
+ <div class="awdr-filter-content">
131
+ <p><?php _e("Choose which <b>gets</b> discount (products/categories/attributes/SKU and so on )", WDR_TEXT_DOMAIN); ?></p>
132
+ <p><?php _e("Note : You can also exclude products/categories.", WDR_TEXT_DOMAIN); ?></p>
133
+ </div>
134
+ </div>
135
+ <div class="wdr-rule-options-con">
136
+ <div id="wdr-save-rule" name="rule_generator">
137
+ <input type="hidden" name="action" value="wdr_ajax">
138
+ <input type="hidden" name="method" value="save_rule">
139
+ <input type="hidden" name="wdr_save_close" value="">
140
+ <div id="rule_template">
141
+ <?php include 'Filters/Main.php'; ?>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ <!-- ------------------------Rule Filter Section End-------------------------- -->
147
+
148
+ <!-- ------------------------Rule Discount Section Start---------------------- -->
149
+ <?php
150
+ //product adjustments
151
+ $product_adjustments = ($rule->getProductAdjustments()) ? $rule->getProductAdjustments() : false;
152
+ //echo "<pre>"; print_r($product_adjustments); echo "</pre>";
153
+ //cart adjustments
154
+ $cart_adjustment = $rule->getCartAdjustments();
155
+ //Bulk adjustments
156
+ if ($get_bulk_adjustments = $rule->getBulkAdjustments()) {
157
+ $bulk_adj_operator = (isset($get_bulk_adjustments->operator) && !empty($get_bulk_adjustments->operator)) ? $get_bulk_adjustments->operator : 'product_cumulative';
158
+ $bulk_adj_as_cart = (isset($get_bulk_adjustments->apply_as_cart_rule) && !empty($get_bulk_adjustments->apply_as_cart_rule)) ? $get_bulk_adjustments->apply_as_cart_rule : '';
159
+ $bulk_adj_as_cart_label = (isset($get_bulk_adjustments->cart_label) && !empty($get_bulk_adjustments->cart_label)) ? $get_bulk_adjustments->cart_label : '';
160
+ $bulk_adj_ranges = (isset($get_bulk_adjustments->ranges) && !empty($get_bulk_adjustments->ranges)) ? $get_bulk_adjustments->ranges : false;
161
+ $bulk_cat_selector = (isset($get_bulk_adjustments->selected_categories) && !empty($get_bulk_adjustments->selected_categories)) ? $get_bulk_adjustments->selected_categories : false;
162
+ } else {
163
+ $bulk_adj_operator = 'product_cumulative';
164
+ $bulk_adj_as_cart = '';
165
+ $bulk_adj_as_cart_label = '';
166
+ $bulk_adj_ranges = false;
167
+ $bulk_cat_selector = false;
168
+ }
169
+ $show_bulk_discount = $rule->showHideDiscount($bulk_adj_ranges); ?>
170
+ <div class="awdr-discount-container">
171
+ <div class="awdr-discount-row">
172
+ <div class="wdr-rule-filters-and-options-con">
173
+ <div class="wdr-rule-menu">
174
+ <h2 class="awdr-discount-heading"><?php _e("Discount", WDR_TEXT_DOMAIN); ?></h2>
175
+ <div class="awdr-discount-content">
176
+ <p><?php _e("Select discount type and its value (percentage/price/fixed price)", WDR_TEXT_DOMAIN); ?></p>
177
+ </div>
178
+ </div>
179
+ <div class="wdr-rule-options-con">
180
+ <div class="wdr-discount-template">
181
+ <div class="wdr-block wdr-discount-template-placement">
182
+ </div>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ </div>
187
+ </div>
188
+ <!-- ------------------------Rule Discount Section End------------------------ -->
189
+
190
+ <!-- ------------------------Rule Condition Section Start--------------------- -->
191
+ <div class="awdr-condition-container">
192
+ <div class="awdr-condition-row">
193
+ <div class="wdr-rule-filters-and-options-con">
194
+ <?php include 'Conditions/Main.php'; ?>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ <!-- ------------------------Rule Condition Section End----------------------- -->
199
+
200
+
201
+ <!-- ------------------------Rule Discount Batch Section Start---------------- -->
202
+ <?php
203
+ if ($rule->hasAdvancedDiscountMessage()) {
204
+ $badge_display = $rule->getAdvancedDiscountMessage('display', 0);
205
+ $badge_bg_color = $rule->getAdvancedDiscountMessage('badge_color_picker', '#ffffff');
206
+ $badge_text_color = $rule->getAdvancedDiscountMessage('badge_text_color_picker', '#000000');
207
+ $badge_text = $rule->getAdvancedDiscountMessage('badge_text');
208
+ } else {
209
+ $badge_display = false;
210
+ $badge_bg_color = '#ffffff';
211
+ $badge_text_color = '#000000';
212
+ $badge_text = false;
213
+ }
214
+ ?>
215
+ <?php include 'DiscountBatch/Main.php'; ?>
216
+ <!-- ------------------------Rule Discount Batch Section End------------------ -->
217
+
218
+ </div>
219
+ </form>
220
+ </div>
221
+ </div>
222
+ <?php include 'Discounts/Main.php'; ?>
223
+ <div class="awdr-default-template" style="display: none;">
224
+ <?php
225
+ do_action('advanced_woo_discount_rules_admin_after_load_rule_fields', $rule);
226
+ $discount_types = $base->discountElements();
227
+ foreach ($discount_types as $type => $discount_type) {
228
+ (isset($discount_type['template']) && !empty($discount_type['template'])) ? include $discount_type['template'] : '';
229
+ }
230
+ include "Others/CommonTemplates.php"; ?>
231
+ </div>
232
+
233
+
v2/App/Views/Admin/Rules/Others/CommonTemplates.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ /**
6
+ * filter selector
7
+ * condition selector
8
+ * discount selector
9
+ */
10
+ ?>
11
+
12
+ <div id="templates" style="display: none;">
13
+ <div class="wdr-icon-remove">
14
+ <div class="wdr-btn-remove wdr_filter_remove">
15
+ <span class="dashicons dashicons-no-alt remove-current-row"></span>
16
+ </div>
17
+ </div>
18
+ <?php $wdr_product_filters = $base->getProductFilterTypes(); ?>
19
+ <div class="wdr-build-filter-type">
20
+ <div class="wdr-filter-type">
21
+ <select name="filters[{i}][type]" class="wdr-product-filter-type"><?php
22
+ if (isset($wdr_product_filters) && !empty($wdr_product_filters)) {
23
+ foreach ($wdr_product_filters as $wdr_filter_key => $wdr_filter_value) {
24
+ ?>
25
+ <optgroup label="<?php echo $wdr_filter_key; ?>"><?php
26
+ foreach ($wdr_filter_value as $key => $value) {
27
+ ?>
28
+ <option
29
+ <?php
30
+ if(isset($value['active']) && $value['active'] == false){
31
+ ?>
32
+ disabled="disabled"
33
+ <?php
34
+ } else {
35
+ ?>
36
+ value="<?php echo $key; ?>"
37
+ <?php
38
+ }
39
+ ?>
40
+ <?php if ($key == 'products') {
41
+ echo 'selected';
42
+ } ?>><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
43
+ } ?>
44
+ </optgroup><?php
45
+ }
46
+ } ?>
47
+ </select>
48
+ </div>
49
+ </div>
50
+ <?php $wdr_product_filter_templates = $base->getFilterTemplatesContent();
51
+ if (isset($wdr_product_filter_templates) && !empty($wdr_product_filter_templates)) {
52
+ foreach ($wdr_product_filter_templates as $wdr_filter_template) {
53
+ echo $wdr_filter_template;
54
+ }
55
+ }
56
+ $wdr_product_conditions = $base->getProductConditionsTypes();
57
+ ?>
58
+ <div class="wdr-build-condition-type">
59
+ <div class="wdr-condition-type">
60
+ <select name="conditions[{i}][type]" class="wdr-product-condition-type awdr-left-align"><?php
61
+ if (isset($wdr_product_conditions) && !empty($wdr_product_conditions)) {
62
+ foreach ($wdr_product_conditions as $wdr_condition_key => $wdr_condition_value) {
63
+ ?>
64
+ <optgroup label="<?php echo $wdr_condition_key; ?>"><?php
65
+ foreach ($wdr_condition_value as $key => $value) {
66
+ ?>
67
+ <option
68
+ <?php
69
+ if(isset($value['enable']) && $value['enable'] === false){
70
+ ?>
71
+ disabled="disabled"
72
+ <?php
73
+ } else {
74
+ ?>
75
+ value="<?php echo $key; ?>"
76
+ <?php
77
+ }
78
+ ?>
79
+ <?php if ($key == 'products') {
80
+ echo 'selected';
81
+ } ?>><?php _e($value['label'], WDR_TEXT_DOMAIN); ?></option><?php
82
+ } ?>
83
+ </optgroup><?php
84
+ }
85
+ } ?>
86
+ </select>
87
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Condition Type', WDR_TEXT_DOMAIN); ?></span>
88
+ </div>
89
+ </div>
90
+ <?php $wdr_product_conditions_templates = $base->getConditionsTemplatesContent();
91
+ if (isset($wdr_product_conditions_templates) && !empty($wdr_product_conditions_templates)) {
92
+ foreach ($wdr_product_conditions_templates as $wdr_conditions_template) {
93
+ echo $wdr_conditions_template;
94
+ }
95
+ }?>
96
+ </div>
v2/App/Views/Admin/Tabs/DiscountRule.php ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+
4
+ $rules_count = count($rules);
5
+ $is_pro = \Wdr\App\Helpers\Helper::hasPro();
6
+ ?>
7
+ <br>
8
+ <div id="wpbody-content" class="awdr-container">
9
+ <div class="" style ="<?php if(!$is_pro){ echo "width: 71%; float: left;"; }?>" >
10
+ <div class="col-md-6 col-lg-6 text-left awdr-list-header-btn" <?php if(!$is_pro){ echo 'style="width:100%; float: left"'; }?>>
11
+ <h1 class="wp-heading-inline"><?php _e('Discount Rules', WDR_TEXT_DOMAIN); ?></h1>
12
+ <a href="<?php echo admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'create'))); ?>"
13
+ class="btn btn-primary"><?php _e('Add New Rule', WDR_TEXT_DOMAIN); ?></a>
14
+ <?php if($has_migration == true) {
15
+ ?>
16
+ <a class="wdr-popup-link btn btn-primary"><span class="modal-trigger" data-modal="wdr_migration_popup"><?php _e("Migrate rules from v1", WDR_TEXT_DOMAIN); ?></a>
17
+
18
+ <div class="modal" id="wdr_migration_popup">
19
+ <div class="modal-sandbox"></div>
20
+ <div class="modal-box">
21
+ <div class="modal-header">
22
+ <div class="close-modal"><span class="wdr-close-modal-box">&#10006;</span></div>
23
+ <h1 class="wdr-modal-header-title"><?php _e("Migration", WDR_TEXT_DOMAIN); ?></h1>
24
+ </div>
25
+ <div class="modal-body">
26
+ <h2 class="wdr_tabs_container nav-tab-wrapper">
27
+ <?php esc_html_e('Migrate rules from v1 to v2', WDR_TEXT_DOMAIN); ?>
28
+ </h2>
29
+ <div class="wdr_migration_text_con">
30
+ <p>
31
+ <b><?php esc_html_e('Available price rules', WDR_TEXT_DOMAIN); ?>:</b> <?php echo isset($migration_rule_count['price_rules'])? $migration_rule_count['price_rules']: 0;?>
32
+ </p>
33
+ <p>
34
+ <b><?php esc_html_e('Available cart rules', WDR_TEXT_DOMAIN); ?>:</b> <?php echo isset($migration_rule_count['cart_rules'])? $migration_rule_count['cart_rules']: 0?>
35
+ </p>
36
+ <p>
37
+ <?php _e('Once migration is completed, please open the rules and check their configuration once again to make sure it meets your discount scenario. If required, please adjust the rule configuration. If you need any help, just open a ticket at <a href="https://www.flycart.org/support" target="_blank">https://www.flycart.org/support</a>', WDR_TEXT_DOMAIN); ?>
38
+ </p>
39
+ </div>
40
+ <div class="wdr_settings">
41
+ <div class="wdr_migration_container">
42
+ <button class="btn btn-primary" type="button" id="awdr_do_v1_v2_migration"><?php esc_html_e('Migrate', WDR_TEXT_DOMAIN); ?></button>
43
+ <span class="close-modal"><button class="btn btn-warning wdr-close-modal-box" type="button"><?php esc_html_e('Skip', WDR_TEXT_DOMAIN); ?></button></span>
44
+ <div class="wdr_migration_process">
45
+ </div>
46
+ <div class="wdr_migration_process_status">
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <?php
54
+ }?>
55
+ <a href="https://docs.flycart.org/en/collections/2195266-discount-rules-2-0?utm_source=woo-discount-rules-v2&utm_campaign=doc&utm_medium=text-click&utm_content=examples#commonly-asked-scenarios" target="_blank"
56
+ class="btn btn-info text-right" style="float: right"><?php _e('View Examples', WDR_TEXT_DOMAIN); ?></a>
57
+ <a href="https://docs.flycart.org/en/collections/2195266-discount-rules-2-0?utm_source=woo-discount-rules-v2&utm_campaign=doc&utm_medium=text-click&utm_content=documentation" target="_blank"
58
+ class="btn btn-info text-right" style="float: right"><?php _e('Documentation', WDR_TEXT_DOMAIN); ?></a>
59
+ </div>
60
+
61
+ <br/>
62
+ <form id="wdr-search-top" method="get" style="display: none">
63
+ <input type="hidden" name="adminUrl"
64
+ value="<?php echo admin_url('admin.php?page=woo_discount_rules'); ?>">
65
+ <input type="hidden" name="name" value="" class="wdr-rule-search-key">
66
+ <input type="submit" class="button" class="wdr-trigger-search-key"
67
+ value="<?php _e('Search Rules', WDR_TEXT_DOMAIN); ?>">
68
+ </form>
69
+ <form id="wdr-bulk-action-top" method="post">
70
+ <div class="tablenav top">
71
+ <div class="alignleft actions bulkactions">
72
+ <label for="bulk-action-selector-top"
73
+ class="screen-reader-text"><?php _e('Search Rules', WDR_TEXT_DOMAIN); ?></label>
74
+ <select name="wdr_bulk_action" id="bulk-action-selector-top">
75
+ <option value="-1"><?php _e('Bulk Actions', WDR_TEXT_DOMAIN); ?></option>
76
+ <option value="enable"><?php _e('Enable', WDR_TEXT_DOMAIN); ?></option>
77
+ <option value="disable"><?php _e('Disable', WDR_TEXT_DOMAIN); ?></option>
78
+ <option value="delete"><?php _e('Delete', WDR_TEXT_DOMAIN); ?></option>
79
+ </select>
80
+ <input type="submit" id="doaction" class="button action" value="<?php _e('Apply', WDR_TEXT_DOMAIN);?>">
81
+ <input type="search" name="awdr-hidden-name" class="awdr-hidden-name" value="<?php echo $input->get('name'); ?>">
82
+ <input type="button" class="button awdr-hidden-search"
83
+ value="<?php _e('Search Rules', WDR_TEXT_DOMAIN); ?>">
84
+ </div>
85
+ <div class="tablenav-pages one-page">
86
+ <span class="displaying-num"><?php echo $rules_count . ' ';
87
+ ($rules_count == 0 || $rules_count == 1) ? _e('item', WDR_TEXT_DOMAIN) : _e('items', WDR_TEXT_DOMAIN); ?></span>
88
+ </div>
89
+ <br class="clear">
90
+ </div>
91
+
92
+ <table class="wp-list-table widefat fixed posts">
93
+ <thead>
94
+ <tr>
95
+ <td id="cb" class="manage-column column-cb check-column">
96
+ </td>
97
+ <td id="cb" class="manage-column column-cb check-column">
98
+ <input name="bulk_check[]" class="wdr-rules-select" type="checkbox" value="off"/>
99
+ </td>
100
+
101
+ <th scope="col" id="title" class="manage-column column-title column-primary sortable desc">
102
+ <a href="javascript:void(0);">
103
+ <span><?php _e('Title', WDR_TEXT_DOMAIN); ?></span>
104
+ <span class="sorting-indicator"></span>
105
+ </a>
106
+ </th>
107
+ <th scope="col" id="author"
108
+ class="manage-column column-author"><?php _e('Start Date', WDR_TEXT_DOMAIN); ?></th>
109
+ <th scope="col" id="tags"
110
+ class="manage-column column-tags"><?php _e('Expired On', WDR_TEXT_DOMAIN); ?></th>
111
+ <?php
112
+ if (count($site_languages) > 1) {
113
+ ?>
114
+ <th scope="col" id="tags"
115
+ class="manage-column column-tags"><?php _e('Language(s)', WDR_TEXT_DOMAIN); ?></th>
116
+ <?php
117
+ }
118
+ ?>
119
+ <!--<th scope="col" id="tags" class="manage-column column-tags">
120
+ <?php /*_e('Priority',WDR_TEXT_DOMAIN) */?>
121
+ </th>-->
122
+ <th scope="col" id="status"
123
+ class="manage-column column-tags"><?php _e('Status', WDR_TEXT_DOMAIN); ?></th>
124
+ <th scope="col" id="title"
125
+ class="manage-column column-title"><?php _e('Action', WDR_TEXT_DOMAIN); ?></th>
126
+ </tr>
127
+ </thead>
128
+ <tbody class="wdr-ruleboard" id="sortable"><?php
129
+ if ($rules) {
130
+ foreach ($rules as $rule_row) { ?>
131
+ <tr id="<?php echo $rule_row->getId(); ?>" class="awdr-listing-rule-tr">
132
+ <th scope="row" class="check-column awdr-listing-rule-check-box-align">
133
+ <span class="dashicons dashicons-menu" style="padding-left: 5px;"></span>
134
+ </th>
135
+ <th scope="row" class="check-column awdr-listing-rule-check-box-align">
136
+ <input id="cb-select-<?php echo $rule_row->getId(); ?>" class="wdr-rules-selector"
137
+ type="checkbox" name="saved_rules[]"
138
+ value="<?php echo $rule_row->getId(); ?>">
139
+ </th>
140
+ <td class="title column-title has-row-actions column-primary page-title"
141
+ data-colname="Title">
142
+ <strong>
143
+ <a class="row-title"
144
+ href="<?php echo admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_row->getId()))); ?>"
145
+ aria-label="“<?php echo $rule_row->getTitle(); ?>” (Edit)"><?php echo $rule_row->getTitle();
146
+ if($rule_row->isExclusive()) {?>
147
+ <span class="awdr-exclusive-disable-listing"><?php _e('Exclusive', WDR_TEXT_DOMAIN); ?></span> <?php
148
+ }?></a>
149
+ </strong>
150
+ </td>
151
+ <td class="author column-author" data-colname="Author"><?php
152
+ $get_start_date = $rule_row->getStartDate($timestamp = false, $format = "Y-m-d H:i");
153
+ ?>
154
+ <abbr><?php echo is_null($get_start_date) ? '-' : $get_start_date; ?></abbr>
155
+ </td>
156
+ <td class="date column-date" data-colname="Date"><?php
157
+ $get_end_date = $rule_row->getEndDate($timestamp = false, $format = "Y-m-d H:i");
158
+ ?>
159
+ <abbr><?php echo is_null($get_end_date) ? '-' : $get_end_date; ?></abbr>
160
+ </td>
161
+ <?php
162
+ if (count($site_languages) > 1) {
163
+ ?>
164
+ <td>
165
+ <?php
166
+ $chosen_languages = $rule_row->getLanguages();
167
+ if (!empty($chosen_languages)) {
168
+ $i = 1;
169
+ foreach ($chosen_languages as $language) {
170
+ echo isset($site_languages[$language]) ? $site_languages[$language] : '';
171
+ if (count($chosen_languages) > $i) {
172
+ echo ', ';
173
+ }
174
+ $i++;
175
+ }
176
+ } else {
177
+ echo '-';
178
+ }
179
+ ?>
180
+ </td>
181
+ <?php
182
+ }
183
+ ?>
184
+ <!-- <td></td>-->
185
+ <td class="date column-tag" data-colname="wdr-rule-status">
186
+ <label class="switch switch-left-right">
187
+ <input class="switch-input wdr_manage_status" name="toogle_action" type="checkbox" data-manage-status="<?php echo $rule_row->getId(); ?>" <?php echo ($rule_row->isEnabled()) ? 'checked' : '';?>/>
188
+ <span class="switch-label" data-on="<?php _e('Enabled', WDR_TEXT_DOMAIN); ?>" data-off="<?php _e('Disabled', WDR_TEXT_DOMAIN); ?>"></span>
189
+ <span class="switch-handle"></span>
190
+ </label>
191
+ <span class="awdr-enabled-status" style="<?php echo (!$rule_row->isEnabled()) ? 'display:none' : '';?>">
192
+ <?php
193
+ $rule_status = $rule_row->getRuleVaildStatus();
194
+ $current_time_stamp = current_time('timestamp');
195
+ $current_time = $rule_row->formatDate($current_time_stamp, $format = "Y-m-d H:i", false);
196
+ if($rule_status == 'in_future'){?>
197
+ <span class="awdr-listing-status-text"><?php _e(' - ( Will run in future)', WDR_TEXT_DOMAIN);?></span><br><?php
198
+ if(isset($current_time) && !empty($current_time)) {
199
+ ?>
200
+ <span class="awdr-text-warning"><b><?php _e('Your server current date and time:', WDR_TEXT_DOMAIN);?> </b><?php echo $current_time; ?>
201
+ </span><?php
202
+ }
203
+
204
+ }elseif ($rule_status == 'expired'){?>
205
+ <span class="awdr-listing-status-text"><?php _e(' - ( Not running - validity expired)', WDR_TEXT_DOMAIN);?></span><br><?php
206
+ if(isset($current_time) && !empty($current_time)) {
207
+ ?>
208
+ <span class="awdr-text-warning"><b><?php _e('Your server current date and time:', WDR_TEXT_DOMAIN);?> </b><?php echo $current_time; ?>
209
+ </span><?php
210
+ }
211
+ }else{?>
212
+ <span class="awdr-listing-status-text"><?php _e(' - (Running)', WDR_TEXT_DOMAIN);?></span><?php
213
+ }?>
214
+ </span>
215
+ </td>
216
+ <td>
217
+ <a class="btn btn-primary"
218
+ href="<?php echo admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_row->getId()))); ?>">
219
+ <?php _e('Edit', WDR_TEXT_DOMAIN); ?></a>
220
+ <a class="btn btn-primary wdr_duplicate_rule"
221
+ data-duplicate-rule="<?php echo $rule_row->getId(); ?>"><?php _e('Duplicate', WDR_TEXT_DOMAIN); ?></a>
222
+ <a class="btn btn-danger wdr_delete_rule"
223
+ data-delete-rule="<?php echo $rule_row->getId(); ?>">
224
+ <?php _e('Delete', WDR_TEXT_DOMAIN); ?></a>
225
+ </td>
226
+ </tr>
227
+
228
+ <?php
229
+ }
230
+ } else {
231
+ ?>
232
+ <tr class="no-items">
233
+ <td></td>
234
+ <td></td>
235
+ <td class="colspanchange" colspan="2"><?php _e('No rules found.', WDR_TEXT_DOMAIN);?></td>
236
+ </tr>
237
+ <?php } ?>
238
+ </tbody>
239
+ <tfoot>
240
+ <tr>
241
+ <td class="manage-column column-cb check-column">
242
+ </td>
243
+ <td class="manage-column column-cb check-column">
244
+ <input name="bulk_check[]" class="wdr-rules-select" type="checkbox" value="off"/>
245
+ </td>
246
+ <th scope="col" id="title" class="manage-column column-title column-primary sortable desc">
247
+ <a href="javascript:void(0);">
248
+ <span><?php _e('Title', WDR_TEXT_DOMAIN); ?></span>
249
+ <span class="sorting-indicator"></span>
250
+ </a>
251
+ </th>
252
+ <th scope="col" id="author"
253
+ class="manage-column column-author"><?php _e('Start Date', WDR_TEXT_DOMAIN); ?></th>
254
+ <th scope="col" id="tags"
255
+ class="manage-column column-tags"><?php _e('Expired On', WDR_TEXT_DOMAIN); ?></th>
256
+ <?php
257
+ if (count($site_languages) > 1) {
258
+ ?>
259
+ <th scope="col" id="tags"
260
+ class="manage-column column-tags"><?php _e('Language(s)', WDR_TEXT_DOMAIN); ?></th>
261
+ <?php
262
+ }
263
+ ?>
264
+ <!--<th scope="col" id="tags" class="manage-column column-tags">
265
+ <?php /*_e('Priority',WDR_TEXT_DOMAIN) */?>
266
+ </th>-->
267
+ <th scope="col" id="status"
268
+ class="manage-column column-tags"><?php _e('Status', WDR_TEXT_DOMAIN); ?></th>
269
+ <th scope="col" id="title"
270
+ class="manage-column column-title"><?php _e('Action', WDR_TEXT_DOMAIN); ?></th>
271
+ </tr>
272
+ </tfoot>
273
+ </table>
274
+
275
+
276
+ <div class="tablenav bottom">
277
+ <div class="alignleft actions bulkactions">
278
+ <!-- <label for="bulk-action-selector-bottom" class="screen-reader-text">Select bulk
279
+ action</label><select name="action2" id="bulk-action-selector-bottom">
280
+ <option value="-1">Bulk Actions</option>
281
+ <option value="edit" class="hide-if-no-js">Edit</option>
282
+ <option value="trash">Move to Trash</option>
283
+ </select>
284
+ <input type="submit" id="doaction2" class="button action" value="Apply">-->
285
+ </div>
286
+ <div class="alignleft actions">
287
+ </div>
288
+ <div class="tablenav-pages one-page"><span class="displaying-num"><?php echo $rules_count . ' ';
289
+ ($rules_count == 0 || $rules_count == 1) ? _e('item', WDR_TEXT_DOMAIN) : _e('items', WDR_TEXT_DOMAIN); ?></span></span>
290
+ </div>
291
+ <br class="clear">
292
+ </div>
293
+ <input type="hidden" name="action" value="wdr_ajax">
294
+ <input type="hidden" name="method" value="bulk_action">
295
+ <input type="hidden" name="adminUrl" value="<?php echo admin_url('admin.php?page=woo_discount_rules') ?>">
296
+ </form>
297
+ <br class="clear">
298
+ </div>
299
+ <?php
300
+ if(!$is_pro){ ?>
301
+ <div class="col-md-6 col-lg-6 text-right" style="width: 27%; float: right;">
302
+ <div class="col-md-12">
303
+ <a href="https://www.flycart.org/products/wordpress/woocommerce-discount-rules?utm_source=wpwoodiscountrules&utm_medium=plugin&utm_campaign=inline&utm_content=woo-discount-rules" target="_blank" class="btn btn-success"><?php esc_html_e('Looking for more features? Upgrade to PRO', WDR_TEXT_DOMAIN); ?></a>
304
+ </div>
305
+ <div class="woo-side-panel">
306
+ <div class="panel">
307
+ <div class="panel-body">
308
+ <h3><?php esc_html_e('With PRO version, you can create:', WDR_TEXT_DOMAIN)?></h3>
309
+ <p><?php esc_html_e('- Categories based discounts', WDR_TEXT_DOMAIN)?></p>
310
+ <p><?php esc_html_e('- User roles based discounts', WDR_TEXT_DOMAIN)?></p>
311
+ <p><?php esc_html_e('- Buy One Get One Free deals', WDR_TEXT_DOMAIN)?></p>
312
+ <p><?php esc_html_e('- Buy X Get Y deals', WDR_TEXT_DOMAIN)?></p>
313
+ <p><?php esc_html_e('- Buy 2, get 1 at 50% discount', WDR_TEXT_DOMAIN)?></p>
314
+ <p><?php esc_html_e('- Buy 3 for $10 (Package / Bundle [Set] Discount)', WDR_TEXT_DOMAIN)?></p>
315
+ <p><?php esc_html_e('- Different discounts with one coupon code', WDR_TEXT_DOMAIN)?></p>
316
+ <p><?php esc_html_e('- Purchase history based discounts', WDR_TEXT_DOMAIN)?></p>
317
+ <p><?php esc_html_e('- Free product / gift', WDR_TEXT_DOMAIN)?></p>
318
+ <p><?php esc_html_e('- Discount for variants', WDR_TEXT_DOMAIN)?></p>
319
+ <p><?php esc_html_e('- Conditional discounts', WDR_TEXT_DOMAIN)?></p>
320
+ <p><?php esc_html_e('- Fixed cost discounts', WDR_TEXT_DOMAIN)?></p>
321
+ <p><?php esc_html_e('- Offer fixed price on certain conditions', WDR_TEXT_DOMAIN)?></p>
322
+ <p><a href="https://www.flycart.org/products/wordpress/woocommerce-discount-rules?utm_source=wpwoodiscountrules&amp;utm_medium=plugin&amp;utm_campaign=inline&amp;utm_content=woo-discount-rules" class="btn btn-success" target="_blank"><?php esc_html_e('Go PRO', WDR_TEXT_DOMAIN); ?></a></p>
323
+ </div>
324
+ </div>
325
+ </div>
326
+ </div>
327
+ <?php } ?>
328
+ </div>
v2/App/Views/Admin/Tabs/ImportExport.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+
4
+ function forceDownloadFile($filepath)
5
+ {
6
+ header('Location: ' . $filepath);
7
+ return true;
8
+ } ?>
9
+ <br>
10
+ <div class="wdr_settings ui-page-theme-a awdr-container">
11
+ <div class="wdr_settings_container">
12
+ <div>
13
+ <h3><?php _e('Export tool', WDR_TEXT_DOMAIN);?></h3>
14
+ <div>
15
+ <p>
16
+ <!--<select id="wdr-export-select">
17
+ <optgroup label="Rules">
18
+ <option value="all">All Rules</option>
19
+ </optgroup>
20
+ <optgroup label="Rule Title"><?php
21
+ /* $json_array = array();
22
+ if($rules){
23
+ $rule_items = array();
24
+ foreach ($rules as $rule_row) {*/ ?>
25
+ <option value="<?php /*echo $rule_row->id; */ ?>"><?php /*echo $rule_row->title; */ ?></option><?php
26
+ /* $rule_items[] = $rule_row;
27
+ }
28
+ }*/ ?>
29
+ </optgroup>
30
+ </select>--><?php
31
+ if (isset($_POST['wdr-export'])) {
32
+ $file_name = 'advanced-discount-rules-' . date("Y-m-d-h-i-a") . '.csv';
33
+ if (!file_exists(WDR_PLUGIN_PATH . 'Export')) {
34
+ mkdir(WDR_PLUGIN_PATH . 'Export', 0777, true);
35
+ }
36
+ $file_path = WDR_PLUGIN_PATH . 'Export/' . $file_name;
37
+ $file = fopen($file_path, "w");
38
+ fputcsv($file, array('id', 'enabled', 'deleted', 'exclusive', 'title', 'priority', 'apply_to', 'filters', 'conditions', 'product_adjustments', 'cart_adjustments', 'buy_x_get_x_adjustments', 'buy_x_get_y_adjustments', 'bulk_adjustments', 'set_adjustments', 'other_discounts', 'date_from', 'date_to', 'usage_limits', 'rule_language', 'used_limits', 'additional', 'max_discount_sum', 'advanced_discount_message', 'discount_type', 'used_coupons'));
39
+ foreach ($rules as $rule_row) {
40
+ $row_data = (array)$rule_row;
41
+ fputcsv($file, $row_data);
42
+ }
43
+ fclose($file);
44
+
45
+ $filepath = WDR_PLUGIN_URL . 'Export/' . $file_name;
46
+ $rm_dir = WDR_PLUGIN_PATH . 'Export';
47
+ if (forceDownloadFile($filepath)) {
48
+ rmdir(WDR_PLUGIN_PATH . 'Export');
49
+ }
50
+ }
51
+ ?>
52
+ <form method="post">
53
+ <button type="submit" id="wdr-export" name="wdr-export" class="button button-primary">
54
+ <?php _e('Export', WDR_TEXT_DOMAIN);?>
55
+ </button>
56
+ </form>
57
+ </p>
58
+
59
+ </div>
60
+ </div><?php
61
+ /* if (isset($_POST['wdr_import'])) {
62
+
63
+ if (isset($_FILES["import_rules"]["name"]) && !empty($_FILES["import_rules"]["name"])) {
64
+ $file_name = $_FILES["import_rules"]["name"];
65
+ $ext_info = new SplFileInfo($file_name);
66
+ if ($ext_info->getExtension() == 'csv') {
67
+ $file = fopen($_FILES['import_rules']['tmp_name'], "r");
68
+ if( $file !== FALSE ){
69
+ while($csv_row = fgetcsv($file, 1000, ",")) {
70
+ $rule_helper = new \Wdr\App\Helpers\Rule();
71
+ $rule_helper->importCsvRules($csv_row, $this->input->post('wdp_import_data_reset_rules'));
72
+ }
73
+ }
74
+ fclose($file);
75
+ } else {
76
+ echo "Error: Please Upload only CSV File";
77
+ }
78
+ }
79
+ }
80
+ */?>
81
+ <!--<form method="post" enctype="multipart/form-data">
82
+ <div>
83
+ <h3>Import tool</h3>
84
+ <div>
85
+ <div>
86
+ <p>
87
+ <input type="file" name="import_rules"/>
88
+ </p>
89
+ <input type="hidden" name="wdp_import_data_reset_rules" value="0">
90
+ <input type="checkbox" name="wdp_import_data_reset_rules" value="1">
91
+ <label for="wdp-import-data-reset-rules">
92
+ Clear all rules before import </label>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ <p>
97
+ <button type="submit" id="wdr-import" name="wdr_import" class="button button-primary">
98
+ Import
99
+ </button>
100
+ </p>
101
+ </form>-->
102
+
103
+ </div>
104
+ </div>
v2/App/Views/Admin/Tabs/Statistics.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <style>
7
+ .chart-options select {
8
+ vertical-align: inherit;
9
+ }
10
+
11
+ .chart-options .chart-period-start,
12
+ .chart-options .chart-period-end {
13
+ padding: 4px 8px;
14
+ }
15
+
16
+ .chart-tooltip {
17
+ position: absolute;
18
+ }
19
+
20
+ .chart-placeholder {
21
+ margin-right: 50px;
22
+ height: 400px;
23
+ }
24
+
25
+ .chart-placeholder.loading:after {
26
+ position: absolute;
27
+ width: 100%;
28
+ height: 100%;
29
+ background: rgba(255, 255, 255, .6);
30
+ content: '';
31
+ }
32
+ </style>
33
+ <br>
34
+ <div id="wpbody-content" class="awdr-container">
35
+ <form method="post" name="wdr-statistics" class="chart-options">
36
+ <div class="wdr-rule-statistics">
37
+ <div class="statistics_date_range">
38
+ <select name="period" class="chart-period" style="height: 33px">
39
+ <option value="this_week"><?php _e('This Week', WDR_TEXT_DOMAIN); ?></option>
40
+ <option value="this_month"><?php _e('This Month', WDR_TEXT_DOMAIN); ?></option>
41
+ <option value="custom"><?php _e('Custom Range', WDR_TEXT_DOMAIN); ?></option>
42
+ </select>
43
+ </div>
44
+ <div class="wdr-dateandtime-value">
45
+ <input type="text"
46
+ name="from"
47
+ class="wdr-condition-date wdr-title chart-period-start" data-class="start_dateonly"
48
+ placeholder="<?php _e('From: yyyy/mm/dd', WDR_TEXT_DOMAIN); ?>" data-field="date"
49
+ autocomplete="off"
50
+ id="rule_datetime_from" value="<?php if (isset($date[0]) && !empty($date[0])) {
51
+ echo $date[0];
52
+ } ?>" style="height: 34px;">
53
+ <!--<span class="wdr_desc_text"><?php /*_e('Vaild from', WDR_TEXT_DOMAIN); */ ?></span>-->
54
+ </div>
55
+ <div class="wdr-dateandtime-value">
56
+ <input type="text"
57
+ name="to"
58
+ class="wdr-condition-date wdr-title chart-period-end" data-class="end_dateonly"
59
+ placeholder="<?php _e('To: yyyy/mm/dd', WDR_TEXT_DOMAIN); ?>"
60
+ data-field="date" autocomplete="off"
61
+ id="rule_datetime_to" value="<?php if (isset($date[1]) && !empty($date[1])) {
62
+ echo $date[1];
63
+ } ?>" style="height: 34px;">
64
+ <!--<span class="wdr_desc_text"><?php /*_e('Vaild to', WDR_TEXT_DOMAIN); */ ?></span>-->
65
+ </div>
66
+ <div class="">
67
+ <select name="type" class="chart-type" style="height: 33px">
68
+ <?php foreach ( $charts as $group => $charts_by_group ): ?>
69
+ <optgroup label="<?php echo $group ?>">
70
+ <?php foreach ( $charts_by_group as $key => $name ): ?>
71
+ <option value="<?php echo $key ?>"><?php echo $name ?></option>
72
+ <?php endforeach; ?>
73
+ </optgroup>
74
+ <?php endforeach; ?>
75
+ </select>
76
+ </div>
77
+
78
+ <div class="">
79
+ <button type="submit" class="btn btn-success"><?php _e('Update Chart', WDR_TEXT_DOMAIN); ?></button>
80
+ </div>
81
+ </div>
82
+ </form>
83
+ <br/>
84
+ <div id="chart-container"></div>
85
+ <div class="clear"></div>
86
+ </div>
v2/App/Views/Admin/Tabs/compatible.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <br>
7
+
8
+ <div id="wpbody-content" class="awdr-container">
9
+ <div class="awdr-compatible-form">
10
+ <form name="compatible_form" id="compatible-form" method="post">
11
+ <?php $has_compatibility_plugin = false; ?>
12
+ <h1><?php _e('Compatibility for Woo Discount Rules', WDR_TEXT_DOMAIN) ?></h1>
13
+ <div class="awdr-compatible-field-container">
14
+ <?php
15
+ $base->loadFields($has_compatibility_plugin);
16
+ ?>
17
+ </div>
18
+ <?php
19
+ if($has_compatibility_plugin){
20
+ ?>
21
+ <div class="save-configuration">
22
+ <p class="submit">
23
+ <button type="submit" name="awdr_compatibility_submit" id="submit" class="button button-primary save-compatibility-submit"
24
+ value="1"><?php esc_html_e('Save Changes', WDR_TEXT_DOMAIN); ?></button></p>
25
+ </div>
26
+ <?php
27
+ } else{
28
+ ?>
29
+ <div class="">
30
+ <?php esc_html_e('This section lists plugins that require a compatibility with discount rules to resolve conflicts.
31
+ Please tick them (by checking the box) and then save. This will help discount rules to run smoothly along with these plugins', WDR_TEXT_DOMAIN); ?>
32
+ </div>
33
+ <?php
34
+ }
35
+ ?>
36
+ </form>
37
+ </div>
38
+ <div class="clear"></div>
39
+ </div>
40
+
41
+
42
+
43
+
44
+
v2/App/Views/Admin/Tabs/help.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <div class="container-fluid woo_discount_loader_outer awdr-container">
7
+ <div class="row-fluid">
8
+ <div class="col-md-12">
9
+ <div class="row form-group">
10
+ <div class="col-md-12">
11
+ <br>
12
+ <h4><?php _e('Documentation', WDR_TEXT_DOMAIN);?></h4>
13
+ <hr>
14
+ </div>
15
+ </div>
16
+ <div class="row form-group enable_variable_product_cache_con">
17
+ <div class="col-md-12">
18
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
19
+ href="https://docs.flycart.org/woocommerce-discount-rules/introduction/getting-started?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;getting_started"
20
+ target="_blank"><?php _e('Getting started', WDR_TEXT_DOMAIN);?></a>
21
+ <p class=""><?php _e('Welcome onboard', WDR_TEXT_DOMAIN);?></p></div>
22
+ </div>
23
+ <div class="col-md-12">
24
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
25
+ href="https://docs.flycart.org/woocommerce-discount-rules/introduction/license-key-activation?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;license_key_activation"
26
+ target="_blank">License Key activation</a>
27
+ <p class="">Learn how to obtain the license key and activate it</p></div>
28
+ </div>
29
+ <div class="col-md-12">
30
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
31
+ href="https://docs.flycart.org/woocommerce-discount-rules/introduction/version-updates?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;version_updates"
32
+ target="_blank">Version Updates!</a>
33
+ <p class="">Learn how to update to latest versions</p></div>
34
+ </div>
35
+ <div class="col-md-12">
36
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
37
+ href="https://docs.flycart.org/woocommerce-discount-rules/introduction/price-discount-rules?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;price_rules"
38
+ target="_blank">Price Discount Rules</a>
39
+ <p class="">Learn all about creating a price discount rules</p></div>
40
+ </div>
41
+ <div class="col-md-12">
42
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
43
+ href="https://docs.flycart.org/woocommerce-discount-rules/introduction/cart-discount-rules?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;cart_rules"
44
+ target="_blank">Cart Discount Rules</a>
45
+ <p class="">Cart based discount rules with examples.</p></div>
46
+ </div>
47
+ <div class="col-md-12">
48
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
49
+ href="https://docs.flycart.org/woocommerce-discount-rules/buy-one-get-one-deals/how-to-create-a-perfect-bogo-discount-rule-in-woocommerce?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;perfect_bogo"
50
+ target="_blank">How to create a perfect BOGO discount
51
+ rule in WooCommerce</a>
52
+ <p class="">Buy One Get One deals can be simple to complex. Learn how to get them working
53
+ correct in your online store</p></div>
54
+ </div>
55
+ <div class="col-md-12">
56
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
57
+ href="https://docs.flycart.org/woocommerce-discount-rules/role-based-discounts/user-role-based-discount-rules?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;role_based"
58
+ target="_blank">User Role based discount rules</a>
59
+ <p class="">Learn how to create user role based / customer group based discount in
60
+ WooCommerce</p></div>
61
+ </div>
62
+ <div class="col-md-12">
63
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
64
+ href="https://docs.flycart.org/woocommerce-discount-rules/coupon-based-discounts/activate-discount-rule-using-a-coupon-code-in-woocommerce?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;coupon_based"
65
+ target="_blank">Activate discount rule using a coupon
66
+ code in WooCommerce</a>
67
+ <p class="">Apply the dynamic discount rules after the customer enters a valid coupon code</p>
68
+ </div>
69
+ </div>
70
+ <div class="col-md-12">
71
+ <div class="wdr_read_documentation_con"><a class="wdr_read_documentation"
72
+ href="https://docs.flycart.org/woocommerce-discount-rules/purchase-history-based-discounts/purchase-history-based-discount?utm_source=woo-discount-rules&amp;utm_campaign=doc&amp;utm_medium=text-click&amp;purchase_history"
73
+ target="_blank">Purchase History Based Discount</a>
74
+ <p class="">Price Rule and Cart Rule which gives discount based on the purchase history</p>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ <div class="woo_discount_loader">
81
+ <div class="lds-ripple">
82
+ <div></div>
83
+ <div></div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+
v2/App/Views/Admin/Tabs/settings.php ADDED
@@ -0,0 +1,849 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+ ?>
6
+ <br>
7
+
8
+ <div id="wpbody-content" class="awdr-container">
9
+ <?php
10
+ do_action('advanced_woo_discount_rules_on_settings_header');
11
+ ?>
12
+ <div class="awdr-configuration-form">
13
+ <form name="configuration_form" id="configuration-form" method="post">
14
+
15
+ <h1><?php _e('General', WDR_TEXT_DOMAIN) ?></h1>
16
+ <table class="wdr-general-setting form-table">
17
+ <tbody style="background-color: #fff;">
18
+ <?php
19
+ do_action('advanced_woo_discount_rules_before_general_settings_fields', $configuration);
20
+ ?>
21
+ <tr>
22
+ <td scope="row">
23
+ <label for="calculate_discount_from" class="awdr-left-align"><?php _e('Calculate discount from', WDR_TEXT_DOMAIN) ?></label>
24
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('sale price or regular price', WDR_TEXT_DOMAIN); ?></span>
25
+ </td>
26
+ <td>
27
+ <select name="calculate_discount_from">
28
+ <option value="sale_price" <?php echo ($configuration->getConfig('calculate_discount_from', 'sale_price') == 'sale_price') ? 'selected' : ''; ?>><?php _e('Sale price', WDR_TEXT_DOMAIN); ?></option>
29
+ <option value="regular_price" <?php echo ($configuration->getConfig('calculate_discount_from', 'sale_price') == 'regular_price') ? 'selected' : ''; ?> ><?php _e('Regular price', WDR_TEXT_DOMAIN); ?></option>
30
+ </select>
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <td scope="row">
35
+ <label for="apply_product_discount_to" class="awdr-left-align"><?php _e('Apply discount', WDR_TEXT_DOMAIN) ?></label>
36
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Highest/Lowest/First/All matched rules', WDR_TEXT_DOMAIN); ?></span>
37
+ </td>
38
+ <td>
39
+ <select name="apply_product_discount_to" class="apply_product_and_cart_discount_to" data-subsequent="apply_product_discount_subsequently_row">
40
+ <option value="biggest_discount" <?php echo ($configuration->getConfig('apply_product_discount_to', 'biggest_discount') == 'biggest_discount') ? 'selected' : ''; ?>><?php _e('Biggest one from matched rules', WDR_TEXT_DOMAIN); ?></option>
41
+ <option value="lowest_discount" <?php echo ($configuration->getConfig('apply_product_discount_to', 'biggest_discount') == 'lowest_discount') ? 'selected' : ''; ?>><?php _e('Lowest one from matched rules', WDR_TEXT_DOMAIN); ?></option>
42
+ <option value="first" <?php echo ($configuration->getConfig('apply_product_discount_to', 'biggest_discount') == 'first') ? 'selected' : ''; ?> ><?php _e('First matched rules', WDR_TEXT_DOMAIN); ?></option>
43
+ <option value="all" <?php echo ($configuration->getConfig('apply_product_discount_to', 'biggest_discount') == 'all') ? 'selected' : ''; ?>><?php _e('All matched rules', WDR_TEXT_DOMAIN); ?></option>
44
+ </select>
45
+ </td>
46
+ </tr>
47
+ <tr class="apply_product_discount_subsequently_row" style="<?php echo ($configuration->getConfig('apply_product_discount_to', 'biggest_discount') != 'all') ? 'display:none' : ''; ?>">
48
+ <td scope="row">
49
+ <label for="awdr_subsequent_discount" class="awdr-left-align"><?php _e('Apply discount subsequently', WDR_TEXT_DOMAIN) ?></label>
50
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('discounts applied subsequently', WDR_TEXT_DOMAIN); ?></span>
51
+ </td>
52
+ <td>
53
+ <input type="radio" name="apply_discount_subsequently" id="do_apply_discount_subsequently"
54
+ value="1" <?php echo($configuration->getConfig('apply_discount_subsequently', 0) ? 'checked' : '') ?>><label
55
+ for="do_apply_discount_subsequently"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
56
+ <input type="radio" name="apply_discount_subsequently"
57
+ id="do_not_apply_discount_subsequently"
58
+ value="0" <?php echo(!$configuration->getConfig('apply_discount_subsequently', 0) ? 'checked' : '') ?>><label
59
+ for="do_not_apply_discount_subsequently"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
60
+ </td>
61
+ </tr>
62
+ <tr>
63
+ <td scope="row">
64
+ <label for="disable_coupon_when_rule_applied" class="awdr-left-align"><?php _e('Choose how discount rules should work', WDR_TEXT_DOMAIN) ?></label>
65
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Choose how discount rules should work when WooCommerce coupons (or third party) coupons are used?', WDR_TEXT_DOMAIN); ?></span>
66
+ </td>
67
+ <td>
68
+ <?php
69
+ $disable_coupon_when_rule_applied = $configuration->getConfig('disable_coupon_when_rule_applied', 'run_both');
70
+ ?>
71
+ <select name="disable_coupon_when_rule_applied" class="disable_coupon_when_rule_applied">
72
+ <option value="run_both" <?php echo ($disable_coupon_when_rule_applied == 'run_both') ? 'selected' : ''; ?>><?php _e('Let both coupons and discount rules run together', WDR_TEXT_DOMAIN); ?></option>
73
+ <option value="disable_coupon" <?php echo ($disable_coupon_when_rule_applied == 'disable_coupon') ? 'selected' : ''; ?>><?php _e('Disable the coupons (discount rules will work)', WDR_TEXT_DOMAIN); ?></option>
74
+ <option value="disable_rules" <?php echo ($disable_coupon_when_rule_applied == 'disable_rules') ? 'selected' : ''; ?> ><?php _e('Disable the discount rules (coupons will work)', WDR_TEXT_DOMAIN); ?></option>
75
+ </select>
76
+ </td>
77
+ </tr>
78
+ <tr>
79
+ <td scope="row">
80
+ <label for="suppress_other_discount_plugins" class="awdr-left-align"><?php _e('Suppress third party discount plugins', WDR_TEXT_DOMAIN) ?></label>
81
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('suppress third party plugins from modifying the prices. other discount plugins may not works!', WDR_TEXT_DOMAIN); ?></span>
82
+ </td>
83
+ <td>
84
+ <input type="radio" name="suppress_other_discount_plugins" id="suppress_other_discount_plugins"
85
+ value="1" <?php echo($configuration->getConfig('suppress_other_discount_plugins', 0) ? 'checked' : '') ?>><label
86
+ for="modify_price_at_product_page"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
87
+ <input type="radio" name="suppress_other_discount_plugins"
88
+ id="do_not_suppress_other_discount_plugins"
89
+ value="0" <?php echo(!$configuration->getConfig('suppress_other_discount_plugins', 0) ? 'checked' : '') ?>><label
90
+ for="do_not_suppress_other_discount_plugins"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
91
+ </td>
92
+ </tr>
93
+ <?php
94
+ do_action('advanced_woo_discount_rules_general_settings_fields', $configuration);
95
+ ?>
96
+ </tbody>
97
+ </table>
98
+
99
+ <h1><?php _e('Product', WDR_TEXT_DOMAIN) ?></h1>
100
+
101
+ <table class="wdr-general-setting form-table">
102
+ <tbody style="background-color: #fff;">
103
+ <tr>
104
+ <td scope="row">
105
+ <label for="" class="awdr-left-align"><?php _e('On-sale badge', WDR_TEXT_DOMAIN) ?></label>
106
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('show on-sale badge', WDR_TEXT_DOMAIN); ?></span>
107
+ </td>
108
+ <td>
109
+ <?php
110
+ $show_on_sale_badge = $configuration->getConfig('show_on_sale_badge', 'disabled');
111
+ ?>
112
+ <select name="show_on_sale_badge" class="on_sale_badge_condition">
113
+ <option value="when_condition_matches" <?php echo ($show_on_sale_badge == 'when_condition_matches') ? 'selected' : ''; ?> ><?php _e('Show only after a rule condition is matched exactly', WDR_TEXT_DOMAIN); ?></option>
114
+ <option value="at_least_has_any_rules" <?php echo ($show_on_sale_badge == 'at_least_has_any_rules') ? 'selected' : ''; ?>><?php _e('Show on products that are covered under any discount rule in the plugin', WDR_TEXT_DOMAIN); ?></option>
115
+ <option value="disabled" <?php echo ($show_on_sale_badge == 'disabled') ? 'selected' : ''; ?>><?php _e('Do not show', WDR_TEXT_DOMAIN); ?></option>
116
+ </select>
117
+ </td>
118
+ </tr>
119
+ <tr class="sale_badge_toggle" style="<?php echo ($show_on_sale_badge == 'disabled')? 'display:none;':''?>">
120
+ <td scope="row">
121
+ <label for="" class="awdr-left-align"><?php _e('Do you want to customize the sale badge?', WDR_TEXT_DOMAIN) ?></label>
122
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Customize the sale badge', WDR_TEXT_DOMAIN); ?></span>
123
+ </td>
124
+ <td>
125
+ <?php
126
+ $customize_on_sale_badge = $configuration->getConfig('customize_on_sale_badge', '');
127
+ $force_override_on_sale_badge = $configuration->getConfig('force_override_on_sale_badge', '');
128
+ ?>
129
+ <input type="checkbox" name="customize_on_sale_badge" id="customize_on_sale_badge"
130
+ value="1" <?php echo ( $customize_on_sale_badge == 1 ? 'checked' : '') ?>><label
131
+ for="customize_on_sale_badge" class="padding10"><?php _e('Yes, I would like to customize the sale badge', WDR_TEXT_DOMAIN); ?></label>
132
+ <br>
133
+ <input type="checkbox" name="force_override_on_sale_badge" id="force_override_on_sale_badge"
134
+ value="1" <?php echo ( $force_override_on_sale_badge == 1 ? 'checked' : '') ?>><label
135
+ for="force_override_on_sale_badge" class="padding10"><?php _e('Force override the label for sale badge (useful when your theme has override for sale badge).', WDR_TEXT_DOMAIN); ?></label>
136
+ </td>
137
+ </tr>
138
+ <tr class="sale_badge_customizer" style="<?php echo ($show_on_sale_badge != 'disabled' && $customize_on_sale_badge == 1) ? '':'display:none;'?>">
139
+ <td scope="row">
140
+ <label for="" class="awdr-left-align"><?php _e('Sale badge content', WDR_TEXT_DOMAIN) ?></label>
141
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php _e('You can use HTML inside. <br><b>IMPORTANT NOTE:</b> This customized sale badge will be applicable only for products that are part of the discount rules configured in this plugin <b>Eg:</b><span class="onsale">Sale!</span>', WDR_TEXT_DOMAIN); ?></span>
142
+ </td>
143
+ <td>
144
+ <textarea name="on_sale_badge_html"
145
+ placeholder='<span class="onsale">Sale!</span>'
146
+ rows="5"
147
+ cols="30"><?php echo $configuration->getConfig('on_sale_badge_html', '<span class="onsale">Sale!</span>'); ?></textarea>
148
+ </td>
149
+ </tr>
150
+ <tr>
151
+ <td scope="row">
152
+ <label for="" class="awdr-left-align"><?php _e('Show discount table ', WDR_TEXT_DOMAIN) ?></label>
153
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show discount table on product page', WDR_TEXT_DOMAIN); ?></span>
154
+ </td>
155
+ <td>
156
+ <input type="radio" name="show_bulk_table" id="show_bulk_table_layout" class="bulk_table_layout settings_option_show_hide"
157
+ value="1" <?php echo($configuration->getConfig('show_bulk_table', 0) ? 'checked' : '') ?> data-name="hide_table_position"><label
158
+ for="show_bulk_table_layout"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
159
+ <input type="radio" name="show_bulk_table" id="dont_show_bulk_table_layout" class="bulk_table_layout settings_option_show_hide"
160
+ value="0" <?php echo(!$configuration->getConfig('show_bulk_table', 0) ? 'checked' : '') ?> data-name="hide_table_position"><label
161
+ for="dont_show_bulk_table_layout"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
162
+ <a class="wdr-popup-link" style="<?php echo (!$configuration->getConfig('show_bulk_table', 0)) ? 'display:none' : ''; ?>"><span class="modal-trigger" data-modal="modal-name"><?php _e("Customize Discount Table", WDR_TEXT_DOMAIN); ?></a>
163
+ </td>
164
+
165
+ </tr>
166
+ <tr class="hide_table_position"
167
+ style="<?php echo (!$configuration->getConfig('show_bulk_table', 0) ? 'display:none' : ''); ?>">
168
+ <td scope="row">
169
+ <label for="position_to_show_bulk_table" class="awdr-left-align"><?php _e('Position to show discount table', WDR_TEXT_DOMAIN) ?></label>
170
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Position to show discount table on product page', WDR_TEXT_DOMAIN); ?></span>
171
+ </td>
172
+ <td>
173
+ <select name="position_to_show_bulk_table">
174
+ <option value="woocommerce_before_add_to_cart_form" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_add_to_cart_form') ? 'selected' : ''; ?> ><?php _e('Woocommerce before add to cart form', WDR_TEXT_DOMAIN); ?></option>
175
+ <option value="woocommerce_product_meta_end" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_product_meta_end') ? 'selected' : ''; ?>><?php _e('Woocommerce product meta end', WDR_TEXT_DOMAIN); ?></option>
176
+ <option value="woocommerce_product_meta_start" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_product_meta_start') ? 'selected' : ''; ?>><?php _e('Woocommerce product meta start', WDR_TEXT_DOMAIN); ?></option>
177
+ <option value="woocommerce_after_add_to_cart_form" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_add_to_cart_form') ? 'selected' : ''; ?>><?php _e('Woocommerce after add to cart form', WDR_TEXT_DOMAIN); ?></option>
178
+ <option value="woocommerce_after_single_product" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_single_product') ? 'selected' : ''; ?>><?php _e('Woocommerce after single product', WDR_TEXT_DOMAIN); ?></option>
179
+ <option value="woocommerce_before_single_product" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_single_product') ? 'selected' : ''; ?>><?php _e('Woocommerce before single product', WDR_TEXT_DOMAIN); ?></option>
180
+ <option value="woocommerce_after_single_product_summary" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_single_product_summary') ? 'selected' : ''; ?>><?php _e('Woocommerce after single product summary', WDR_TEXT_DOMAIN); ?></option>
181
+ <option value="woocommerce_before_single_product_summary" <?php echo ($configuration->getConfig('position_to_show_bulk_table', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_single_product_summary') ? 'selected' : ''; ?>><?php _e('Woocommerce before single product summary', WDR_TEXT_DOMAIN); ?></option>
182
+ </select>
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td scope="row">
187
+ <label for="position_to_show_discount_bar" class="awdr-left-align"><?php _e('Position to show discount bar', WDR_TEXT_DOMAIN) ?></label>
188
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Position to show discount bar on product page', WDR_TEXT_DOMAIN); ?></span>
189
+ </td>
190
+ <td>
191
+ <select name="position_to_show_discount_bar">
192
+ <option value="woocommerce_before_add_to_cart_form" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_add_to_cart_form') ? 'selected' : ''; ?> ><?php _e('Woocommerce before add to cart form', WDR_TEXT_DOMAIN); ?></option>
193
+ <option value="woocommerce_product_meta_end" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_product_meta_end') ? 'selected' : ''; ?>><?php _e('Woocommerce product meta end', WDR_TEXT_DOMAIN); ?></option>
194
+ <option value="woocommerce_product_meta_start" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_product_meta_start') ? 'selected' : ''; ?>><?php _e('Woocommerce product meta start', WDR_TEXT_DOMAIN); ?></option>
195
+ <option value="woocommerce_after_add_to_cart_form" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_add_to_cart_form') ? 'selected' : ''; ?>><?php _e('Woocommerce after add to cart form', WDR_TEXT_DOMAIN); ?></option>
196
+ <option value="woocommerce_after_single_product" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_single_product') ? 'selected' : ''; ?>><?php _e('Woocommerce after single product', WDR_TEXT_DOMAIN); ?></option>
197
+ <option value="woocommerce_before_single_product" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_single_product') ? 'selected' : ''; ?>><?php _e('Woocommerce before single product', WDR_TEXT_DOMAIN); ?></option>
198
+ <option value="woocommerce_after_single_product_summary" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_after_single_product_summary') ? 'selected' : ''; ?>><?php _e('Woocommerce after single product summary', WDR_TEXT_DOMAIN); ?></option>
199
+ <option value="woocommerce_before_single_product_summary" <?php echo ($configuration->getConfig('position_to_show_discount_bar', 'woocommerce_before_add_to_cart_form') == 'woocommerce_before_single_product_summary') ? 'selected' : ''; ?>><?php _e('Woocommerce before single product summary', WDR_TEXT_DOMAIN); ?></option>
200
+ </select>
201
+ </td>
202
+ </tr>
203
+ <tr>
204
+ <td scope="row">
205
+ <label for="" class="awdr-left-align"><?php _e('Show strikeout price', WDR_TEXT_DOMAIN) ?></label>
206
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show product strikeout price on', WDR_TEXT_DOMAIN); ?></span>
207
+ </td>
208
+ <td>
209
+ <input type="checkbox" name="modify_price_at_shop_page" id="modify_price_at_shop_page"
210
+ value="1" <?php echo($configuration->getConfig('modify_price_at_shop_page', 1) ? 'checked' : '') ?>><label
211
+ for="modify_price_at_shop_page" class="padding10"><?php _e('On shop page?', WDR_TEXT_DOMAIN); ?></label>
212
+ <input type="checkbox" name="modify_price_at_product_page" id="modify_price_at_product_page"
213
+ value="1" <?php echo($configuration->getConfig('modify_price_at_product_page', 1) ? 'checked' : '') ?>><label
214
+ for="modify_price_at_product_page" class="padding10"><?php _e('On product page?', WDR_TEXT_DOMAIN); ?></label>
215
+ <input type="checkbox" name="modify_price_at_category_page" id="modify_price_at_category_page"
216
+ value="1" <?php echo($configuration->getConfig('modify_price_at_category_page', 1) ? 'checked' : '') ?>><label
217
+ for="modify_price_at_category_page" class="padding10"><?php _e('On category page?', WDR_TEXT_DOMAIN); ?></label>
218
+
219
+ </td>
220
+ </tr>
221
+ <tr>
222
+ <td scope="row">
223
+ <label for="" class="awdr-left-align"><?php _e('Show Strikeout when', WDR_TEXT_DOMAIN) ?></label>
224
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show Strikeout when this option is matched', WDR_TEXT_DOMAIN); ?></span>
225
+ </td>
226
+ <td>
227
+ <select name="show_strikeout_when">
228
+ <option value="show_when_matched" <?php echo ($configuration->getConfig('show_strikeout_when', 'show_when_matched') == 'show_when_matched') ? 'selected' : ''; ?> ><?php _e('Show when a rule condition is matched', WDR_TEXT_DOMAIN); ?></option>
229
+ <option value="show_after_matched" <?php echo ($configuration->getConfig('show_strikeout_when', 'show_when_matched') == 'show_after_matched') ? 'selected' : ''; ?>><?php _e('Show after a rule condition is matched', WDR_TEXT_DOMAIN); ?></option>
230
+ <option value="show_dynamically" <?php echo ($configuration->getConfig('show_strikeout_when', 'show_when_matched') == 'show_dynamically') ? 'selected' : ''; ?>><?php _e('Shown on quantity update (dynamic)', WDR_TEXT_DOMAIN); ?></option>
231
+ </select>
232
+ </td>
233
+ </tr>
234
+ <?php
235
+ do_action('advanced_woo_discount_rules_product_settings_fields', $configuration);
236
+ ?>
237
+
238
+ </tbody>
239
+ </table>
240
+
241
+ <h1><?php _e('Cart', WDR_TEXT_DOMAIN); ?></h1>
242
+
243
+ <table class="wdr-general-setting form-table">
244
+ <tbody style="background-color: #fff;">
245
+ <tr>
246
+ <td scope="row">
247
+ <label for="" class="awdr-left-align"><?php _e('Show strikeout on cart', WDR_TEXT_DOMAIN) ?></label>
248
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show price strikeout on cart', WDR_TEXT_DOMAIN); ?></span>
249
+ </td>
250
+ <td>
251
+ <input type="radio" name="show_strikeout_on_cart" id="show_strikeout_on_cart"
252
+ value="1" <?php echo($configuration->getConfig('show_strikeout_on_cart', 1) ? 'checked' : '') ?>><label
253
+ for="show_strikeout_on_cart"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
254
+
255
+ <input type="radio" name="show_strikeout_on_cart" id="dont_show_strikeout_on_cart"
256
+ value="0" <?php echo(!$configuration->getConfig('show_strikeout_on_cart', 1) ? 'checked' : '') ?>><label
257
+ for="dont_show_strikeout_on_cart"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
258
+ </td>
259
+ </tr>
260
+ <tr>
261
+ <td scope="row">
262
+ <label for="" class="awdr-left-align"><?php _e('Combine all cart discounts', WDR_TEXT_DOMAIN) ?></label>
263
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Combine all cart discounts in single discount label', WDR_TEXT_DOMAIN); ?></span>
264
+ </td>
265
+ <td>
266
+ <input type="radio" name="combine_all_cart_discounts" id="combine_all_cart_discounts"
267
+ data-name="combine_all_cart_discounts"
268
+ value="1"
269
+ class="settings_option_show_hide" <?php echo($configuration->getConfig('combine_all_cart_discounts', 0) ? 'checked' : '') ?>><label
270
+ for="combine_all_cart_discounts"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
271
+
272
+ <input type="radio" name="combine_all_cart_discounts" id="dont_combine_all_cart_discounts"
273
+ data-name="combine_all_cart_discounts"
274
+ value="0"
275
+ class="settings_option_show_hide" <?php echo(!$configuration->getConfig('combine_all_cart_discounts', 0) ? 'checked' : '') ?>><label
276
+ for="dont_combine_all_cart_discounts"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
277
+ </td>
278
+ </tr>
279
+ <tr class="combine_all_cart_discounts"
280
+ style="<?php echo(!$configuration->getConfig('combine_all_cart_discounts', 0) ? 'display:none' : '') ?>">
281
+ <td scope="row">
282
+ <label for="discount_label_for_combined_discounts" class="awdr-left-align"><?php _e('Discount label for combined discounts', WDR_TEXT_DOMAIN) ?></label>
283
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Discount label for combined discounts', WDR_TEXT_DOMAIN); ?></span>
284
+ </td>
285
+ <td>
286
+ <input type="text" name="discount_label_for_combined_discounts"
287
+ value="<?php echo $configuration->getConfig('discount_label_for_combined_discounts', 'Cart discount'); ?>">
288
+ </td>
289
+ </tr>
290
+ <?php
291
+ do_action('advanced_woo_discount_rules_cart_settings_fields', $configuration);
292
+ ?>
293
+ </tbody>
294
+ </table>
295
+ <h1><?php _e('Promotion', WDR_TEXT_DOMAIN); ?></h1>
296
+ <table class="wdr-general-setting form-table">
297
+ <tbody style="background-color: #fff;">
298
+ <tr>
299
+ <td scope="row">
300
+ <label for="display_saving_text" class="awdr-left-align"><?php _e('Display you saved text', WDR_TEXT_DOMAIN) ?></label>
301
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Display you saved text when rule applied', WDR_TEXT_DOMAIN); ?></span>
302
+ </td>
303
+ <td>
304
+ <select name="display_saving_text" class="settings_option_show_hide_on_change">
305
+ <option value="disabled" <?php echo ($configuration->getConfig('display_saving_text', 'disabled') == 'disabled') ? 'selected' : ''; ?>><?php _e('Disabled', WDR_TEXT_DOMAIN); ?></option>
306
+ <option value="on_each_line_item" <?php echo ($configuration->getConfig('display_saving_text', 'disabled') == 'on_each_line_item') ? 'selected' : ''; ?> ><?php _e('On each line item', WDR_TEXT_DOMAIN); ?></option>
307
+ <option value="after_total" <?php echo ($configuration->getConfig('display_saving_text', 'disabled') == 'after_total') ? 'selected' : ''; ?> ><?php _e('On after total', WDR_TEXT_DOMAIN); ?></option>
308
+ <option value="both_line_item_and_after_total" <?php echo ($configuration->getConfig('display_saving_text', 'disabled') == 'both_line_item_and_after_total') ? 'selected' : ''; ?> ><?php _e('Both in line item and after total', WDR_TEXT_DOMAIN); ?></option>
309
+ </select>
310
+ </td>
311
+ </tr>
312
+ <tr class="display_you_saved_text"
313
+ style="<?php echo ($configuration->getConfig('display_saving_text', 'disabled') == 'disabled') ? 'display:none' : ''; ?>">
314
+ <td scope="row">
315
+ <label for="you_saved_text" class="awdr-left-align"><?php _e('Savings text to show', WDR_TEXT_DOMAIN) ?></label>
316
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('You save text to show when rule applied', WDR_TEXT_DOMAIN); ?></span>
317
+ </td>
318
+ <td>
319
+ <textarea name="you_saved_text" rows="5"
320
+ cols="30"><?php echo $configuration->getConfig('you_saved_text', 'You saved {{total_discount}}'); ?></textarea>
321
+ </td>
322
+ </tr>
323
+ <tr>
324
+ <td scope="row">
325
+ <label for="" class="awdr-left-align"><?php _e('Show a discount applied message on cart?', WDR_TEXT_DOMAIN) ?></label>
326
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show message in cart page on rule applied', WDR_TEXT_DOMAIN); ?></span>
327
+ </td>
328
+ <td>
329
+ <input type="radio" name="show_applied_rules_message_on_cart" class="settings_option_show_hide"
330
+ id="show_applied_rules_message_on_cart" data-name="hide_alert_message_text"
331
+ value="1" <?php echo($configuration->getConfig('show_applied_rules_message_on_cart', 0) ? 'checked' : '') ?>><label
332
+ for="show_applied_rules_message_on_cart"><?php _e('Yes', WDR_TEXT_DOMAIN); ?></label>
333
+
334
+ <input type="radio" name="show_applied_rules_message_on_cart" class="settings_option_show_hide"
335
+ id="dont_show_applied_rules_message_on_cart" data-name="hide_alert_message_text"
336
+ value="0" <?php echo(!$configuration->getConfig('show_applied_rules_message_on_cart', 0) ? 'checked' : '') ?>><label
337
+ for="dont_show_applied_rules_message_on_cart"><?php _e('No', WDR_TEXT_DOMAIN); ?></label>
338
+ </td>
339
+ </tr>
340
+ <tr class="hide_alert_message_text" style="<?php echo (!$configuration->getConfig('show_applied_rules_message_on_cart', 0)) ? 'display:none' : ''; ?>">
341
+ <td scope="row">
342
+ <label for="applied_rule_message" class="awdr-left-align"><?php _e('Applied rule message text on cart', WDR_TEXT_DOMAIN) ?></label>
343
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Text to show when rule applied', WDR_TEXT_DOMAIN); ?></span>
344
+ </td>
345
+ <td>
346
+ <textarea name="applied_rule_message"
347
+ rows="5"
348
+ cols="30"><?php echo $configuration->getConfig('applied_rule_message', 'You saved {{total_discount}}'); ?></textarea>
349
+ </td>
350
+ </tr>
351
+ </tbody>
352
+ </table>
353
+ <h1><?php _e('Banner', WDR_TEXT_DOMAIN); ?></h1>
354
+ <table class="wdr-general-setting form-table">
355
+ <tbody style="background-color: #fff;">
356
+ <?php if(!$is_pro) { ?>
357
+ <tr class="" style="">
358
+ <td scope="row">
359
+ <label for="applied_rule_message"
360
+ class="awdr-left-align"><?php _e('Banner Content', WDR_TEXT_DOMAIN) ?></label>
361
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('A static banner you that you want to display in your storefront. <br><br> <b>NOTE:</b> It is a static banner. You can use any content or html here.', WDR_TEXT_DOMAIN); ?></span>
362
+ </td>
363
+ <td>
364
+ <?php _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN); ?>
365
+ </td>
366
+ </tr>
367
+ <tr class="" style="">
368
+ <td scope="row">
369
+ <label for="applied_rule_message"
370
+ class="awdr-left-align"><?php _e('Banner Content display position', WDR_TEXT_DOMAIN) ?></label>
371
+ <span class="wdr_desc_text awdr-clear-both"><?php _e('Choose a display position for the banner in your storefront', WDR_TEXT_DOMAIN); ?></span>
372
+ </td>
373
+ <td><?php _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN); ?></td>
374
+ </tr>
375
+ <?php } ?>
376
+
377
+ <?php
378
+ do_action('advanced_woo_discount_rules_promotion_settings_fields', $configuration);
379
+ ?>
380
+ </tbody>
381
+ </table>
382
+ <h1><?php _e('On-Sale page', WDR_TEXT_DOMAIN); ?></h1>
383
+ <table class="wdr-general-setting form-table">
384
+ <tbody style="background-color: #fff;">
385
+ <tr>
386
+ <td scope="row">
387
+ <?php
388
+ _e('Select rules for the On Sale Page', WDR_TEXT_DOMAIN );
389
+ ?>
390
+ </td>
391
+ <td scope="row">
392
+ <?php if($is_pro){ ?>
393
+ <div class="awdr_rebuild_on_sale_list_progress">
394
+ </div>
395
+ <div class="awdr_rebuild_on_sale_list_con">
396
+ <div class="wdr-select-filed-hight wdr-search-box">
397
+ <select id="awdr_rebuild_on_sale_rules" name="awdr_rebuild_on_sale_rules[]" multiple
398
+ class="edit-all-loaded-values"
399
+ data-list=""
400
+ data-field="autoloaded"
401
+ data-placeholder="<?php esc_attr_e("Type the name of the rule to select it", WDR_TEXT_DOMAIN);?>"
402
+ style="">
403
+ <option value="all"
404
+ <?php if(!empty($awdr_rebuild_on_sale_rules) && is_array($awdr_rebuild_on_sale_rules)){
405
+ if(in_array("all", $awdr_rebuild_on_sale_rules)){
406
+ echo ' selected ';
407
+ }
408
+ } ?>
409
+ ><?php esc_attr_e("All active rules", WDR_TEXT_DOMAIN); ?></option>
410
+ <?php
411
+ $awdr_rebuild_on_sale_rules = $configuration->getConfig('awdr_rebuild_on_sale_rules', array());
412
+ $rules = \Wdr\App\Controllers\ManageDiscount::$available_rules;
413
+ if(!empty($rules) && is_array($rules)){
414
+ foreach ($rules as $rule){
415
+ if($rule->rule->enabled == 1){
416
+ ?>
417
+ <option value="<?php echo $rule->rule->id; ?>"
418
+ <?php if(!empty($awdr_rebuild_on_sale_rules) && is_array($awdr_rebuild_on_sale_rules)){
419
+ if(in_array($rule->rule->id, $awdr_rebuild_on_sale_rules)){
420
+ echo ' selected ';
421
+ }
422
+ } ?>
423
+ ><?php echo $rule->rule->title; ?></option>
424
+ <?php
425
+ }
426
+ }
427
+ }
428
+ ?>
429
+ </select>
430
+ </div>
431
+ <div class="awdr_rebuild_on_sale_list_notice">
432
+ </div>
433
+ </div>
434
+ <button type="button" class="btn btn-warning" id="awdr_rebuild_on_sale_list"><?php _e('Save and Build Index', WDR_TEXT_DOMAIN ); ?></button>
435
+ <?php } else {
436
+ _e("Unlock this feature by <a href='https://www.flycart.org/products/wordpress/woocommerce-discount-rules' target='_blank'>Upgrading to Pro</a>", WDR_TEXT_DOMAIN);
437
+ }?>
438
+ </td>
439
+ </tr>
440
+ <?php if($is_pro){ ?>
441
+ <tr>
442
+ <td scope="row" colspan="2">
443
+ <?php
444
+ _e('ShortCode to load all products which has discount through Woo Discount Rules', WDR_TEXT_DOMAIN );
445
+ ?>
446
+ <span id="awdr_shortcode_text">[awdr_sale_items_list]</span>
447
+ <button type="button" class="btn btn-warning" id="awdr_shortcode_copy_btn"><?php _e('Copy ShortCode', WDR_TEXT_DOMAIN ); ?></button>
448
+ </td>
449
+ </tr>
450
+ <?php } ?>
451
+ </tbody>
452
+ </table>
453
+ <?php
454
+ do_action('advanced_woo_discount_rules_after_settings_fields', $configuration);
455
+ ?>
456
+
457
+ <!--Bulk Table Popup start-->
458
+
459
+ <div class="modal" id="modal-name">
460
+ <div class="modal-sandbox"></div>
461
+ <div class="modal-box">
462
+ <div class="modal-header">
463
+ <div class="close-modal"><span class="wdr-close-modal-box">&#10006;</span></div>
464
+ <h1 class="wdr-modal-header-title"><?php _e("Customize Discount Table", WDR_TEXT_DOMAIN); ?></h1>
465
+ </div>
466
+ <div class="modal-body">
467
+ <p class="awdr-save-green wdr-alert-success" style="display: none;"><?php _e('Settings Saved', WDR_TEXT_DOMAIN) ?></p>
468
+ <p class="wdr-customizer-notes"><b><?php _e('Note:', WDR_TEXT_DOMAIN) ?></b><?php _e(" This table contains sample content for design purpose.", WDR_TEXT_DOMAIN); ?></p>
469
+ <div style="width: 100%">
470
+ <div class="wdr-customizer-container">
471
+ <div class="wdr-customizer-grid">
472
+ <div class="wdr_customize_table_settings">
473
+ <table class="form-table popup-bulk-table">
474
+ <tbody style="background-color: #fff;">
475
+
476
+ <tr>
477
+ <th scope="row">
478
+ <label for="" class="awdr-left-align"><?php _e('Table Header', WDR_TEXT_DOMAIN) ?></label>
479
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show/Hide table header column names', WDR_TEXT_DOMAIN); ?></span>
480
+ </th>
481
+ <td >
482
+ <input type="radio" name="table_column_header" id="show_table_header" class="bulk_table_customizer_preview"
483
+ value="1" data-colname="wdr_bulk_table_thead" data-showhide="show" <?php echo($configuration->getConfig('table_column_header', 1) ? 'checked' : '') ?>><label
484
+ for="show_table_header"><?php _e('Show', WDR_TEXT_DOMAIN); ?></label>
485
+ <input type="radio" name="table_column_header" id="dont_show_table_header" class="bulk_table_customizer_preview"
486
+ value="0" data-colname="wdr_bulk_table_thead" data-showhide="hide" <?php echo(!$configuration->getConfig('table_column_header', 1) ? 'checked' : '') ?>><label
487
+ for="dont_show_table_header"><?php _e("Don't Show", WDR_TEXT_DOMAIN); ?></label>
488
+ </td>
489
+ </tr>
490
+ <tr class="">
491
+ <th scope="row">
492
+ <label for="" class="awdr-left-align"><?php _e('Title column Name on table', WDR_TEXT_DOMAIN) ?></label>
493
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Give name for rule title column', WDR_TEXT_DOMAIN); ?></span>
494
+ </th>
495
+ <td class="awdr_table_columns">
496
+ <input type="checkbox" name="table_title_column" value="1" class="bulk_table_customizer_show_hide_column"
497
+ data-colname="popup_table_title_column"
498
+ <?php echo($configuration->getConfig('table_title_column', 1) ? 'checked' : '') ?>>
499
+ <input type="text" class="awdr_popup_col_name_text_box awdr_popup_col_title_keyup" data-keyup="title_on_keyup" name="table_title_column_name" value="<?php echo $configuration->getConfig('table_title_column_name', 'Title');?>">
500
+ </td>
501
+ </tr>
502
+ <tr class="">
503
+ <th scope="row">
504
+ <label for="" class="awdr-left-align"><?php _e('Discount column Name on table', WDR_TEXT_DOMAIN) ?></label>
505
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Give name for discount column', WDR_TEXT_DOMAIN); ?></span>
506
+ </th>
507
+ <td class="awdr_table_columns">
508
+ <input type="checkbox" name="table_discount_column" value="1" class="bulk_table_customizer_show_hide_column"
509
+ data-colname="popup_table_discount_column"
510
+ <?php echo($configuration->getConfig('table_discount_column', 1) ? 'checked' : '') ?>>
511
+ <input type="text" class="awdr_popup_col_name_text_box" data-keyup="discount_on_keyup" name="table_discount_column_name" value="<?php echo $configuration->getConfig('table_discount_column_name', 'Discount');?>">
512
+ </td>
513
+ </tr>
514
+ <tr class="">
515
+ <th scope="row">
516
+ <label for="" class="awdr-left-align"><?php _e('Range column Name on table', WDR_TEXT_DOMAIN) ?></label>
517
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Give name for range column', WDR_TEXT_DOMAIN); ?></span>
518
+ </th>
519
+ <td class="awdr_table_columns">
520
+ <input type="checkbox" name="table_range_column" value="1" class="bulk_table_customizer_show_hide_column"
521
+ data-colname="popup_table_range_column"
522
+ <?php echo($configuration->getConfig('table_range_column', 1) ? 'checked' : '') ?>>
523
+ <input type="text" class="awdr_popup_col_name_text_box" data-keyup="range_on_keyup" name="table_range_column_name" value="<?php echo $configuration->getConfig('table_range_column_name', 'Range');?>">
524
+ </td>
525
+ </tr>
526
+ <tr class="">
527
+ <th scope="row">
528
+ <label for="" class="awdr-left-align"><?php _e('Discount column value on table', WDR_TEXT_DOMAIN) ?></label>
529
+ <span class="wdr_settings_desc_text awdr-clear-both"><?php esc_attr_e('Show Discount value/price in table', WDR_TEXT_DOMAIN); ?></span>
530
+ </th>
531
+ <td>
532
+ <input type="radio" name="table_discount_column_value" id="show_table_discount_column_value" class="popup_table_discount_column_value"
533
+ value="1" <?php echo($configuration->getConfig('table_discount_column_value', 1) ? 'checked' : '') ?>><label
534
+ for="show_table_discount_column_value"><?php _e('Discount Value', WDR_TEXT_DOMAIN); ?></label>
535
+ <input type="radio" name="table_discount_column_value" id="dont_show_table_discount_column_value" class="popup_table_discount_column_value"
536
+ value="0" <?php echo(!$configuration->getConfig('table_discount_column_value', 1) ? 'checked' : '') ?>><label
537
+ for="dont_show_table_discount_column_value"><?php _e("Discounted Price", WDR_TEXT_DOMAIN); ?></label>
538
+ </td>
539
+ </tr>
540
+ <!-- <tr>
541
+ <th scope="row">
542
+ <label for=""><?php /*_e('Color Picker', WDR_TEXT_DOMAIN) */?></label>
543
+ <span style="float: right" class="wdr-tool-tip"
544
+ title="<?php /*_e("Rule name / title", WDR_TEXT_DOMAIN); */?>"> &#63</span>
545
+ </th>
546
+ <td>
547
+ <input type="color" id="colorpicker" name="color" pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$" value="#bada55">
548
+ <input type="text" name="wdr_color_picker" pattern="^#+([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$" value="#bada55" id="hexcolor">
549
+ </td>
550
+ </tr>-->
551
+ </tbody>
552
+ </table>
553
+ </div>
554
+
555
+ <div class="wdr_customize_table" style="background-color: #fff;"><?php
556
+ $tbl_title = $configuration->getConfig('customize_bulk_table_title', 0);
557
+ $tbl_range = $configuration->getConfig('customize_bulk_table_range', 1);
558
+ $tbl_discount = $configuration->getConfig('customize_bulk_table_discount', 2);
559
+
560
+
561
+ $tbl_title_text = $configuration->getConfig('table_title_column_name', 'Title');
562
+ $tbl_discount_text = $configuration->getConfig('table_discount_column_name', 'Discount');
563
+ $tbl_range_text = $configuration->getConfig('table_range_column_name', 'Range');
564
+
565
+ $table_sort_by_columns = array(
566
+ 'tbl_title' => $tbl_title,
567
+ 'tbl_range' => $tbl_range,
568
+ 'tbl_discount' => $tbl_discount,
569
+ );
570
+ asort($table_sort_by_columns);
571
+ ?>
572
+ <table id="sort_customizable_table" class="wdr_bulk_table_msg sar-table">
573
+ <thead class="wdr_bulk_table_thead">
574
+ <tr class="wdr_bulk_table_tr wdr_bulk_table_thead" style="">
575
+ <?php foreach ($table_sort_by_columns as $column => $order) {
576
+ if ($column == "tbl_title") {
577
+ ?>
578
+ <th id="customize-bulk-table-title" class="wdr_bulk_table_td popup_table_title_column awdr-dragable"
579
+ style="<?php if(!$configuration->getConfig('table_column_header', 0)){
580
+ echo 'display:none';
581
+ }else{
582
+ echo((!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '');
583
+ } ?>"><span class="title_on_keyup"><?php _e($tbl_title_text, WDR_TEXT_DOMAIN) ?></span>
584
+ </th><?php
585
+ } elseif ($column == "tbl_discount") {
586
+ ?>
587
+ <th id="customize-bulk-table-discount" class="wdr_bulk_table_td popup_table_discount_column awdr-dragable"
588
+ style="<?php if(!$configuration->getConfig('table_column_header', 0)){
589
+ echo 'display:none';
590
+ }else{
591
+ echo((!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '');
592
+ } ?>"><span class="discount_on_keyup"><?php _e($tbl_discount_text, WDR_TEXT_DOMAIN) ?></span>
593
+ </th><?php
594
+ } else {
595
+ ?>
596
+ <th id="customize-bulk-table-range" class="wdr_bulk_table_td popup_table_range_column awdr-dragable"
597
+ style="<?php if(!$configuration->getConfig('table_column_header', 0)){
598
+ echo 'display:none';
599
+ }else{
600
+ echo((!$configuration->getConfig('table_range_column', 0)) ? 'display:none' : '');
601
+ }?>"><span class="range_on_keyup"><?php _e($tbl_range_text, WDR_TEXT_DOMAIN) ?></span></th><?php
602
+ }
603
+ }?>
604
+ </tr>
605
+ </thead>
606
+ <tbody>
607
+ <tr class="wdr_bulk_table_tr bulk_table_row">
608
+ <?php foreach ($table_sort_by_columns as $column => $order) {
609
+ if ($column == "tbl_title") {?>
610
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
611
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
612
+ <?php _e('Bulk Rule', WDR_TEXT_DOMAIN); ?>
613
+ </td><?php
614
+
615
+ } elseif ($column == "tbl_discount") {?>
616
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
617
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
618
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
619
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(12);
620
+ _e(' flat', WDR_TEXT_DOMAIN); ?></span>
621
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
622
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(33); ?></span>
623
+ </td><?php
624
+ } else {?>
625
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
626
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('1 - 5', WDR_TEXT_DOMAIN); ?></td><?php
627
+ }
628
+ }?>
629
+ </tr>
630
+ <tr class="wdr_bulk_table_tr bulk_table_row">
631
+ <?php foreach ($table_sort_by_columns as $column => $order) {
632
+ if ($column == "tbl_title") {?>
633
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
634
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
635
+ <?php _e('Bulk Rule', WDR_TEXT_DOMAIN); ?>
636
+ </td><?php
637
+
638
+ } elseif ($column == "tbl_discount") {?>
639
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
640
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
641
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>">
642
+ 14%
643
+ </span>
644
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
645
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(38.70); ?></span>
646
+ </td><?php
647
+ } else {?>
648
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
649
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('11 - 15', WDR_TEXT_DOMAIN); ?></td><?php
650
+ }
651
+ }?>
652
+ </tr>
653
+ <tr class="wdr_bulk_table_tr bulk_table_row">
654
+ <?php foreach ($table_sort_by_columns as $column => $order) {
655
+ if ($column == "tbl_title") {?>
656
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
657
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
658
+ <?php _e('Bulk Flat discount', WDR_TEXT_DOMAIN); ?>
659
+ </td><?php
660
+
661
+ } elseif ($column == "tbl_discount") {?>
662
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
663
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
664
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
665
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(10);
666
+ _e(' flat', WDR_TEXT_DOMAIN); ?> </span>
667
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
668
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(35); ?></span>
669
+ </td><?php
670
+ } else {?>
671
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
672
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('50 - 60', WDR_TEXT_DOMAIN); ?></td><?php
673
+ }
674
+ }?>
675
+ </tr>
676
+ <tr class="wdr_bulk_table_tr bulk_table_row">
677
+ <?php foreach ($table_sort_by_columns as $column => $order) {
678
+ if ($column == "tbl_title") {?>
679
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
680
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
681
+ <?php _e('Bulk percentage discount', WDR_TEXT_DOMAIN); ?>
682
+ </td><?php
683
+
684
+ } elseif ($column == "tbl_discount") {?>
685
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
686
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
687
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>">
688
+ 10% </span>
689
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
690
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(40.50); ?></span>
691
+ </td><?php
692
+ } else {?>
693
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
694
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('70 - 80', WDR_TEXT_DOMAIN); ?></td><?php
695
+ }
696
+ }?>
697
+ </tr>
698
+ <tr class="wdr_bulk_table_tr bulk_table_row">
699
+ <?php foreach ($table_sort_by_columns as $column => $order) {
700
+ if ($column == "tbl_title") {?>
701
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
702
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
703
+ <?php _e('Bulk % discount', WDR_TEXT_DOMAIN); ?>
704
+ </td><?php
705
+
706
+ } elseif ($column == "tbl_discount") {?>
707
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
708
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
709
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>">
710
+ 50% </span>
711
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
712
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(22.50); ?></span>
713
+ </td><?php
714
+ } else {?>
715
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
716
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('450 - 500', WDR_TEXT_DOMAIN); ?></td><?php
717
+ }
718
+ }?>
719
+ </tr>
720
+ <tr class="wdr_bulk_table_tr bulk_table_row">
721
+ <?php foreach ($table_sort_by_columns as $column => $order) {
722
+ if ($column == "tbl_title") {?>
723
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
724
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
725
+ <?php _e('Bulk flat', WDR_TEXT_DOMAIN); ?>
726
+ </td><?php
727
+
728
+ } elseif ($column == "tbl_discount") {?>
729
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
730
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
731
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
732
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(10);
733
+ _e(' flat', WDR_TEXT_DOMAIN); ?></span>
734
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
735
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(35); ?></span>
736
+ </td><?php
737
+ } else {?>
738
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
739
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('600 - 700', WDR_TEXT_DOMAIN); ?></td><?php
740
+ }
741
+ }?>
742
+ </tr>
743
+ <tr class="wdr_bulk_table_tr bulk_table_row">
744
+ <?php foreach ($table_sort_by_columns as $column => $order) {
745
+ if ($column == "tbl_title") {?>
746
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
747
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
748
+ <?php _e('set percentage discount', WDR_TEXT_DOMAIN); ?>
749
+ </td><?php
750
+
751
+ } elseif ($column == "tbl_discount") {?>
752
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
753
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
754
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>">
755
+ 10%</span>
756
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
757
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(40.50); ?></span>
758
+ </td><?php
759
+ } else {?>
760
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
761
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('5', WDR_TEXT_DOMAIN); ?></td><?php
762
+ }
763
+ }?>
764
+ </tr>
765
+ <tr class="wdr_bulk_table_tr bulk_table_row">
766
+ <?php foreach ($table_sort_by_columns as $column => $order) {
767
+ if ($column == "tbl_title") {?>
768
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
769
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
770
+ <?php _e('Fixed discount for set', WDR_TEXT_DOMAIN); ?>
771
+ </td><?php
772
+
773
+ } elseif ($column == "tbl_discount") {?>
774
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
775
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
776
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
777
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(20); ?></span>
778
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
779
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(2); ?></span>
780
+ </td><?php
781
+ } else {?>
782
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
783
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('10', WDR_TEXT_DOMAIN); ?></td><?php
784
+ }
785
+ }?>
786
+ </tr>
787
+ <tr class="wdr_bulk_table_tr bulk_table_row">
788
+ <?php foreach ($table_sort_by_columns as $column => $order) {
789
+ if ($column == "tbl_title") {?>
790
+ <td class="wdr_bulk_table_td wdr_bulk_title popup_table_title_column col_index_1" data-colindex="1"
791
+ style="<?php echo (!$configuration->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
792
+ <?php _e('set flat discount', WDR_TEXT_DOMAIN); ?>
793
+ </td><?php
794
+
795
+ } elseif ($column == "tbl_discount") {?>
796
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount popup_table_discount_column col_index_2" data-colindex="2"
797
+ style="<?php echo (!$configuration->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
798
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
799
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(30); ?></span>
800
+ <span class="wdr_table_discounted_price" style="<?php echo ( $configuration->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php
801
+ echo \Wdr\App\Helpers\Woocommerce::formatPrice(2);?> </span>
802
+ </td><?php
803
+ } else {?>
804
+ <td class="wdr_bulk_table_td wdr_bulk_range popup_table_range_column col_index_3" data-colindex="3"
805
+ style="<?php echo (!$configuration->getConfig('table_range_column', 0)) ? 'display:none':'';?>"><?php _e('15', WDR_TEXT_DOMAIN); ?></td><?php
806
+ }
807
+ }?>
808
+ </tr>
809
+ </tbody>
810
+ </table>
811
+
812
+
813
+
814
+
815
+
816
+ <p class="advanced_layout_preview"></p>
817
+ </div>
818
+ </div>
819
+ </div>
820
+ </div>
821
+ <br />
822
+ <a class="bulk-table-customized-setting wdr-model-bottom-btn btn btn-primary" style="text-decoration: none">Save</a>
823
+ <a class="close-modal wdr-model-bottom-btn btn btn-danger" style="text-decoration: none">Close</a>
824
+ </div>
825
+ </div>
826
+ </div>
827
+
828
+ <!--Bulk Table Popup end-->
829
+
830
+
831
+ <div class="save-configuration">
832
+ <input type="hidden" class="customizer_save_alert" name="customizer_save_alert" value="">
833
+ <input type="hidden" name="customize_bulk_table_title" class="customize_bulk_table_title" value="<?php echo $configuration->getConfig('customize_bulk_table_title', 0); ?>">
834
+ <input type="hidden" name="customize_bulk_table_discount" class="customize_bulk_table_discount" value="<?php echo $configuration->getConfig('customize_bulk_table_discount', 2); ?>">
835
+ <input type="hidden" name="customize_bulk_table_range" class="customize_bulk_table_range" value="<?php echo $configuration->getConfig('customize_bulk_table_range', 1); ?>">
836
+
837
+ <input type="hidden" name="method" value="save_configuration">
838
+ <input type="hidden" name="action" value="wdr_ajax">
839
+ <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary save-configuration-submit"
840
+ value="Save Changes"></p>
841
+ </div>
842
+ </form>
843
+ </div>
844
+ </div>
845
+
846
+
847
+
848
+
849
+
v2/App/Views/Admin/welcome-text.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+ ?>
4
+ <div class="wdr-loader"></div>
5
+ <div class="wdr">
6
+ <div class="wdr-alert-top-right" id="notify-msg-holder"></div>
7
+
8
+ <h2 class="wdr_tabs_container nav-tab-wrapper">
9
+ <?php esc_html_e('Migrate rules from v1 to v2', WDR_TEXT_DOMAIN); ?>
10
+ </h2>
11
+
12
+ <div class="wdr_settings">
13
+ <div class="wdr_migration_container">
14
+ <button class="button" type="button" id="awdr_do_v1_v2_migration"><?php esc_html_e('Migrate', WDR_TEXT_DOMAIN); ?></button>
15
+ <button class="button" type="button" id="awdr_skip_v1_v2_migration"><?php esc_html_e('Skip', WDR_TEXT_DOMAIN); ?></button>
16
+ <div class="wdr_migration_process">
17
+ </div>
18
+ <div class="wdr_migration_process_status">
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
v2/App/Views/Templates/discount_table.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
+
4
+ if (!empty($ranges) && !empty($woocommerce)) {
5
+ if ($ranges['layout']['type'] == 'advanced') {
6
+ $i=0;
7
+ $existing_rule_id = 0;
8
+ $tag_opened = false;
9
+ foreach ($ranges as $key => $badge_settings){
10
+ if($key !== 'layout'){
11
+ $current_rule_id = isset($badge_settings['rule_id'])? $badge_settings['rule_id'] : '';
12
+ $badge_bg_color = (!empty($badge_settings['badge_bg_color'])) ? $badge_settings['badge_bg_color'] : false;
13
+ $badge_text_color = (!empty($badge_settings['badge_text_color'])) ? $badge_settings['badge_text_color'] : false;
14
+ $badge_text = (!empty($badge_settings['badge_text'])) ? htmlspecialchars_decode($badge_settings['badge_text']) : false;
15
+ if($current_rule_id !== $existing_rule_id){
16
+ $tag_opened = true;
17
+ if($existing_rule_id !== 0){
18
+ ?>
19
+ </div>
20
+ <?php
21
+ }
22
+ $existing_rule_id = $current_rule_id;
23
+ ?>
24
+ <div class="awdr_discount_bar awdr_row_<?php echo $i;?>" style="<?php if($badge_bg_color){
25
+ echo "background-color:".$badge_bg_color.';';
26
+ }if($badge_text_color) {
27
+ echo "color:".$badge_text_color.';';
28
+ }?>">
29
+ <?php
30
+ }
31
+ ?>
32
+ <div class="awdr_discount_bar_content">
33
+ <?php echo $badge_text; ?>
34
+ </div>
35
+ <?php
36
+ $i++;
37
+ }
38
+ }
39
+ if($tag_opened){
40
+ ?>
41
+ </div>
42
+ <?php
43
+ }
44
+ } elseif ($ranges['layout']['type'] == 'default') {
45
+ $tbl_title = $base::$config->getConfig('customize_bulk_table_title', 0);
46
+ $tbl_discount = $base::$config->getConfig('customize_bulk_table_discount', 2);
47
+ $tbl_range = $base::$config->getConfig('customize_bulk_table_range', 1);
48
+
49
+ $tbl_title_text = $base::$config->getConfig('table_title_column_name', 'Title');
50
+ $tbl_discount_text = $base::$config->getConfig('table_discount_column_name', 'Discount');
51
+ $tbl_range_text = $base::$config->getConfig('table_range_column_name', 'Range');
52
+
53
+ $table_sort_by_columns = array(
54
+ 'tbl_title' => $tbl_title,
55
+ 'tbl_discount' => $tbl_discount,
56
+ 'tbl_range' => $tbl_range,
57
+ );
58
+ asort($table_sort_by_columns); ?>
59
+ <table id="sort_customizable_table" class="wdr_bulk_table_msg sar-table">
60
+ <thead class="wdr_bulk_table_thead">
61
+ <tr class="wdr_bulk_table_tr wdr_bulk_table_thead" style="<?php echo (!$base::$config->getConfig('table_column_header', 1) ? 'display:none' : '')?>">
62
+ <?php foreach ($table_sort_by_columns as $column => $order) {
63
+ if ($column == "tbl_title") {
64
+ ?>
65
+ <th id="customize-bulk-table-title" class="wdr_bulk_table_td awdr-dragable"
66
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
67
+ echo 'display:none';
68
+ }else{
69
+ echo((!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '');
70
+ } ?>"><span><?php _e($tbl_title_text, WDR_TEXT_DOMAIN) ?></span>
71
+ </th><?php
72
+ } elseif ($column == "tbl_discount") {
73
+ ?>
74
+ <th id="customize-bulk-table-discount" class="wdr_bulk_table_td awdr-dragable"
75
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
76
+ echo 'display:none';
77
+ }else{
78
+ echo((!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '');
79
+ } ?>"><span><?php _e($tbl_discount_text, WDR_TEXT_DOMAIN) ?></span>
80
+ </th><?php
81
+ } else {
82
+ ?>
83
+ <th id="customize-bulk-table-range" class="wdr_bulk_table_td awdr-dragable"
84
+ style="<?php if(!$base::$config->getConfig('table_column_header', 0)){
85
+ echo 'display:none';
86
+ }else{
87
+ echo((!$base::$config->getConfig('table_range_column', 0)) ? 'display:none' : '');
88
+ }?>"><span><?php _e($tbl_range_text, WDR_TEXT_DOMAIN) ?></span></th><?php
89
+ }
90
+ }?>
91
+ </tr>
92
+ </thead>
93
+ <tbody><?php
94
+ foreach ($ranges as $range) :
95
+ $cart_discount_text = '';
96
+ $discount_type_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
97
+ if (empty($discount_type_value)){
98
+ continue;
99
+ }
100
+ ?>
101
+ <tr class="wdr_bulk_table_tr bulk_table_row">
102
+ <?php
103
+ /**
104
+ * Discount value
105
+ */
106
+
107
+ if (isset($range['discount_method']) && $range['discount_method'] == 'cart') {
108
+ $cart_discount_text = __(' (in cart)', WDR_TEXT_DOMAIN);
109
+ }
110
+ $discount_type = isset($range['discount_type']) ? $range['discount_type'] : 'flat';
111
+ if ($discount_type == "flat") {
112
+ $discount_value = $woocommerce->formatPrice($discount_type_value);
113
+ $discount_value .= __(' flat', WDR_TEXT_DOMAIN);
114
+ $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
115
+ } elseif ($discount_type == "percentage") {
116
+ $discount_value = isset($range['discount_value']) ? $range['discount_value'] : 0;
117
+ $discount_value .= '%';
118
+ $discount_value .= !empty($cart_discount_text) ? $cart_discount_text : '';
119
+ } else {
120
+ $discount_value = $woocommerce->formatPrice($discount_type_value);
121
+ }
122
+
123
+ if (isset($range['discount_method']) && $range['discount_method'] != 'cart') {
124
+ $discounted_price_for_customizer = $woocommerce->formatPrice(isset($range['discounted_price']) ? $range['discounted_price'] : 0);
125
+ }else{
126
+ $discounted_price_for_customizer = $discount_value;
127
+ }
128
+ /**
129
+ * Discount Range
130
+ */
131
+ if (isset($range['discount_method']) && $range['discount_method'] == 'set') {
132
+ $for_text = '';
133
+ } else {
134
+ $for_text = ' +';
135
+ }
136
+ if (isset($range['from']) && !empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
137
+ $discount_range = $range['from'] . ' - ' . $range['to'];
138
+ } elseif (isset($range['from']) && !empty($range['from']) && isset($range['to']) && empty($range['to'])) {
139
+ $discount_range = $range['from']. $for_text;
140
+ } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && !empty($range['to'])) {
141
+ $discount_range = '0 - ' . $range['to'];
142
+ } elseif (isset($range['from']) && empty($range['from']) && isset($range['to']) && empty($range['to'])) {
143
+ $discount_range = '';
144
+ }?><?php
145
+ /**
146
+ * Table Data <td>'s
147
+ */
148
+ $j=1;
149
+ foreach ($table_sort_by_columns as $column => $order) {
150
+ if ($column == "tbl_title") {?>
151
+ <td class="wdr_bulk_table_td wdr_bulk_title col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
152
+ style="<?php echo (!$base::$config->getConfig('table_title_column', 0)) ? 'display:none' : '';?>">
153
+ <?php echo isset($range['rule_title']) ? $range['rule_title'] : '-' ?>
154
+ </td><?php
155
+
156
+ } elseif ($column == "tbl_discount") {?>
157
+ <td class="wdr_bulk_table_td wdr_bulk_table_discount col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
158
+ style="<?php echo (!$base::$config->getConfig('table_discount_column', 0)) ? 'display:none' : '';?>">
159
+ <span class="wdr_table_discounted_value" style="<?php echo ( !$base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discount_value; ?></span>
160
+ <span class="wdr_table_discounted_price" style="<?php echo ( $base::$config->getConfig('table_discount_column_value', 0)) ? 'display: none' : '';?>"><?php echo $discounted_price_for_customizer; ?></span>
161
+ </td><?php
162
+ } else {?>
163
+ <td class="wdr_bulk_table_td wdr_bulk_range col_index_<?php echo $j;?>" data-colindex="<?php echo $j;?>"
164
+ style="<?php echo (!$base::$config->getConfig('table_range_column', 0) || isset($range['discount_method']) && in_array($range['discount_method'], array('product', 'cart'))) ? 'display:none':'';?>"><?php echo $discount_range ?></td><?php
165
+ }
166
+ $j++;
167
+ }?>
168
+ </tr>
169
+ <?php
170
+ endforeach;
171
+ ?>
172
+ </tbody>
173
+ </table><?php
174
+ }
175
+ }
v2/App/Views/Templates/loop/sale-flash.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product loop sale flash
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woo-discount-rules/loop/sale-flash.php.
6
+ *
7
+ * HOWEVER, on occasion Woo Discount Rules will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ */
13
+
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit; // Exit if accessed directly
16
+ }
17
+
18
+ global $post, $product;
19
+
20
+ ?>
21
+ <?php if ( $product->is_on_sale() ) : ?>
22
+
23
+ <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale wdr-onsale">' . esc_html__( 'Sale!', 'woocommerce' ) . '</span>', $post, $product ); ?>
24
+
25
+ <?php endif;
26
+
27
+ /* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
v2/App/Views/Templates/single-product/sale-flash.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Single Product Sale Flash
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woo-discount-rules/single-product/sale-flash.php.
6
+ *
7
+ * HOWEVER, on occasion Woo Discount Rules will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ */
13
+
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit; // Exit if accessed directly
16
+ }
17
+
18
+ global $post, $product;
19
+
20
+ ?>
21
+ <?php if ( $product->is_on_sale() ) : ?>
22
+
23
+ <?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale wdr-onsale">' . esc_html__( 'Sale!', 'woocommerce' ) . '</span>', $post, $product ); ?>
24
+
25
+ <?php endif;
26
+
27
+ /* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
v2/Assets/Css/admin_style.css ADDED
@@ -0,0 +1,1395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .btn {
2
+ display: inline-block;
3
+ padding: 6px 12px;
4
+ margin-bottom: 0;
5
+ font-size: 14px;
6
+ font-weight: 400;
7
+ line-height: 1.42857143;
8
+ text-align: center;
9
+ white-space: nowrap;
10
+ vertical-align: middle;
11
+ -ms-touch-action: manipulation;
12
+ touch-action: manipulation;
13
+ cursor: pointer;
14
+ -webkit-user-select: none;
15
+ -moz-user-select: none;
16
+ -ms-user-select: none;
17
+ user-select: none;
18
+ background-image: none;
19
+ border: 1px solid transparent;
20
+ border-radius: 4px;
21
+ }
22
+ .wdr-status-alert {
23
+ padding: 8px;
24
+ border: 1px solid transparent;
25
+ border-radius: 4px;
26
+ }
27
+ .awdr-container .status-alert-success {
28
+ color: #3c763d;
29
+ background-color: #dff0d8;
30
+ border-color: #d6e9c6;
31
+ }
32
+ .awdr-container .status-alert-danger {
33
+ color: #a94442;
34
+ background-color: #f2dede;
35
+ border-color: #ebccd1;
36
+ }
37
+ .awdr-container .btn-primary {
38
+ color: #fff;
39
+ background-color: #337ab7;
40
+ border-color: #2e6da4;
41
+ }
42
+ .awdr-container .btn-success {
43
+ color: #fff;
44
+ background-color: #5cb85c;
45
+ border-color: #4cae4c;
46
+ }
47
+ .awdr-container .btn-danger, .wdr .btn-danger{
48
+ color: #fff;
49
+ background-color: #d9534f;
50
+ border-color: #d43f3a;
51
+ }
52
+ .awdr-container .btn-info {
53
+ color: #fff;
54
+ background-color: #5bc0de;
55
+ border-color: #46b8da;
56
+ }
57
+ .awdr-container .btn-warning {
58
+ color: #fff;
59
+ background-color: #ffc100;
60
+ border-color: #ffc100;
61
+ }
62
+
63
+ .text-right {
64
+ float: right;
65
+ margin: 2px;
66
+ text-decoration: none;
67
+ }
68
+
69
+ .wdr-rule-menu {
70
+ float: left;
71
+ width: 19%;
72
+ background-color: #FFFFFF;
73
+ padding: 10px 10px 0px 10px;
74
+ /*clear: left;*/
75
+
76
+ }
77
+
78
+ .wdr-rule-menu button {
79
+ background-color: #6495ed;
80
+ padding: 8px;
81
+ margin-top: 7px;
82
+ display: block;
83
+ width: 100%;
84
+ color: white;
85
+ text-decoration: none;
86
+ border-radius: 3px;
87
+ border: 1px solid #92b4f2;
88
+ }
89
+
90
+ .main {
91
+ float: left;
92
+ width: 80%;
93
+ background-color: white;
94
+ clear: right;
95
+ }
96
+
97
+ .right {
98
+ background-color: #e5e5e5;
99
+ float: left;
100
+ width: 20%;
101
+ padding: 15px;
102
+ margin-top: 7px;
103
+ text-align: center;
104
+ }
105
+
106
+ .wdr-block {
107
+ border: 1px solid gainsboro;
108
+ font-size: 12px;
109
+ line-height: 24px;
110
+ padding: 5px 10px 10px 10px;
111
+ color: #555;
112
+ margin-top: 5px;
113
+ margin-bottom: 10px;
114
+ background-color: #FFFFFF;
115
+ }
116
+ .wdr-grid {
117
+ width: 100%;
118
+ }
119
+ .grid-container1 {
120
+ width: 100%;
121
+ display: table;
122
+ }
123
+
124
+ .wdr-grid div {
125
+ /*text-align: left;
126
+ padding: 5px 0;
127
+ border: 2px solid #ddd;
128
+ padding: 10px;
129
+ display: table-cell;
130
+ width: auto;*/
131
+ }
132
+
133
+ .wdr-general-grid-container {
134
+ display: grid;
135
+ grid-template-columns: auto;
136
+ grid-gap: 10px;
137
+ }
138
+ .wdr-general-grid-container > div {
139
+ text-align: left;
140
+ padding: 5px 0;
141
+ }
142
+ .wdr-rule-setting {
143
+ display: grid;
144
+ grid-template-columns: 14% auto 30% ;
145
+ grid-gap: 10px;
146
+ }
147
+ .wdr-rule-date-valid {
148
+ display: grid;
149
+ grid-template-columns: 49% 49%;
150
+ grid-gap: 10px;
151
+ }
152
+ .wdr-rule-setting > div {
153
+ padding: 5px 0;
154
+ }
155
+ .wdr-title {
156
+ width: 100%;
157
+ box-sizing: border-box;
158
+ border: 1px solid #ccc;
159
+ border-radius: 4px;
160
+ background-color: white;
161
+ padding: 8px 10px 8px 10px;
162
+ height: 40px;
163
+ }
164
+ .wdr-discount-type-selector{
165
+ box-sizing: border-box;
166
+ border: 1px solid #ccc;
167
+ border-radius: 4px;
168
+ background-color: white;
169
+ padding: 8px 10px 8px 10px;
170
+ height: 40px;
171
+ }
172
+ .wdr-save-rule {
173
+ background-color: #6495ed !important;
174
+ color: #ffffff !important;
175
+ border: 1px solid #92b4f2 !important;
176
+ }
177
+ .wdr-add-condition {
178
+ line-height: 24px;
179
+ margin-top: 10px;
180
+ }
181
+ .wdr-column {
182
+ margin-right: 10px;
183
+ }
184
+ .wdr-active {
185
+ cursor: no-drop;
186
+ background-color: #ffffff !important;
187
+ color: #6495ed !important;
188
+ }
189
+ .wdr-inactive:hover {
190
+ cursor: pointer;
191
+ background-color:#92b4f2 !important;
192
+ }
193
+ .wdr-conditions-container[data-index="1"] {
194
+ display: none;
195
+ }
196
+ .wdr-conditions-container {
197
+ padding: 10px 0 20px 0;
198
+ list-style: none;
199
+ display: flex;
200
+ margin: 10px 0;
201
+ border-bottom: 1px solid #ddd;
202
+ }
203
+ .wdr-condition-types {
204
+ width: 22%;
205
+ padding-right: 5px;
206
+ }
207
+ .wdr-condition-container {
208
+ width: 75%;
209
+ display: flex;
210
+ flex-wrap: nowrap;
211
+ }
212
+ .wdr-discount-tabs {
213
+ width: 100%;
214
+ display: table;
215
+ }
216
+ .wdr-discount-tabs a {
217
+ text-decoration: none;
218
+ display: table-cell;
219
+ padding: 5px;
220
+ /*font-size: 16px;*/
221
+ }
222
+ .wdr-simple-discount-main {
223
+ display: table;
224
+ width: 100%
225
+ }
226
+ .wdr-simple-discount-inner div {
227
+ padding: 5px;
228
+ display: table-cell;
229
+ width: auto;
230
+ vertical-align: middle;
231
+ }
232
+ .wdr-cart-discount-main {
233
+ display: grid;
234
+ width: 100%
235
+ }
236
+ .wdr-cart-discount-inner div {
237
+ padding: 5px;
238
+ display: inline-grid;
239
+ width: auto;
240
+ }
241
+ .wdr-discount-block {
242
+ /*border: 1px solid gainsboro;*/
243
+ font-size: 12px;
244
+ line-height: 24px;
245
+ padding: 5px 10px 10px 10px;
246
+ color: #555;
247
+ margin-bottom: 10px;
248
+ }
249
+ .wdr_desc_text {
250
+ color: darkgray;
251
+ display: inline-block;
252
+ font-size: 12px;
253
+ float: left;
254
+ padding-top: 5px;
255
+ }
256
+ .wdr_settings_desc_text{
257
+ color: darkgray;
258
+ display: inline-block;
259
+ font-size: 12px;
260
+ float: left;
261
+ padding-top: 5px;
262
+ }
263
+ .wdr_save_btn_disabled{
264
+ opacity: .3;
265
+ cursor: default;
266
+ }
267
+
268
+ /*Checkbox Design*/
269
+
270
+ .awdr-container .toggle {
271
+ --uiToggleSize: var(--toggleSize, 20px);
272
+ --uiToggleIndent: var(--toggleIndent, .4em);
273
+ --uiToggleBorderWidth: var(--toggleBorderWidth, 2px);
274
+ --uiToggleColor: var(--toggleColor, #000);
275
+ --uiToggleDisabledColor: var(--toggleDisabledColor, #868e96);
276
+ --uiToggleBgColor: var(--toggleBgColor, #fff);
277
+ --uiToggleArrowWidth: var(--toggleArrowWidth, 2px);
278
+ --uiToggleArrowColor: var(--toggleArrowColor, #fff);
279
+
280
+ display: inline-block;
281
+ position: relative;
282
+ }
283
+
284
+ .awdr-container .toggle__input {
285
+ position: absolute;
286
+ left: -99999px;
287
+ }
288
+
289
+ .awdr-container .toggle__label {
290
+ display: inline-flex;
291
+ cursor: pointer;
292
+ min-height: var(--uiToggleSize);
293
+ padding-left: calc(var(--uiToggleSize) + var(--uiToggleIndent));
294
+ }
295
+
296
+ .awdr-container .toggle__label:before, .toggle__label:after {
297
+ content: "";
298
+ box-sizing: border-box;
299
+ width: 1em;
300
+ height: 1em;
301
+ font-size: var(--uiToggleSize);
302
+
303
+ position: absolute;
304
+ left: 0;
305
+ top: 0;
306
+ }
307
+
308
+ .awdr-container .toggle__label:before {
309
+ border: var(--uiToggleBorderWidth) solid var(--uiToggleColor);
310
+ z-index: 2;
311
+ }
312
+
313
+ .awdr-container .toggle__input:disabled ~ .toggle__label:before {
314
+ border-color: var(--uiToggleDisabledColor);
315
+ }
316
+
317
+ .awdr-container .toggle__input:focus ~ .toggle__label:before {
318
+ box-shadow: 0 0 0 2px var(--uiToggleBgColor), 0 0 0px 4px var(--uiToggleColor);
319
+ }
320
+
321
+ .awdr-container .toggle__input:not(:disabled):checked:focus ~ .toggle__label:after {
322
+ box-shadow: 0 0 0 2px var(--uiToggleBgColor), 0 0 0px 4px var(--uiToggleColor);
323
+ }
324
+
325
+ .awdr-container .toggle__input:not(:disabled) ~ .toggle__label:after {
326
+ background-color: var(--uiToggleColor);
327
+ opacity: 0;
328
+ }
329
+
330
+ .awdr-container .toggle__input:not(:disabled):checked ~ .toggle__label:after {
331
+ opacity: 1;
332
+ }
333
+
334
+ .awdr-container .toggle__text {
335
+ margin-top: auto;
336
+ margin-bottom: auto;
337
+ }
338
+
339
+ /*
340
+ The arrow size and position depends from sizes of square because I needed an arrow correct positioning from the top left corner of the element toggle
341
+ */
342
+
343
+ .awdr-container .toggle__text:before {
344
+ content: "";
345
+ box-sizing: border-box;
346
+ width: 0;
347
+ height: 0;
348
+ font-size: var(--uiToggleSize);
349
+
350
+ border-left-width: 0;
351
+ border-bottom-width: 0;
352
+ border-left-style: solid;
353
+ border-bottom-style: solid;
354
+ border-color: var(--uiToggleArrowColor);
355
+
356
+ position: absolute;
357
+ top: .5428em;
358
+ left: .2em;
359
+ z-index: 3;
360
+
361
+ transform-origin: left top;
362
+ transform: rotate(-40deg) skew(10deg);
363
+ }
364
+
365
+ .awdr-container .toggle__input:not(:disabled):checked ~ .toggle__label .toggle__text:before {
366
+ width: .5em;
367
+ height: .25em;
368
+ border-left-width: var(--uiToggleArrowWidth);
369
+ border-bottom-width: var(--uiToggleArrowWidth);
370
+ will-change: width, height;
371
+ transition: width .1s ease-out .2s, height .2s ease-out;
372
+ }
373
+
374
+ .awdr-container .toggle__label:before, .toggle__label:after {
375
+ border-radius: 2px;
376
+ }
377
+
378
+ /*
379
+ The animation of switching states
380
+ */
381
+
382
+ .awdr-container .toggle__input:not(:disabled) ~ .toggle__label:before,
383
+ .awdr-container .toggle__input:not(:disabled) ~ .toggle__label:after {
384
+ opacity: 1;
385
+ transform-origin: center center;
386
+ will-change: transform;
387
+ transition: transform .2s ease-out;
388
+ }
389
+
390
+ .awdr-container .toggle__input:not(:disabled) ~ .toggle__label:before {
391
+ transform: rotateY(0deg);
392
+ transition-delay: .2s;
393
+ }
394
+
395
+ .awdr-container .toggle__input:not(:disabled) ~ .toggle__label:after {
396
+ transform: rotateY(90deg);
397
+ }
398
+
399
+ .awdr-container .toggle__input:not(:disabled):checked ~ .toggle__label:before {
400
+ transform: rotateY(-90deg);
401
+ transition-delay: 0s;
402
+ }
403
+
404
+ .awdr-container .toggle__input:not(:disabled):checked ~ .toggle__label:after {
405
+ transform: rotateY(0deg);
406
+ transition-delay: .2s;
407
+ }
408
+
409
+ .awdr-container .toggle__text:before {
410
+ opacity: 0;
411
+ }
412
+
413
+ .awdr-container .toggle__input:not(:disabled):checked ~ .toggle__label .toggle__text:before {
414
+ opacity: 1;
415
+ transition: opacity .1s ease-out .3s, width .1s ease-out .5s, height .2s ease-out .3s;
416
+ }
417
+
418
+ /*
419
+ =====
420
+ LEVEL 3. SETTINGS
421
+ =====
422
+ */
423
+
424
+ .awdr-container .toggle {
425
+ --toggleColor: #6495ed;
426
+ --toggleBgColor: #6495ed;
427
+ --toggleSize: 25px;
428
+ }
429
+
430
+ .awdr-container .page__toggle {
431
+ /*padding-right: 20px;*/
432
+ padding-left: 20px;
433
+ padding-top: 7px;
434
+ }
435
+ .wdr-enable-rule .wdr-discount-type{
436
+ width: 19.7%;
437
+ }
438
+ .wdr-enable-rule {
439
+ display: flex;
440
+ padding: 10px 30px 20px 2px;
441
+ }
442
+
443
+
444
+ @media only screen and (max-width: 620px) {
445
+ /* For mobile phones: */
446
+ .wdr-rule-menu, .main, .right {
447
+ width: 100%;
448
+ }
449
+ }
450
+
451
+ .wdr-sticky-header {
452
+ background-color: #FFFFFF;
453
+ padding: 20px;
454
+ margin-bottom: 20px;
455
+ }
456
+
457
+ .wdr-sticky {
458
+ position: fixed;
459
+ top: 33px;
460
+ width: 87%;
461
+ overflow: hidden;
462
+ background-color: #eee;
463
+ z-index: 1;
464
+ }
465
+
466
+ .nav-tab.nav-tab-active {
467
+ background-color: #FFFFFF;
468
+ }
469
+
470
+ .awdr-product-selector {
471
+ width: 100% !important;
472
+ margin-bottom: 10px;
473
+ padding-left: 4px;
474
+ }
475
+ .wdr-filter-type select
476
+ {
477
+ height: 34px;
478
+ }.wdr-product_filter_method select
479
+ {
480
+ height: 34px;
481
+ }
482
+ .wdr-product-filter-type {
483
+ min-width: 100px;
484
+ }
485
+
486
+ .wdr-alert-top-right {
487
+ position: fixed;
488
+ top: 116px;
489
+ right: 30px;
490
+ width: 300px;
491
+ z-index: 9999;
492
+ }
493
+
494
+ .wdr-alert-success {
495
+ color: #FFFFFF;
496
+ background: green;
497
+ font-weight: bolder;
498
+ }
499
+
500
+ .wdr-alert-error {
501
+ color: #FFFFFF;
502
+ background: red;
503
+ font-weight: bolder;
504
+ }
505
+
506
+ .wdr-alert-warning {
507
+ color: #FFFFFF;
508
+ background: sandybrown;
509
+ font-weight: bolder;
510
+ }
511
+
512
+ .wdr-alert {
513
+ border-radius: 5px;
514
+ padding: 10px;
515
+ margin-bottom: 10px;
516
+ width: 100% !important;
517
+ z-index: 9999;
518
+ }
519
+
520
+ .wdr-general-setting.form-table th{
521
+ padding: 20px 10px 20px 10px;
522
+ width: 300px;
523
+ }
524
+ .wdr-filter-type
525
+ {
526
+ display: inline-block;
527
+ }
528
+ .wdr-filter-group-items .wdr-filter-group .wdr-products_group {
529
+ padding-right: 10px;
530
+ display: inline-flex;
531
+ flex-wrap: nowrap;
532
+ width: 60%;
533
+ }
534
+ .wdr_filter_remove
535
+ {
536
+ display: inline-block;
537
+ }
538
+ .wdr-cart-search_box
539
+ {
540
+ min-width: 500px;
541
+ }
542
+ .wdr-coupon-search_box
543
+ {
544
+ min-width: 400px;
545
+ }
546
+ .wdr-search-box
547
+ {
548
+ min-width: 250px;
549
+ vertical-align: super;
550
+ }
551
+ .wdr-filter-group
552
+ {
553
+ margin-bottom: 10px;
554
+ padding: 15px 0 15px 0;
555
+ border-bottom: 1px solid #ddd;
556
+ }
557
+ .wdr-condition-type select
558
+ {
559
+ height: 34px;
560
+ }
561
+
562
+ .wdr-select-filed-hight select
563
+ {
564
+ height: 34px;
565
+ }
566
+ .wdr-input-filed-hight input
567
+ {
568
+ height: 34px !important;
569
+ }
570
+ .add-condition-and-filters
571
+ {
572
+ margin-top: 15px;
573
+ }
574
+ .wdr-tool-tip{
575
+ background-color: gray;
576
+ color: #fff;
577
+ display: inline-block;
578
+ padding-left: 5px;
579
+ padding-right: 5px;
580
+ text-align: center;
581
+ border-radius: 50%;
582
+ font-size: 10px;
583
+ font-weight: bolder;
584
+ cursor: help;
585
+ }
586
+ .wdr-hide{
587
+ display: none;
588
+ }
589
+ .padding10{
590
+ padding: 10px;
591
+ }
592
+ .wdr-rule-statistics {
593
+ display: flex;
594
+ }
595
+ .wdr-rule-statistics > div{
596
+ padding: 10px;
597
+ }
598
+ .awdr-container .button.bottom-tabs{
599
+ margin-right: 5px;
600
+ }
601
+ .awdr-container .remove-current-row:hover,.awdr-container .remove-clicked-discount-block:hover,.awdr-container .wdr_discount_remove:hover{
602
+ cursor: pointer;
603
+ }
604
+
605
+ .wdr-ruleboard{
606
+ cursor: move;
607
+ }
608
+
609
+ .wdr-loader {
610
+ display: none!important;
611
+ width: 64px;
612
+ height: 64px;
613
+ position: absolute;
614
+ left: 0px;
615
+ right: 0px;
616
+ z-index: 999;
617
+ margin: auto;
618
+ top: 0px;
619
+ bottom: 0px;
620
+ }
621
+ .wdr-loader:after {
622
+ content: " ";
623
+ display: block;
624
+ width: 46px;
625
+ height: 46px;
626
+ margin: 1px;
627
+ border-radius: 50%;
628
+ border: 5px solid #333;
629
+ border-color: #333 transparent #333 transparent;
630
+ animation: wdr-loader 1.2s linear infinite;
631
+ }
632
+ @keyframes wdr-loader {
633
+ 0% {
634
+ transform: rotate(0deg);
635
+ }
636
+ 100% {
637
+ transform: rotate(360deg);
638
+ }
639
+ }
640
+ .awdr-container textarea {
641
+ width: 100%;
642
+ height: 150px;
643
+ padding: 10px 20px;
644
+ box-sizing: border-box;
645
+ border: 1px solid #ddd;
646
+ border-radius: 4px;
647
+ background-color: #f8f8f8;
648
+ resize: none;
649
+ }
650
+ .adv-msg-min-qty, .adv-msg-max-qty{
651
+ display: none;
652
+ }
653
+ .wdr-customizer-container{
654
+ width: 100%;
655
+ /*margin: 0px 337px;
656
+ max-width: 60%;*/
657
+ }
658
+ .wdr-customizer-grid{
659
+ display: grid;
660
+ grid-template-columns: 53% 47%;
661
+ grid-gap: 10px;
662
+ padding: 10px;
663
+ }
664
+ .wdr-customizer-grid > div {
665
+ padding: 0px 0;
666
+ }
667
+ /*.wdr_customize_table{
668
+ text-align: center;
669
+ }*/
670
+ .popup-bulk-table
671
+ {
672
+ padding: 0px 0;
673
+ margin-top: 0;
674
+ }
675
+ .popup-bulk-table tr th
676
+ {
677
+ padding: 20px 20px;
678
+ }
679
+ .wdr_bulk_table_msg{
680
+ width: 100%;
681
+ }
682
+
683
+ /*Model Popup*/
684
+ .awdr-container .modal,
685
+ .awdr-container .modal-box {
686
+ z-index: 9999;
687
+ }
688
+
689
+ .awdr-container .modal-sandbox {
690
+ position: fixed;
691
+ width: 100%;
692
+ height: 100%;
693
+ top: 0;
694
+ left: 0;
695
+ background: transparent;
696
+ }
697
+
698
+ .awdr-container .modal {
699
+ display: none;
700
+ position: fixed;
701
+ width: 100%;
702
+ height: 100%;
703
+ left: 0;
704
+ top: 0;
705
+ background: rgb(0,0,0);
706
+ background: rgba(0,0,0,.8);
707
+ overflow: auto;
708
+ }
709
+
710
+ .awdr-container .modal-box {
711
+ position: relative;
712
+ width: 80%;
713
+ max-width: 920px;
714
+ margin: 100px auto;
715
+ animation-name: modalbox;
716
+ animation-duration: .4s;
717
+ animation-timing-function: cubic-bezier(0,0,.3,1.6);
718
+ }
719
+
720
+ .awdr-container .modal-header {
721
+ padding: 20px 40px;
722
+ background: #6495ed;
723
+ color: #ffffff;
724
+ }
725
+
726
+ .awdr-container .modal-body {
727
+ background: #ECEFF1;
728
+ padding: 50px 15px;
729
+ }
730
+
731
+ /* Close Button */
732
+ .awdr-container .close-modal {
733
+ text-align: right;
734
+ cursor: pointer;
735
+ }
736
+
737
+ /* Animation */
738
+ @-webkit-keyframes modalbox {
739
+ 0% {
740
+ top: -250px;
741
+ opacity: 0;
742
+ }
743
+ 100% {
744
+ top: 0;
745
+ opacity: 1;
746
+ }
747
+ }
748
+
749
+ @keyframes modalbox {
750
+ 0% {
751
+ top: -250px;
752
+ opacity: 0;
753
+ }
754
+ 100% {
755
+ top: 0;
756
+ opacity: 1;
757
+ }
758
+ }
759
+
760
+ .awdr-configuration-form .modal-trigger {
761
+ top: 50%;
762
+ left: 50%;
763
+ background: transparent;
764
+ border: 1px solid #ffffff;
765
+ text-decoration: none;
766
+ }
767
+
768
+ .wdr-modal-header-title{
769
+ color: #FFFFFF;
770
+ }
771
+ .wdr-model-bottom-btn{
772
+ float: right;
773
+ margin: 5px;
774
+ }
775
+ .wdr-popup-link{
776
+ cursor: pointer;
777
+ }
778
+ table.wdr_bulk_table_msg,
779
+ tr.wdr_bulk_table_tr,
780
+ td.wdr_bulk_table_td,
781
+ th.wdr_bulk_table_td{
782
+ padding: 10px;
783
+ }
784
+ .wdr-customizer-notes{
785
+ padding: 0px 10px;
786
+ }
787
+ .wdr-red-text{
788
+ color: red;
789
+ }
790
+ .wdr-cart-coupon-value .coupon_name_msg{
791
+ text-transform: uppercase;
792
+ }
793
+ span#awdr_shortcode_text{
794
+ font-weight: bold;
795
+ }
796
+ .awdr-list-header-btn a.text-right{
797
+ float: right;
798
+ margin-left: 10px;
799
+ text-decoration: none;
800
+ }
801
+ .wdr-rule-options-con {
802
+ width: 80%;
803
+ float: left;
804
+ }
805
+ .awdr-clear{
806
+ height: inherit;
807
+ clear: both;
808
+ }
809
+ .wdr-rule-filters-and-options-con{
810
+ background-color: #ffffff;
811
+ display: flex;
812
+ padding: 10px;
813
+ }
814
+ .wdr-discount-block-remove .remove-clicked-discount-block,
815
+ .wdr-btn-remove .wdr_discount_remove,
816
+ .wdr_filter_remove .remove-current-row{
817
+ color: #fff;
818
+ background-color: #d9534f;
819
+ border-radius: 3px;
820
+ }
821
+ .wdr-condition-group .remove-current-row{
822
+ margin-top: 5px;
823
+ }
824
+ .wdp-block.add-condition{
825
+ margin-top: 10px;
826
+ }
827
+ .set_range_setter{
828
+ margin-bottom: 15px;
829
+ }
830
+ .range_setter_inner .wdr-simple-discount-inner,
831
+ .bulk_range_setter .wdr-simple-discount-inner,
832
+ .wdr-cart-discount-placement .wdr-simple-discount-inner{
833
+ border-bottom: 1px solid #ddd;
834
+ padding: 5px 0;
835
+ }
836
+ .buyx_getx_individual_range{
837
+ padding: 5px 0;
838
+ }
839
+ .wdr-conditions-container .number_only_field,
840
+ .wdr-conditions-container input[type="number"],
841
+ .wdr-conditions-container .float_only_field{
842
+ width: 100px;
843
+ }
844
+ .wdr-condition-type-options div{
845
+ display: inline-block;
846
+ margin: 0 2px;
847
+ }
848
+ .wdr-condition-type-options{
849
+ margin: 0 5px;
850
+ }
851
+ #configuration-form table tbody tr > td:first-child {
852
+ width: 400px;
853
+ }
854
+ .wdr_color_picker{
855
+ letter-spacing: 0.2rem;
856
+ }
857
+ .wdr_adv_msg_shortcode_text{
858
+ color: darkgray;
859
+ font-size: 12px;
860
+ }
861
+ .awdr_popup_col_name_text_box{
862
+ width: 100% !important;
863
+ }
864
+ #customize-bulk-table-title{
865
+ width: 40%;
866
+ text-align: left;
867
+ }
868
+ #customize-bulk-table-discount, #customize-bulk-table-range{
869
+ width: 30%;
870
+ text-align: left;
871
+ }
872
+ table.wdr_bulk_table_msg{
873
+ border-collapse: collapse;
874
+ }
875
+ table.wdr_bulk_table_msg,tr.wdr_bulk_table_tr,
876
+ td.wdr_bulk_table_td,th.wdr_bulk_table_td{
877
+ border:1px solid #bfc6cb;
878
+ }
879
+ .awdr-dragable{
880
+ cursor: ew-resize;
881
+ word-break: break-all;
882
+ }
883
+ .awdr_valide_date_in_desc{
884
+ line-height: 28px;
885
+ font-size: 14px;
886
+ padding-left: 20px;
887
+ }
888
+ .wdr_customize_table table tbody tr > td:first-child {
889
+ width: auto !important;
890
+ }
891
+ .awdr-listing-rule-tr:hover{
892
+ background-color: #ddf2ff;
893
+ }
894
+ tr.awdr-listing-rule-tr td {
895
+ vertical-align: middle;
896
+ }
897
+ .awdr-text-warning {
898
+ color: #8a6d3b;
899
+ }
900
+ .updates-table tbody td.check-column, .widefat tbody th.check-column, .widefat tfoot td.check-column, .widefat thead td.check-column {
901
+ padding: 0px !important;
902
+ }
903
+ .widefat tbody th.check-column {
904
+ padding: 0px !important;
905
+ }
906
+ .widefat .check-column {
907
+ width: 2.2em !important;
908
+ padding: 0px !important;
909
+ vertical-align: middle !important;
910
+ }
911
+ .awdr-save-green{
912
+ border-radius: 5px;
913
+ padding: 10px;
914
+ width: 98%;
915
+ z-index: 9999;
916
+ }
917
+ .banner-short-code-setting{
918
+ vertical-align: middle;
919
+ line-height: 39px;
920
+ }
921
+ .awdr-condition-container, .awdr-discount-container{
922
+ background-color: #FFFFFF;
923
+ margin: 20px 0px;
924
+ clear: both;
925
+ }
926
+ .awdr-discount-batch-container{
927
+ background-color: #FFFFFF;
928
+ clear: both;
929
+ }
930
+ .awdr-condition-container h2, .wdr-advanced-layout-groups h2, .awdr-discount-container h2, .wdr-rule-menu h2{
931
+ color:#6495ed;
932
+ margin: auto;
933
+ }
934
+ .awdr-sub-heading-description{
935
+ font-size: smaller;
936
+ color: gray;
937
+ }
938
+ .woocommerce table.form-table.awdr-discount-badge {
939
+ table-layout: auto !important;
940
+ }
941
+ .woocommerce table.form-table.awdr-discount-badge input[type=text]{
942
+ width: auto;
943
+ }
944
+ .awdr-exclusive-enable-listing{
945
+ color: #4cae4c;
946
+ font-size: 10px;
947
+ border: 1px solid #4cae4c;
948
+ padding: 2px;
949
+ margin: 8px;
950
+ border-radius: 3px;
951
+ }
952
+ .awdr-exclusive-disable-listing{
953
+ color: #d43f3a;
954
+ font-size: 10px;
955
+ border: 1px solid #d43f3a;
956
+ padding: 2px;
957
+ margin: 8px;
958
+ border-radius: 3px;
959
+ }
960
+ /** Toggle Enable Disable Button */
961
+ .switch {
962
+ position: relative;
963
+ display: block;
964
+ vertical-align: top;
965
+ width: 84px;
966
+ height: 30px;
967
+ padding: 3px;
968
+ margin: 0 5px 10px 0;
969
+ border-radius: 0px;
970
+ cursor: pointer;
971
+ box-sizing:content-box;
972
+ }
973
+ .switch-input {
974
+ position: absolute;
975
+ top: 0;
976
+ left: 0;
977
+ opacity: 0;
978
+ box-sizing:content-box;
979
+ }
980
+ .switch-label {
981
+ position: relative;
982
+ display: block;
983
+ height: inherit;
984
+ font-size: 13px;
985
+ background: #808080;
986
+ border-radius: 4px;
987
+ box-sizing:content-box;
988
+ }
989
+ .switch-label:before, .switch-label:after {
990
+ position: absolute;
991
+ top: 50%;
992
+ margin-top: -.5em;
993
+ line-height: 1;
994
+ -webkit-transition: inherit;
995
+ -moz-transition: inherit;
996
+ -o-transition: inherit;
997
+ transition: inherit;
998
+ box-sizing:content-box;
999
+ }
1000
+ .switch-label:before {
1001
+ content: attr(data-off);
1002
+ right: 11px;
1003
+ color: #ffffff;
1004
+ text-shadow: 0 1px rgba(255, 255, 255, 0.5);
1005
+ }
1006
+ .switch-label:after {
1007
+ content: attr(data-on);
1008
+ left: 11px;
1009
+ color: #ffffff;
1010
+ text-shadow: 0 1px rgba(0, 0, 0, 0.2);
1011
+ opacity: 0;
1012
+ }
1013
+ .switch-input:checked ~ .switch-label {
1014
+ background: #5cb85c;
1015
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 3px rgba(0, 0, 0, 0.2);
1016
+ }
1017
+ .switch-input:checked ~ .switch-label:before {
1018
+ opacity: 0;
1019
+ }
1020
+ .switch-input:checked ~ .switch-label:after {
1021
+ opacity: 1;
1022
+ }
1023
+ .switch-handle {
1024
+ position: absolute;
1025
+ top: 4px;
1026
+ left: 4px;
1027
+ width: 12px;
1028
+ height: 28px;
1029
+ background: linear-gradient(to bottom, #FFFFFF 40%, #f0f0f0);
1030
+ background-image: -webkit-linear-gradient(top, #FFFFFF 40%, #f0f0f0);
1031
+ border-radius: 4px;
1032
+ box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
1033
+ }
1034
+ .switch-handle:before {
1035
+ content: "";
1036
+ position: absolute;
1037
+ top: 50%;
1038
+ left: 50%;
1039
+ margin: -6px 0 0 -6px;
1040
+ width: 12px;
1041
+ height: 12px;
1042
+ background: linear-gradient(to bottom, #eeeeee, #FFFFFF);
1043
+ background-image: -webkit-linear-gradient(top, #eeeeee, #FFFFFF);
1044
+ border-radius: 6px;
1045
+ box-shadow: inset 0 1px rgba(0, 0, 0, 0.02);
1046
+ }
1047
+ .switch-input:checked ~ .switch-handle {
1048
+ left: 74px;
1049
+ box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
1050
+ }
1051
+
1052
+ /* Transition
1053
+ ========================== */
1054
+ .switch-label, .switch-handle {
1055
+ transition: All 0.3s ease;
1056
+ -webkit-transition: All 0.3s ease;
1057
+ -moz-transition: All 0.3s ease;
1058
+ -o-transition: All 0.3s ease;
1059
+ }
1060
+
1061
+ .awdr-container input[type="color"] {
1062
+ padding: 2px;
1063
+ }
1064
+ .awdr-common-save{
1065
+ margin-left: auto;
1066
+ }
1067
+ .wdr-buyx-getx-discount-main, .wdr-buyx-gety-discount-main {
1068
+ display: grid;
1069
+ width: 100%;
1070
+ }
1071
+ .awdr-buyx-getx-number-box, .awdr-buyx-gety-number-box{
1072
+ width: 150px;
1073
+ }
1074
+ .wdr-buyx-getx-discount-inner div, .wdr-buyx-gety-discount-inner div {
1075
+ display: inline-grid;
1076
+ width: auto;
1077
+ padding: 5px;
1078
+ }
1079
+ .awdr-discount-add-row{
1080
+ padding-left: 14px;
1081
+ }
1082
+ .awdr-listing-status-text{
1083
+ padding-left: 10px;
1084
+ }
1085
+ .awdr-get-y-general-settings{
1086
+ display: flex;
1087
+ width: auto;
1088
+ }
1089
+ .awdr-left-align{
1090
+ float: left;
1091
+ }
1092
+ .awdr-clear-both{
1093
+ clear: both;
1094
+ }
1095
+ .awdr_check_styles{
1096
+ display: flex;
1097
+ }
1098
+ .awdr_discount_type_section{
1099
+ padding-bottom: 20px;
1100
+ }
1101
+ .awdr-rules-sub-menu{
1102
+ padding-top: 42px !important;
1103
+ }
1104
+ .awdr-rule-limit-timestamp{
1105
+ color: darkgray;
1106
+ display: inline-block;
1107
+ font-size: 12px;
1108
+ text-transform: capitalize;
1109
+ line-height: 34px;
1110
+ padding-left: 15px;
1111
+ }
1112
+ #wpfooter{
1113
+ position: relative;
1114
+ }
1115
+ .wdr-buyx-gety-discount-inner{
1116
+ padding: 5px;
1117
+ }
1118
+ .page__toggle.apply_as_cart_checkbox{
1119
+ padding-left: 11px;
1120
+ padding-top: 20px;
1121
+ }
1122
+ .apply_as_cart_checkbox .toggle__label:before, .apply_as_cart_checkbox .toggle__label:after{
1123
+ width: 0.8em !important;
1124
+ height: 0.8em !important;
1125
+ }
1126
+ .toggle_tic.toggle__text:before{
1127
+ top: 0.4300em !important;
1128
+ left: .1em !important;
1129
+ }
1130
+ .apply_discount_as_cart_section{
1131
+ display: flex;
1132
+ }
1133
+ .apply_fee_coupon_label{
1134
+ padding-left: 15px;
1135
+ padding-top: 13px;
1136
+ }
1137
+ .bulk-row-start{
1138
+ border-bottom: 1px solid #ddd;
1139
+ padding: 5px 0;
1140
+ }
1141
+ .bulk-row-start div{
1142
+ padding: 5px;
1143
+ display: table-cell;
1144
+ width: min-content;
1145
+ }
1146
+ .woocommerce table.form-table.popup-bulk-table th {
1147
+ padding-right: 0px !important;
1148
+ }
1149
+ .awdr_table_columns{
1150
+ display: flex;
1151
+ }
1152
+ .awdr-accordion {
1153
+ background-color: #fff;
1154
+ color: #6495ed;
1155
+ cursor: pointer;
1156
+ padding: 18px;
1157
+ width: 100%;
1158
+ border: none;
1159
+ text-align: left;
1160
+ outline: none;
1161
+ font-weight: 600;
1162
+ font-size: 1.3em;
1163
+ transition: 0.4s;
1164
+ }
1165
+
1166
+ .awdr-accordion-active, .awdr-accordion:hover {
1167
+ background-color: #808080;
1168
+ color: #ffffff;
1169
+ }
1170
+
1171
+ .awdr-accordion-panel {
1172
+ display: none;
1173
+ background-color: white;
1174
+ overflow: hidden;
1175
+ }
1176
+ .awdr-accordion:after {
1177
+ content: '\02795'; /* Unicode character for "plus" sign (+) */
1178
+ font-size: 13px;
1179
+ color: #777;
1180
+ float: right;
1181
+ margin-left: 5px;
1182
+ }
1183
+
1184
+ .awdr-accordion-active:after {
1185
+ content: "\2796"; /* Unicode character for "minus" sign (-) */
1186
+ }
1187
+
1188
+ .wdr_filter_desc_text {
1189
+ color: darkgray;
1190
+ display: block;
1191
+ font-size: 12px;
1192
+ padding-top: 5px;
1193
+ }
1194
+ .wdr_select2_desc_text{
1195
+ color: darkgray;
1196
+ display: inline-block;
1197
+ font-size: 12px;
1198
+ text-transform: capitalize;
1199
+ padding-top: 5px;
1200
+ }
1201
+ .awdr-sort-icon{
1202
+ padding-top: 12px !important;
1203
+ }
1204
+ .bulk_range_setter {
1205
+ cursor: move;
1206
+ }
1207
+ .dashicons-menu{
1208
+ color:darkgray !important;
1209
+ }
1210
+ .dashicons-menu:hover{
1211
+ color: black !important;
1212
+ }
1213
+ .awdr_admin_discount_bar{
1214
+ padding: 10px;
1215
+ margin-bottom: 10px;
1216
+ border-radius: 4px;
1217
+ }
1218
+ .wdr_migration_container{
1219
+ margin: 10px 0;
1220
+ }
1221
+
1222
+ .wdr_settings .woo_discount_loader{
1223
+ display: none;
1224
+ position: absolute;
1225
+ background-color: rgba(255,255,255,0.5);
1226
+ top: 0;
1227
+ left: 0;
1228
+ width: 100%;
1229
+ height: 70%;
1230
+ text-align: center;
1231
+ }
1232
+ .woo_discount_loader .lds-ripple {
1233
+ display: inline-block;
1234
+ position: relative;
1235
+ top: 50%;
1236
+ width: 64px;
1237
+ height: 64px;
1238
+ }
1239
+ .woo_discount_loader .lds-ripple div {
1240
+ position: absolute;
1241
+ border: 4px solid #257AF0;
1242
+ opacity: 1;
1243
+ border-radius: 50%;
1244
+ animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
1245
+ }
1246
+ .woo_discount_loader .lds-ripple div:nth-child(2) {
1247
+ animation-delay: -0.5s;
1248
+ }
1249
+ @keyframes lds-ripple {
1250
+ 0% {
1251
+ top: 28px;
1252
+ left: 28px;
1253
+ width: 0;
1254
+ height: 0;
1255
+ opacity: 1;
1256
+ }
1257
+ 100% {
1258
+ top: -1px;
1259
+ left: -1px;
1260
+ width: 58px;
1261
+ height: 58px;
1262
+ opacity: 0;
1263
+ }
1264
+ }
1265
+ .awdr-product-selector span.select2-selection {
1266
+ max-height: 100px;
1267
+ overflow: auto;
1268
+ }
1269
+ .bulk_discount_min, .bulk_discount_max, .bulk_discount_value,