Discount Rules for WooCommerce - Version 2.4.4

Version Description

  • 09/08/22 =
  • Improvement: Event: advanced_woo_discount_rules_is_valid_filter_type
  • Improvement: Event: advanced_woo_discount_rules_after_delete_rule
  • Improvement: Event: advanced_woo_discount_rules_after_delete_rules
  • Improvement: Event: advanced_woo_discount_rules_page_tabs
  • Improvement: Event: advanced_woo_discount_rules_process_custom_filter
  • Improvement: Event: advanced_woo_discount_rules_load_custom_filter_data
  • Improvement: Event: advanced_woo_discount_rules_update_additional_data_before_save_rule
  • Improvement: Event: advanced_woo_discount_rules_after_save_rule
  • Improvement: Event: advanced_woo_discount_rules_do_strikeout_for_out_of_stock_variants
  • Fix: Onsale page query improvement for on-sale filter.
  • Fix: Redirecting to list page on create rule instead of edit page.
  • Fix: BXGY cheapest variants together strikeout issue fix
  • Fix: Wrong price on subtotal promotion message while set including tax.
Download this release

Release Info

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

Code changes from version 2.4.2 to 2.4.4

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: 6.0
7
- Stable tag: 2.4.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -336,6 +336,37 @@ Note : Enable recursive checkbox if the discounts should be applied in sequentia
336
 
337
  == Changelog ==
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  = 2.4.2 - 21/06/22 =
340
  * Feature: Option to schedule sale page product rebuild on daily once.
341
  * Improvement: Event: advanced_woo_discount_rules_variation_title_modify_count
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: 6.0
7
+ Stable tag: 2.4.4
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
336
 
337
  == Changelog ==
338
 
339
+ = 2.4.4 - 09/08/22 =
340
+ * Improvement: Event: advanced_woo_discount_rules_is_valid_filter_type
341
+ * Improvement: Event: advanced_woo_discount_rules_after_delete_rule
342
+ * Improvement: Event: advanced_woo_discount_rules_after_delete_rules
343
+ * Improvement: Event: advanced_woo_discount_rules_page_tabs
344
+ * Improvement: Event: advanced_woo_discount_rules_process_custom_filter
345
+ * Improvement: Event: advanced_woo_discount_rules_load_custom_filter_data
346
+ * Improvement: Event: advanced_woo_discount_rules_update_additional_data_before_save_rule
347
+ * Improvement: Event: advanced_woo_discount_rules_after_save_rule
348
+ * Improvement: Event: advanced_woo_discount_rules_do_strikeout_for_out_of_stock_variants
349
+ * Fix: Onsale page query improvement for on-sale filter.
350
+ * Fix: Redirecting to list page on create rule instead of edit page.
351
+ * Fix: BXGY cheapest variants together strikeout issue fix
352
+ * Fix: Wrong price on subtotal promotion message while set including tax.
353
+
354
+ = 2.4.3 - 28/06/22 =
355
+ * Improvement: Event: advanced_woo_discount_rules_is_valid_filter_type
356
+ * Improvement: Event: advanced_woo_discount_rules_after_delete_rule
357
+ * Improvement: Event: advanced_woo_discount_rules_after_delete_rules
358
+ * Improvement: Event: advanced_woo_discount_rules_page_tabs
359
+ * Improvement: Event: advanced_woo_discount_rules_process_custom_filter
360
+ * Improvement: Event: advanced_woo_discount_rules_load_custom_filter_data
361
+ * Improvement: Event: advanced_woo_discount_rules_update_additional_data_before_save_rule
362
+ * Improvement: Event: advanced_woo_discount_rules_after_save_rule
363
+ * Fix: Onsale page query improvement for on-sale filter.
364
+ * Fix: Redirecting to list page on create rule instead of edit page.
365
+
366
+ = 2.4.3 - 28/06/22 =
367
+ * Fix: Sale page doesn't filters based on selected rules.
368
+ * Improvement: Event: advanced_woo_discount_rules_get_price_of_cart_item_on_find_cheapest_item
369
+
370
  = 2.4.2 - 21/06/22 =
371
  * Feature: Option to schedule sale page product rebuild on daily once.
372
  * Improvement: Event: advanced_woo_discount_rules_variation_title_modify_count
v2/App/Conditions/CartSubTotal.php CHANGED
@@ -37,6 +37,7 @@ class CartSubTotal extends Base
37
  $cart_sub_total = self::$woocommerce_helper->getCartSubtotal();
38
  }
39
  $sub_total_recalculate = true;
 
40
  }
41
  if((!empty($cart) && $cart_sub_total == 0 && $sub_total_recalculate) || apply_filters('advanced_woo_discount_rules_recalculate_cart_subtotal_manually', false)){
42
  $cart_sub_total = 0;
37
  $cart_sub_total = self::$woocommerce_helper->getCartSubtotal();
38
  }
39
  $sub_total_recalculate = true;
40
+
41
  }
42
  if((!empty($cart) && $cart_sub_total == 0 && $sub_total_recalculate) || apply_filters('advanced_woo_discount_rules_recalculate_cart_subtotal_manually', false)){
43
  $cart_sub_total = 0;
v2/App/Controllers/Admin/Settings.php CHANGED
@@ -126,7 +126,7 @@ class Settings extends Base
126
  private function getTabs()
127
  {
128
  // return $this->tabs;
129
- $tabs = array(
130
  'rules' => new DiscountRules(),
131
  'settings' => new GeneralSettings(),
132
  'statistics' => new Statistics(),
@@ -134,7 +134,7 @@ class Settings extends Base
134
  'importexport' => new ImportExport(),
135
  'help' => new Help(),
136
  'recipe' => new Recipe()
137
- );
138
  uasort($tabs, function ($tab1, $tab2) {
139
  $priority1 = (int)isset($tab1->priority) ? $tab1->priority : 1000;
140
  $priority2 = (int)isset($tab2->priority) ? $tab2->priority : 1000;
126
  private function getTabs()
127
  {
128
  // return $this->tabs;
129
+ $tabs = apply_filters('advanced_woo_discount_rules_page_tabs', array(
130
  'rules' => new DiscountRules(),
131
  'settings' => new GeneralSettings(),
132
  'statistics' => new Statistics(),
134
  'importexport' => new ImportExport(),
135
  'help' => new Help(),
136
  'recipe' => new Recipe()
137
+ ));
138
  uasort($tabs, function ($tab1, $tab2) {
139
  $priority1 = (int)isset($tab1->priority) ? $tab1->priority : 1000;
140
  $priority2 = (int)isset($tab2->priority) ? $tab2->priority : 1000;
v2/App/Controllers/Admin/WDRAjax.php CHANGED
@@ -458,9 +458,9 @@ class WDRAjax extends Base
458
  }
459
  $redirect_url = false;
460
  if (!empty($this->input->post('wdr_save_close', ''))) {
461
- $redirect_url = esc_url(admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules'))));
462
  } elseif (empty($this->input->post('edit_rule', ''))) {
463
- $redirect_url = esc_url(admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_id))));
464
  }
465
  $build_index = array();
466
  if ($rule_id) {
@@ -498,6 +498,7 @@ class WDRAjax extends Base
498
  )
499
  );
500
  OnSaleShortCode::updateOnsaleRebuildPageStatus($row_id);
 
501
  }
502
  $build_index = array();
503
  if ($row_id) {
@@ -659,6 +660,7 @@ class WDRAjax extends Base
659
  )
660
  );
661
  }
 
662
  wp_send_json(
663
  array(
664
  'delete' => 'deleted',
@@ -798,7 +800,7 @@ class WDRAjax extends Base
798
  $rule_data = $recipes_data[$awdr_recipe_type];
799
  $rule_id = $recipes_object->save($rule_data);
800
  if (!empty($rule_id)) {
801
- $redirect_url = esc_url(admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_id))));
802
  } else {
803
  $redirect_url = '';
804
  }
458
  }
459
  $redirect_url = false;
460
  if (!empty($this->input->post('wdr_save_close', ''))) {
461
+ $redirect_url = admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules')));
462
  } elseif (empty($this->input->post('edit_rule', ''))) {
463
+ $redirect_url = admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_id)));
464
  }
465
  $build_index = array();
466
  if ($rule_id) {
498
  )
499
  );
500
  OnSaleShortCode::updateOnsaleRebuildPageStatus($row_id);
501
+ do_action('advanced_woo_discount_rules_after_delete_rule', $row_id);
502
  }
503
  $build_index = array();
504
  if ($row_id) {
660
  )
661
  );
662
  }
663
+ do_action('advanced_woo_discount_rules_after_delete_rules', $saved_rules);
664
  wp_send_json(
665
  array(
666
  'delete' => 'deleted',
800
  $rule_data = $recipes_data[$awdr_recipe_type];
801
  $rule_id = $recipes_object->save($rule_data);
802
  if (!empty($rule_id)) {
803
+ $redirect_url = admin_url("admin.php?" . http_build_query(array('page' => WDR_SLUG, 'tab' => 'rules', 'task' => 'view', 'id' => $rule_id)));
804
  } else {
805
  $redirect_url = '';
806
  }
v2/App/Controllers/ManageDiscount.php CHANGED
@@ -492,10 +492,12 @@ class ManageDiscount extends Base
492
  return $price_html;
493
  }
494
 
495
- $original_prices_list = $discount_prices_lists = array();
496
  $variations = Woocommerce::getProductChildren($product);
497
 
498
  if (!empty($variations)) {
 
 
499
  foreach ($variations as $variation_id) {
500
  if (empty($variation_id)) {
501
  continue;
@@ -504,12 +506,14 @@ class ManageDiscount extends Base
504
  if(!Woocommerce::variationIsVisible($variation)){
505
  continue;
506
  }
507
- if(!$variation->is_in_stock()) {
508
  continue;
509
  }
510
  $prices = self::calculateInitialAndDiscountedPrice($variation, $quantity);
511
  if (!isset($prices['initial_price']) || !isset($prices['discounted_price'])) {
512
- return $this->removeDuplicateStrikeoutPrice($price_html);
 
 
513
  }
514
  $original_prices_list[] = $prices['initial_price'];
515
  $discount_prices_lists[] = $prices['discounted_price'];
@@ -518,11 +522,12 @@ class ManageDiscount extends Base
518
  $discount_prices_lists = array_unique($discount_prices_lists);
519
  $original_prices_list = array_unique($original_prices_list);
520
  if(empty($discount_prices_lists)){
521
- return $price_html;
522
  }
523
  if(empty($original_prices_list)){
524
- return $price_html;
525
  }
 
526
  $min_price = min($discount_prices_lists);
527
  $max_price = max($discount_prices_lists);
528
  $min_original_price = min($original_prices_list);
492
  return $price_html;
493
  }
494
 
495
+ $original_prices_list = $sale_prices_lists = $discount_prices_lists = array();
496
  $variations = Woocommerce::getProductChildren($product);
497
 
498
  if (!empty($variations)) {
499
+ $consider_out_of_stock_variants = apply_filters('advanced_woo_discount_rules_do_strikeout_for_out_of_stock_variants', false);
500
+
501
  foreach ($variations as $variation_id) {
502
  if (empty($variation_id)) {
503
  continue;
506
  if(!Woocommerce::variationIsVisible($variation)){
507
  continue;
508
  }
509
+ if(!Woocommerce::isProductHasStock($variation) && !$consider_out_of_stock_variants) {
510
  continue;
511
  }
512
  $prices = self::calculateInitialAndDiscountedPrice($variation, $quantity);
513
  if (!isset($prices['initial_price']) || !isset($prices['discounted_price'])) {
514
+ $original_prices_list[] = Woocommerce::getProductRegularPrice($variation);
515
+ $sale_prices_lists[] = Woocommerce::getProductPrice($variation);
516
+ continue;
517
  }
518
  $original_prices_list[] = $prices['initial_price'];
519
  $discount_prices_lists[] = $prices['discounted_price'];
522
  $discount_prices_lists = array_unique($discount_prices_lists);
523
  $original_prices_list = array_unique($original_prices_list);
524
  if(empty($discount_prices_lists)){
525
+ return $this->removeDuplicateStrikeoutPrice($price_html);
526
  }
527
  if(empty($original_prices_list)){
528
+ return $this->removeDuplicateStrikeoutPrice($price_html);
529
  }
530
+ $discount_prices_lists = array_merge($discount_prices_lists, $sale_prices_lists);
531
  $min_price = min($discount_prices_lists);
532
  $max_price = max($discount_prices_lists);
533
  $min_original_price = min($original_prices_list);
v2/App/Controllers/OnSaleShortCode.php CHANGED
@@ -4,6 +4,7 @@ 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
 
@@ -89,14 +90,10 @@ class OnSaleShortCode extends ManageDiscount
89
  }
90
  }
91
 
92
- protected function getSelectedRules($rules_ids){
93
- // To fetch rule based on date and active rules
94
- add_filter('advanced_woo_discount_rules_is_front_end_request_for_fetching_rules', '__return_true', 101);
95
  $rule_helper = new Rule();
96
- $this->updateRebuildRulesInSettings($rules_ids);
97
- $rules = $rule_helper->getAvailableRules($this->getAvailableConditions(), $rules_ids);
98
- remove_filter('advanced_woo_discount_rules_is_front_end_request_for_fetching_rules', '__return_true', 101);
99
- return $rules;
100
  }
101
 
102
  /**
@@ -138,16 +135,19 @@ class OnSaleShortCode extends ManageDiscount
138
  self::setRequiredRebuild(0);
139
  return;
140
  } elseif ($update && is_array($rules_ids)){
 
141
  if(!in_array("all", $rules_ids)){
142
- self::$available_rules = $this->getSelectedRules($rules_ids);
143
  } else {
144
- $this->updateRebuildRulesInSettings($rules_ids);
145
  }
146
  } else {
147
  $rules_ids = self::getReBuildOnSaleRules();
148
  if(!empty($rules_ids)){
149
  if(!in_array("all", $rules_ids)){
150
- self::$available_rules = $this->getSelectedRules($rules_ids);
 
 
151
  }
152
  } else {
153
  return;
@@ -155,7 +155,7 @@ class OnSaleShortCode extends ManageDiscount
155
  }
156
  if (!empty(self::$available_rules)) {
157
  foreach (self::$available_rules as $rule) {
158
- if($rule->rule->enabled == 1 && $rule->rule->deleted == 0) {
159
  if($rule->isSpecificConditionsPassed(['order_date', 'order_time', 'order_date_and_time', 'order_days'])) {
160
  $discount_type = $rule->getRuleDiscountType();
161
  if($discount_type != 'wdr_free_shipping'){
@@ -190,6 +190,9 @@ class OnSaleShortCode extends ManageDiscount
190
  }
191
  $this->mergeAllRebuildRules();
192
  self::setRequiredRebuild(0);
 
 
 
193
  }
194
  }
195
 
@@ -438,17 +441,25 @@ class OnSaleShortCode extends ManageDiscount
438
  function setOnSaleProductQueryArguments(&$query_arguments, $query_type)
439
  {
440
  if($query_type == 'include'){
441
- $operator = '>';
442
- $values = 0;
 
 
 
443
  } else {
444
- $operator = '<=';
445
- $values = 0;
 
 
 
 
 
 
 
 
 
 
446
  }
447
- $query_arguments['meta_query'][] = array(
448
- 'key' => '_sale_price',
449
- 'value' => $values,
450
- 'compare' => $operator,
451
- );
452
  }
453
 
454
  protected function setAttributesQueryArguments(&$query_arguments, $query_type, $values)
4
 
5
  use Wdr\App\Helpers\Helper;
6
  use Wdr\App\Helpers\Rule;
7
+ use Wdr\App\Models\DBTable;
8
 
9
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
 
90
  }
91
  }
92
 
93
+ protected function getRules($rule_ids, $all = false) {
 
 
94
  $rule_helper = new Rule();
95
+ $available_rules = DBTable::getRulesForOnSaleList($rule_ids, $all);
96
+ return $rule_helper->getRuleObject($available_rules, $this->getAvailableConditions());
 
 
97
  }
98
 
99
  /**
135
  self::setRequiredRebuild(0);
136
  return;
137
  } elseif ($update && is_array($rules_ids)){
138
+ $this->updateRebuildRulesInSettings($rules_ids);
139
  if(!in_array("all", $rules_ids)){
140
+ self::$available_rules = $this->getRules($rules_ids);
141
  } else {
142
+ self::$available_rules = $this->getRules(null, true);
143
  }
144
  } else {
145
  $rules_ids = self::getReBuildOnSaleRules();
146
  if(!empty($rules_ids)){
147
  if(!in_array("all", $rules_ids)){
148
+ self::$available_rules = $this->getRules($rules_ids);
149
+ } else {
150
+ self::$available_rules = $this->getRules(null, true);
151
  }
152
  } else {
153
  return;
155
  }
156
  if (!empty(self::$available_rules)) {
157
  foreach (self::$available_rules as $rule) {
158
+ if($rule->rule->enabled == 1) {
159
  if($rule->isSpecificConditionsPassed(['order_date', 'order_time', 'order_date_and_time', 'order_days'])) {
160
  $discount_type = $rule->getRuleDiscountType();
161
  if($discount_type != 'wdr_free_shipping'){
190
  }
191
  $this->mergeAllRebuildRules();
192
  self::setRequiredRebuild(0);
193
+ } else {
194
+ update_option(self::$on_sale_list_key, array());
195
+ self::setRequiredRebuild(0);
196
  }
197
  }
198
 
441
  function setOnSaleProductQueryArguments(&$query_arguments, $query_type)
442
  {
443
  if($query_type == 'include'){
444
+ $query_arguments['meta_query'][] = array(
445
+ 'key' => '_sale_price',
446
+ 'value' => 0,
447
+ 'compare' => '>',
448
+ );
449
  } else {
450
+ $query_arguments['meta_query'][] = array(
451
+ 'relation' => 'OR',
452
+ array(
453
+ 'key' => '_sale_price',
454
+ 'compare' => 'NOT EXISTS',
455
+ ),
456
+ array(
457
+ 'key' => '_sale_price',
458
+ 'value' => 0,
459
+ 'compare' => '<=',
460
+ ),
461
+ );
462
  }
 
 
 
 
 
463
  }
464
 
465
  protected function setAttributesQueryArguments(&$query_arguments, $query_type, $values)
v2/App/Helpers/Filter.php CHANGED
@@ -54,12 +54,14 @@ class Filter
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, $product_table = false)
63
  {
64
  $rule = new Rule();
65
  $status = false;
@@ -110,8 +112,19 @@ class Filter
110
  $product_id = $parant_product_id;
111
  }
112
  $processing_result = $this->compareWithCustomTaxonomy($product_id, $values, $method, $type);
 
 
113
  }
114
- if ($method === 'not_in_list') {
 
 
 
 
 
 
 
 
 
115
  if (!$processing_result) {
116
  $status = false;
117
  break;
54
 
55
  /**
56
  * Match rule filters against product
57
+ * @param object $product
58
+ * @param array|object $filters
59
+ * @param bool $sale_badge
60
+ * @param bool $product_table
61
+ * @param array $extra_data
62
  * @return bool
63
  */
64
+ function matchFilters($product, $filters, $sale_badge, $product_table = false, $extra_data = array())
65
  {
66
  $rule = new Rule();
67
  $status = false;
112
  $product_id = $parant_product_id;
113
  }
114
  $processing_result = $this->compareWithCustomTaxonomy($product_id, $values, $method, $type);
115
+ } else {
116
+ $processing_result = apply_filters('advanced_woo_discount_rules_process_custom_filter', $processing_result, $product, $type, $method, $values, $sale_badge, $product_table, $extra_data);
117
  }
118
+
119
+ $is_valid_filter = apply_filters('advanced_woo_discount_rules_is_valid_filter_type', false, $product, $type, $method, $values, $extra_data);
120
+ if ($is_valid_filter) {
121
+ if (!$processing_result) {
122
+ $status = false;
123
+ break;
124
+ } else {
125
+ $status = true;
126
+ }
127
+ } else if ($method === 'not_in_list') {
128
  if (!$processing_result) {
129
  $status = false;
130
  break;
v2/App/Helpers/Helper.php CHANGED
@@ -332,9 +332,9 @@ class Helper
332
 
333
  public static function displayCompatibleCheckMessages()
334
  {
335
- if (version_compare(WDR_VERSION, '2.4.2', '>=')) {
336
  if (defined('WDR_PRO_VERSION')) {
337
- if (version_compare(WDR_PRO_VERSION, '2.4.2', '<')) {
338
  $url = esc_url(admin_url() . "plugins.php");
339
  $plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', 'woo-discount-rules') . '</a>';
340
  ?>
332
 
333
  public static function displayCompatibleCheckMessages()
334
  {
335
+ if (version_compare(WDR_VERSION, '2.4.4', '>=')) {
336
  if (defined('WDR_PRO_VERSION')) {
337
+ if (version_compare(WDR_PRO_VERSION, '2.4.4', '<')) {
338
  $url = esc_url(admin_url() . "plugins.php");
339
  $plugin_page = '<a target="_blank" href="' . $url . '">' . __('Update now', 'woo-discount-rules') . '</a>';
340
  ?>
v2/App/Helpers/Rule.php CHANGED
@@ -376,7 +376,8 @@ class Rule
376
  /**
377
  * Check the filter is passed for product
378
  * @param $product
379
- * @param $sale_badge
 
380
  * @return bool
381
  */
382
  function isFilterPassed($product, $sale_badge = false, $product_table = false)
@@ -388,7 +389,8 @@ class Rule
388
  $conditionFailed = false;
389
  if (!empty($filters)) {
390
  $filter_helper = new Filter();
391
- $filter_passed = $filter_helper->matchFilters($product, $filters, $sale_badge, $product_table);
 
392
  $conditions = $this->getConditions();
393
  $purchase_first_order_passed = $filter_passed_purchase_first_order = $filter_passed_user_logged_in = $user_logged_in_passed = $filter_passed_user_role = $filter_passed_user_list = $user_role_passed = $user_list_passed = $has_other_conditions = false;
394
  $condition_relationship = $this->getRelationship('condition', 'and');
@@ -595,14 +597,15 @@ class Rule
595
 
596
  /**
597
  * get additional column data
 
598
  * @return array|mixed|object
599
  */
600
- function getAdditionalRuleData()
601
  {
602
  $additional = array();
603
  if (isset($this->rule->additional)) {
604
  if (!empty($this->rule->additional) && $this->rule->additional != '{}' && !$this->rule->additional != '[]') {
605
- $additional = json_decode($this->rule->additional, true);
606
  }
607
  }
608
  return $additional;
@@ -1379,6 +1382,7 @@ class Rule
1379
  }
1380
  }
1381
  $rule_additional = $this->getFromArray($post, 'additional', array());
 
1382
  $product_adjustments = $this->getFromArray($post, 'product_adjustments', array());
1383
  if(isset( $product_adjustments['cart_label']) && !empty( $product_adjustments['cart_label'])){
1384
  $product_adjustments['cart_label'] = self::validateHtmlBeforeSave( $product_adjustments['cart_label']);
@@ -1475,7 +1479,7 @@ class Rule
1475
  $rule_id = DBTable::saveRule($column_format, $arg, $rule_id);
1476
  if($rule_id){
1477
  OnSaleShortCode::updateOnsaleRebuildPageStatus($rule_id);
1478
- do_action('advanced_woo_discount_rules_after_save_rule', $rule_id, $post, $arg);
1479
  }
1480
  return $rule_id;
1481
  }
376
  /**
377
  * Check the filter is passed for product
378
  * @param $product
379
+ * @param bool $sale_badge
380
+ * @param bool $product_table
381
  * @return bool
382
  */
383
  function isFilterPassed($product, $sale_badge = false, $product_table = false)
389
  $conditionFailed = false;
390
  if (!empty($filters)) {
391
  $filter_helper = new Filter();
392
+ $extra_data = apply_filters('advanced_woo_discount_rules_load_custom_filter_data', array(), $this);
393
+ $filter_passed = $filter_helper->matchFilters($product, $filters, $sale_badge, $product_table, $extra_data);
394
  $conditions = $this->getConditions();
395
  $purchase_first_order_passed = $filter_passed_purchase_first_order = $filter_passed_user_logged_in = $user_logged_in_passed = $filter_passed_user_role = $filter_passed_user_list = $user_role_passed = $user_list_passed = $has_other_conditions = false;
396
  $condition_relationship = $this->getRelationship('condition', 'and');
597
 
598
  /**
599
  * get additional column data
600
+ * @param bool $associative
601
  * @return array|mixed|object
602
  */
603
+ function getAdditionalRuleData($associative = true)
604
  {
605
  $additional = array();
606
  if (isset($this->rule->additional)) {
607
  if (!empty($this->rule->additional) && $this->rule->additional != '{}' && !$this->rule->additional != '[]') {
608
+ $additional = json_decode($this->rule->additional, $associative);
609
  }
610
  }
611
  return $additional;
1382
  }
1383
  }
1384
  $rule_additional = $this->getFromArray($post, 'additional', array());
1385
+ $rule_additional = apply_filters('advanced_woo_discount_rules_update_additional_data_before_save_rule', $rule_additional, $post, $this, $rule_id, $rule_filters, $rule_conditions);
1386
  $product_adjustments = $this->getFromArray($post, 'product_adjustments', array());
1387
  if(isset( $product_adjustments['cart_label']) && !empty( $product_adjustments['cart_label'])){
1388
  $product_adjustments['cart_label'] = self::validateHtmlBeforeSave( $product_adjustments['cart_label']);
1479
  $rule_id = DBTable::saveRule($column_format, $arg, $rule_id);
1480
  if($rule_id){
1481
  OnSaleShortCode::updateOnsaleRebuildPageStatus($rule_id);
1482
+ do_action('advanced_woo_discount_rules_after_save_rule', $rule_id, $post, $arg, $rule_additional);
1483
  }
1484
  return $rule_id;
1485
  }
v2/App/Helpers/Woocommerce.php CHANGED
@@ -206,6 +206,19 @@ class Woocommerce
206
  return false;
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  /**
210
  * Get the regular price of the product
211
  * @param $product
@@ -716,7 +729,16 @@ class Woocommerce
716
  $subtotal = 0;
717
  if(isset(WC()->cart) && WC()->cart != null) {
718
  if (method_exists(WC()->cart, 'get_subtotal')) {
719
- $subtotal = WC()->cart->get_subtotal();
 
 
 
 
 
 
 
 
 
720
  } elseif (isset(WC()->cart->subtotal)) {
721
  $subtotal = WC()->cart->subtotal;
722
  }
206
  return false;
207
  }
208
 
209
+ /**
210
+ * Check the product has stock
211
+ * @param $product
212
+ * @return bool
213
+ */
214
+ static function isProductHasStock($product)
215
+ {
216
+ if(!empty($product) && method_exists($product, 'is_in_stock')) {
217
+ return $product->is_in_stock();
218
+ }
219
+ return false;
220
+ }
221
+
222
  /**
223
  * Get the regular price of the product
224
  * @param $product
729
  $subtotal = 0;
730
  if(isset(WC()->cart) && WC()->cart != null) {
731
  if (method_exists(WC()->cart, 'get_subtotal')) {
732
+ $tax_display_type = get_option('woocommerce_tax_display_cart');
733
+ if ($tax_display_type === 'excl') {
734
+ $subtotal = WC()->cart->get_subtotal();
735
+ } else {
736
+ $subtotal = WC()->cart->get_subtotal();
737
+ if (method_exists(WC()->cart, 'get_subtotal_tax')) {
738
+ $subtotal_tax = WC()->cart->get_subtotal_tax();
739
+ $subtotal = $subtotal+$subtotal_tax;
740
+ }
741
+ }
742
  } elseif (isset(WC()->cart->subtotal)) {
743
  $subtotal = WC()->cart->subtotal;
744
  }
v2/App/Models/DBTable.php CHANGED
@@ -231,6 +231,31 @@ class DBTable
231
  return false;
232
  }
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  /**
235
  * save new rule
236
  * @param $format
@@ -293,6 +318,20 @@ class DBTable
293
  $wpdb->update($wpdb->prefix . self::RULES_TABLE_NAME, array('used_limits' => intval($used_count)), array('id' => intval($rule_id)), array('%d'), array('%d'));
294
  }
295
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  /**
297
  * save the order item discount
298
  * @param $order_id
231
  return false;
232
  }
233
 
234
+ /**
235
+ * Get rules for on sale list (indexing)
236
+ *
237
+ * @param array $rule_ids
238
+ * @return array
239
+ */
240
+ public static function getRulesForOnSaleList($rule_ids, $all = false)
241
+ {
242
+ global $wpdb;
243
+ $wpdb->hide_errors();
244
+
245
+ $rules_table_name = $wpdb->prefix . self::RULES_TABLE_NAME;
246
+
247
+ $rule_query = '';
248
+ if (!$all && is_array($rule_ids)) {
249
+ $rule_ids = array_map('absint', $rule_ids);
250
+ $rule_ids = implode(",", $rule_ids);
251
+ $rule_query = "AND id IN ({$rule_ids})";
252
+ }
253
+ $current_time = current_time('timestamp');
254
+
255
+ $query = "SELECT * FROM {$rules_table_name} WHERE enabled = %d AND deleted = %d {$rule_query} 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)";
256
+ return self::$rules['on_sale_list'] = $wpdb->get_results($wpdb->prepare($query, array(1, 0, $current_time, $current_time)), OBJECT);
257
+ }
258
+
259
  /**
260
  * save new rule
261
  * @param $format
318
  $wpdb->update($wpdb->prefix . self::RULES_TABLE_NAME, array('used_limits' => intval($used_count)), array('id' => intval($rule_id)), array('%d'), array('%d'));
319
  }
320
 
321
+ /**
322
+ * Update rule additional data
323
+ *
324
+ * @param int $rule_id
325
+ * @param string $new_additional
326
+ * @return bool
327
+ */
328
+ static function updateRuleAdditionalData($rule_id, $new_additional)
329
+ {
330
+ global $wpdb;
331
+ $rules_table = $wpdb->prefix.self::RULES_TABLE_NAME;
332
+ return $wpdb->update($rules_table, array('additional' => (string) $new_additional), array('id' => (int) $rule_id), array('%s'), array('%d'));
333
+ }
334
+
335
  /**
336
  * save the order item discount
337
  * @param $order_id
v2/App/Views/Admin/Menu.php CHANGED
@@ -10,7 +10,7 @@ if (!defined('ABSPATH')) exit; // Exit if accessed directly
10
  'tab' => $tab_key
11
  );
12
  $target = '';
13
- $link = esc_url(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"';
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"';
v2/Assets/Js/admin_script.js CHANGED
@@ -955,7 +955,7 @@ jQuery(document).ready(function ($) {
955
  * Validate Filter section
956
  * @returns {[]}
957
  */
958
- function wdr_filter_validation() {
959
  let filter_array = [];
960
  $('.wdr-filter-group').each(function (index, element) {
961
  let product_filter = $(element).find('.wdr-product-filter-type').val();
@@ -1011,7 +1011,7 @@ jQuery(document).ready(function ($) {
1011
  case 'product_on_sale':
1012
  break;
1013
  default:
1014
- if (product_filter_val.length == 0) {
1015
  filter_array.push("fails");
1016
  $(element).find('.select2-selection').css("border", "1px solid red");
1017
  $(element).find('.select2-selection').focus();
955
  * Validate Filter section
956
  * @returns {[]}
957
  */
958
+ window.wdr_filter_validation = function wdr_filter_validation() {
959
  let filter_array = [];
960
  $('.wdr-filter-group').each(function (index, element) {
961
  let product_filter = $(element).find('.wdr-product-filter-type').val();
1011
  case 'product_on_sale':
1012
  break;
1013
  default:
1014
+ if (product_filter_val == null || product_filter_val.length == 0) {
1015
  filter_array.push("fails");
1016
  $(element).find('.select2-selection').css("border", "1px solid red");
1017
  $(element).find('.select2-selection').focus();
v2/Assets/Js/admin_script.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function($){let i={counts:1};function j(a){let b=a.val(),c=a.parents(".wdr-conditions-container").attr("data-index");"greater_than_or_equal"==b||"greater_than"==b?$(".promo_show_hide_"+c).show():$(".promo_show_hide_"+c).hide()}function k(a){$.ajax({data:{method:"do_v1_v2_migration",action:"wdr_ajax",awdr_nonce:a},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){void 0!=b.data.status?("completed"==b.data.status?(q(wdr_data.localization_data.processing_migration_success_message,"success",i),location.reload()):k(a),$(".wdr_migration_process_status").html(b.data.display_text)):location.reload()}})}function l(a,b,c=!1){$.ajax({data:{method:"rebuild_onsale_list",action:"wdr_ajax",rules:a,update:c?1:0,awdr_nonce:b.attr("data-awdr_nonce")},type:"post",url:ajaxurl,error:function(a,c){q(wdr_data.localization_data.error,"error",i),b.removeAttr("disabled")},success:function(a){b.html(wdr_data.localization_data.rebuild_on_sale_list_processed_text),b.removeAttr("disabled")}})}function m(a){void 0!==a.required_rebuild&& !0==a.required_rebuild&&($("#awdr_rebuild_on_sale_list_on_rule_page").html(wdr_data.localization_data.rebuild_on_sale_list_build_text),$(".awdr_rebuild_on_sale_rule_page_con").addClass("need_attention"))}function n(a){a.selectWoo({width:"100%",minimumInputLength:1,placeholder:a.data("placeholder"),escapeMarkup:function(a){return a},language:{noResults:function(){return wdr_data.labels.select2_no_results},errorLoading:function(){return wdr_data.labels.searching_text}},ajax:{url:ajaxurl,type:"POST",dataType:"json",delay:250,data:function(b){return{query:b.term,action:"wdr_ajax",method:a.data("list")||"products",awdr_nonce:$("input[name=wdr_ajax_select2]").val()||"",taxonomy:a.data("taxonomy")||"",selected:a.val()}},processResults:function(a){return{results:a.data||[]}}}}),a.parent().find(".select2-search__field").css("width","100%")}function o(a){return 0===a?0:parseInt(a)+1}$(".wdr-btn-add-product-filter").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-filter-block",hideBlockId:".wdr-discount-template, .wdr-advanced-layout-block",thisObject:this})}),$(".add-product-filter").click(function(){var a=$(".wdr-filter-group-items").children().last().attr("data-index");a=o(a),wdr_buildrule.wdr_clone_field({addFilterType:".wdr-build-filter-type",addFilterMethod:".products",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-filter-group-items",newIndex:a}),n($('.wdr-filter-group[data-index="'+a+'"]').find('[data-field="autocomplete"]')),$(".wdr-filter-group[data-index="+a+"]").append("<div class='wdr_filter_desc_text'>"+wdr_data.localization_data.filter_products+"</div>")}),$(document).on("click",".remove-current-row",function(){$(".wdr-filter-group-items > div").length>=2&&wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-filter-group",thisObject:this})}),$(document).on("change",".wdr-product-filter-type",function(){let a=$(this).parents(".wdr-filter-group").data("index"),b=$(this).val();switch(wdr_buildrule.remove_wdr_field_group({parentRow:$(this).parent()}),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+b,addRemoveIcon:".wdr-icon-remove",ruleAppendTo:$(this).parents(".wdr-filter-group"),newIndex:a}),b){case"products":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_products+"</div>");break;case"product_category":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Category+"</div>");break;case"product_attributes":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Attributes+"</div>");break;case"product_tags":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Tags+"</div>");break;case"product_sku":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_SKUs+"</div>");break;case"product_on_sale":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_On_sale_products+"</div>");break;case"all_products":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_all_products+"</div>");break;default:$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_custom_taxonomies+"</div>")}n($(this).parents(".wdr-filter-group").find('[data-field="autocomplete"]'))}),$(".wdr-btn-add-condition").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-condition-template",hideBlockId:".wdr-filter-block, .wdr-discount-template, .wdr-advanced-layout-block",thisObject:this})}),$(".add-product-condition").click(function(){var a=$(".wdr-condition-group-items").children().last().attr("data-index");a=o(a),wdr_buildrule.wdr_clone_field({addConditionType:".wdr-build-condition-type",addFilterMethod:".cart_subtotal",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:a}),"1"==wdr_data.enable_subtotal_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-subtotal-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:a}),$(".subtotal_operator").trigger("change")}),$(document).on("change",".subtotal_operator",function(){"1"==wdr_data.enable_subtotal_promo_text&&j($(this))}),$(document).on("change",".wdr_quantity_operator",function(){"1"==wdr_data.enable_cart_quantity_promo_text&&j($(this))}),$(document).on("click",".remove-current-row",function(){if($(".wdr-condition-group-items > div").length>=2&&(wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-conditions-container",thisObject:this}),"1"==wdr_data.enable_subtotal_promo_text||"1"==wdr_data.enable_cart_quantity_promo_text)){let a=$(this).parent(".wdr-btn-remove").siblings(".wdr-condition-type").find(".wdr-product-condition-type").val();if("cart_subtotal"==a){let b=$(this).parents(".wdr-conditions-container").attr("data-index");$(".promo_show_hide_"+b).remove()}if("cart_items_quantity"==a){let c=$(this).parents(".wdr-conditions-container").attr("data-index");$(".promo_show_hide_"+c).remove()}}}),$(document).on("change",".wdr-product-condition-type",function(){var b=$(this).parents(".wdr-condition-group").data("index"),a=$(this).val();wdr_buildrule.remove_wdr_field_group({parentRow:$(this).parent()}),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+a,addRemoveIcon:".wdr-icon-remove",ruleAppendTo:$(this).parents(".wdr-conditions-container"),newIndex:b});var c=$(this).parents(".wdr-conditions-container").attr("data-index");"undefined"!=$(".promo_show_hide_"+c)[0]&&$(".promo_show_hide_"+c).remove(),"order_time"==a?$(".wdr_time_picker").datetimepicker({datepicker:!1,format:"H:i"}):"cart_subtotal"==a?("1"==wdr_data.enable_subtotal_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-subtotal-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:b}),$(".subtotal_operator").trigger("change")):"cart_items_quantity"==a&&("1"==wdr_data.enable_cart_quantity_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-cart-quantity-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:b}),$(".wdr_quantity_operator").trigger("change")),n($(this).parents(".wdr-conditions-container").find('[data-field="autocomplete"]')),function(a){a.each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},minimumInputLength:1,placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")})}($(this).parents(".wdr-conditions-container").find('[data-field="preloaded"]')),function(a){a.each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")})}($(this).parents(".wdr-conditions-container").find('[data-field="autoloaded"]')),function b(a){a.each(function(c,b){var a=$(b).data("class");"start_dateonly"==a?$('[data-class="'+a+'"]').datetimepicker({format:"Y-m-d",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_dateonly"]').val()&&$('[data-class="end_dateonly"]').val()})},timepicker:!1}):"end_dateonly"==a?$('[data-class="'+a+'"]').datetimepicker({format:"Y-m-d",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_dateonly"]').val()&&$('[data-class="start_dateonly"]').val()})},timepicker:!1}):"start_datetimeonly"==a?$('[data-class="'+a+'"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_datetimeonly"]').val()&&$('[data-class="end_datetimeonly"]').val()})}}):"end_datetimeonly"==a&&$('[data-class="'+a+'"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_datetimeonly"]').val()&&$('[data-class="start_datetimeonly"]').val()})}})})}($(this).parents(".wdr-conditions-container").find('[data-field="date"]'))}),$(document).on("change",".wdr_copon_type",function(){var a=$(this).val();"at_least_one_any"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none")):"none_at_all"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none")):"custom_coupon"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","block")):($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","block"),n($(this).parents(".wdr-conditions-container").find('[data-field="autocomplete"]')))}),$(".wdr-btn-add-discount").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-discount-template",hideBlockId:".wdr-filter-block, .wdr-advanced-layout-block",thisObject:this})}),$(document).on("click",".add_discount_elements",function(){var a=$(this).data("append"),e=$(this).data("discount-method"),c=$(this).data("next-starting-value"),b=$("."+a).children().last().attr("data-index");if(b=o(b),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+e,ruleAppendTo:"."+a,addDiscountElement:"enable",newIndex:b}),""!=c&&"undefined"!=c){$("."+a+" "+c+":last-child").find(".awdr_value_selector").val("");let d=$("."+a+" "+c+":nth-last-child(2)").find(".awdr_auto_add_value").val();""==(d=parseInt(d)+1)||isNaN(d)||$("."+a+" "+c+":nth-last-child(1)").find(".awdr_next_value").val(d)}"add_buyx_gety_range"==e?($(".buyx_gety_individual_range[data-index="+b+"]").find(".awdr-buyx-gety-max").show(),$(".buyx_gety_individual_range[data-index="+b+"]").find(".awdr-bogo-recurcive").prop("checked",!1),$(".wdr-buyx-gety-discount-inner").css("border-bottom","1px solid #ddd")):"add_buyx_getx_range"==e&&($(".buyx_getx_individual_range[data-index="+b+"]").find(".awdr-buyx-getx-max").show(),$(".buyx_getx_individual_range[data-index="+b+"]").find(".awdr-bogo-recurcive").prop("checked",!1),$(".buyx_getx_individual_range").css("border-bottom","1px solid #ddd")),n($("."+a+" div:last-child").find('[data-field="autocomplete"]')),n($("."+a+" div:last-child").find('[data-list="product_category"]'))}),$(document).on("click",".wdr_discount_remove",function(){wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-discount-group",thisObject:this})}),$(document).on("click",'[data-click="wdr-bottombar"]',function(){var a=$(this).data("dtype");$(this).hide(),$("."+a).show()}),$(document).on("click","#awdr_rebuild_on_sale_list",function(){var a=$("#awdr_rebuild_on_sale_rules").val();$(".awdr_rebuild_on_sale_list_notice").html(""),null!=a?($("#awdr_rebuild_on_sale_list").attr("disabled","disabled"),$("#awdr_rebuild_on_sale_list").html(wdr_data.localization_data.rebuild_on_sale_list_processing_text),l(a,$(this),!0)):$(".awdr_rebuild_on_sale_list_notice").html(wdr_data.localization_data.rebuild_on_sale_list_error_please_select_rule)}),$(document).on("click","#awdr_rebuild_on_sale_list_on_rule_page",function(){$(this).attr("disabled","disabled"),$(this).html(wdr_data.localization_data.rebuild_on_sale_list_processing_text),l(null,$(this),!1)}),$(document).on("click","#awdr_do_v1_v2_migration",function(){$(".wdr_migration_process").append(wdr_data.localization_data.processing_migration_text),k($(this).attr("data-awdr_nonce"))}),$(document).on("click","#awdr_skip_v1_v2_migration",function(){$(".wdr_migration_process").append(wdr_data.localization_data.skip_migration_text),$.ajax({data:{method:"skip_v1_v2_migration",action:"wdr_ajax"},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"failed"===a?q(wdr_data.localization_data.error,"error",i):!0===a.data&&($(".wdr_migration_process").append(wdr_data.localization_data.skip_migration_success_message),q(wdr_data.localization_data.skip_migration_success_message,"success",i)),location.reload()}})}),$(".awdr-switch-version-button").on("click",function(a){a.preventDefault();var b=$(this).attr("data-version"),c=$(this).attr("data-page"),d=$(this).attr("data-nonce");$.ajax({url:ajaxurl,type:"POST",data:{action:"awdr_switch_version",version:b,page:c,wdr_nonce:d},success:function(a){!0==a.data.status&&window.location.replace(a.data.url),$(".wdr_switch_message").html(a.data.message)}})}),$(document).on("click",".wdr_duplicate_rule",function(){let a=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("duplicate-rule"),awdr_nonce:$(this).data("awdr_nonce"),method:"duplicate_rule",action:"wdr_ajax"},type:"post",url:ajaxurl,beforeSend:function(){a.show()},complete:function(){a.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"failed"===a?q(wdr_data.localization_data.error,"error",i):q(wdr_data.localization_data.duplicate_rule,"success",i),location.reload()}})}),$(document).on("click",".wdr_delete_rule",function(){var a=$(this).closest("tr");if(confirm(wdr_data.localization_data.delete_confirm)){let b=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("delete-rule"),awdr_nonce:$(this).data("awdr_nonce"),method:"delete_rule",action:"wdr_ajax"},type:"post",url:ajaxurl,beforeSend:function(){b.show()},complete:function(){b.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){b?("failed"===b.status?q(wdr_data.localization_data.error,"error",i):(q(wdr_data.localization_data.deleted_rule,"success",i),a.hide(500,function(){a.remove()})),void 0!==b.build_index&&m(b.build_index)):q(wdr_data.localization_data.error,"error",i)}})}}),$(document).on("change",".wdr_manage_status",function(){let a="",b=$(this).closest("tr");a=!0==$(this).prop("checked")?1:0;let c=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("manage-status"),awdr_nonce:$(this).data("awdr_nonce"),method:"manage_status",action:"wdr_ajax",changeto:a},type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(c){c?"failed"===c.status?q(wdr_data.localization_data.error,"error",i):(1==a?($(b).find(".awdr-enabled-status").show(),q(wdr_data.localization_data.enabled_rule,"success",i)):($(b).find(".awdr-enabled-status").hide(),q(wdr_data.localization_data.disabled_rule,"success",i)),void 0!==c.build_index&&m(c.build_index)):q(wdr_data.localization_data.error,"error",i)}})}),$(".edit-filters").selectWoo({width:"100%",minimumInputLength:1,placeholder:wdr_data.labels.placeholders,language:{noResults:function(){return wdr_data.labels.select2_no_results}},ajax:{url:ajaxurl,type:"POST",dataType:"json",delay:250,data:function(a){return{query:a.term,action:"wdr_ajax",method:$(this).data("list")||"products",awdr_nonce:$("input[name=wdr_ajax_select2]").val()||"",taxonomy:$(this).data("taxonomy")||"",selected:$(this).val()}},processResults:function(a){return{results:a.data||[]}}}}),$(".edit-filters").parent().find(".select2-search__field").css("width","100%"),$(".edit-preloaded-values").each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},minimumInputLength:1,placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")});function p(){let a=[];return $(".wdr-condition-group").each(function(S,b){let c=$(b).find(".wdr-product-condition-type").val();if(void 0!==c)switch(c){case"cart_subtotal":case"cart_items_quantity":case"cart_items_weight":case"cart_line_items_count":""==$(b).find(".float_only_field").val()?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"cart_coupon":let f=$(b).find(".wdr_copon_type").val(),g=$(b).find(".coupon_name_msg").val(),h=$(b).find("#rm-coupon").val();"custom_coupon"==f?""==g?(a.push("fails"),$(b).find(".coupon_name_msg").css("border","1px solid red"),$(b).find(".coupon_name_msg").focus()):$(b).find(".coupon_name_msg").css("border","1px solid #7e8993"):h?$(b).find(".select2-selection").css("border","1px solid #7e8993"):(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus());break;case"cart_payment_method":0==$(b).find(".select2-hidden-accessible").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"cart_item_product_attributes":let i=$(b).find(".awdr-attribute-validation").val(),j=$(b).find(".awdr-num-validation").val();0==i.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==j?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_category":let k=$(b).find(".awdr-category-validation").val(),l=$(b).find(".awdr-num-validation").val();0==k.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==l?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_combination":let m=$(b).find(".awdr-product-validation").val(),d=$(b).find(".product_from_qty").val(),n=$(b).find(".product_to_qty").val(),o=$(b).find(".combination_operator").val();0==m.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),"in_range"==o?""==d&&""==n?(a.push("fails"),$(b).find(".product_from_qty").css("border","1px solid red"),$(b).find(".product_from_qty").focus(),$(b).find(".product_to_qty").css("border","1px solid red"),$(b).find(".product_to_qty").focus()):($(b).find(".product_from_qty").css("border","1px solid #7e8993"),$(b).find(".product_to_qty").css("border","1px solid #7e8993")):""==d?(a.push("fails"),$(b).find(".product_from_qty").css("border","1px solid red"),$(b).find(".product_from_qty").focus()):$(b).find(".product_from_qty").css("border","1px solid #7e8993");break;case"cart_item_product_sku":let p=$(b).find(".awdr-sku-validation").val(),q=$(b).find(".awdr-num-validation").val();0==p.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==q?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_tags":let r=$(b).find(".awdr-tag-validation").val(),s=$(b).find(".awdr-num-validation").val();0==r.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==s?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_products":let t=$(b).find(".awdr-product-validation").val(),u=$(b).find(".awdr-num-validation").val();0==t.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==u?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_category_combination":let v=$(b).find(".awdr-cat-validation").val(),e=$(b).find(".cat_from_qty").val(),w=$(b).find(".cat_to_qty").val(),x=$(b).find(".cat_combination_operator").val();0==v.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),"in_range"==x?""==e&&""==w?(a.push("fails"),$(b).find(".cat_from_qty").css("border","1px solid red"),$(b).find(".cat_from_qty").focus(),$(b).find(".cat_to_qty").css("border","1px solid red"),$(b).find(".cat_to_qty").focus()):($(b).find(".cat_from_qty").css("border","1px solid #7e8993"),$(b).find(".cat_to_qty").css("border","1px solid #7e8993")):""==e?(a.push("fails"),$(b).find(".cat_from_qty").css("border","1px solid red"),$(b).find(".cat_from_qty").focus()):$(b).find(".cat_from_qty").css("border","1px solid #7e8993");break;case"order_date":let y=$(b).find(".awdr-from-date").val(),z=$(b).find(".awdr-end-date").val();""==y&&""==z?(a.push("fails"),$(b).find(".awdr-from-date").css("border","1px solid red"),$(b).find(".awdr-from-date").focus(),$(b).find(".awdr-end-date").css("border","1px solid red"),$(b).find(".awdr-end-date").focus()):($(b).find(".awdr-from-date").css("border","1px solid #7e8993"),$(b).find(".awdr-end-date").css("border","1px solid #7e8993"));break;case"order_date_and_time":let A=$(b).find(".awdr-from-date").val(),B=$(b).find(".awdr-end-date").val();""==A&&""==B?(a.push("fails"),$(b).find(".awdr-from-date").css("border","1px solid red"),$(b).find(".awdr-from-date").focus(),$(b).find(".awdr-end-date").css("border","1px solid red"),$(b).find(".awdr-end-date").focus()):($(b).find(".awdr-from-date").css("border","1px solid #7e8993"),$(b).find(".awdr-end-date").css("border","1px solid #7e8993"));break;case"order_days":0==$(b).find(".wdr_order_days").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"order_time":let C=$(b).find(".wdr-from-time").val(),D=$(b).find(".wdr-to-time").val();""==C&&""==D?(a.push("fails"),$(b).find(".wdr-from-time").css("border","1px solid red"),$(b).find(".wdr-from-time").focus(),$(b).find(".wdr-to-time").css("border","1px solid red"),$(b).find(".wdr-to-time").focus()):($(b).find(".wdr-from-time").css("border","1px solid #7e8993"),$(b).find(".wdr-to-time").css("border","1px solid #7e8993"));break;case"purchase_last_order":0==$(b).find(".wdr-wc-order-status").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"purchase_last_order_amount":let E=$(b).find(".wdr-wc-order-status").val(),F=$(b).find(".float_only_field").val();0==E.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==F?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_previous_orders":let G=$(b).find(".wdr-wc-order-status").val(),H=$(b).find(".float_only_field").val();0==G.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==H?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_previous_orders_for_specific_product":let I=$(b).find(".wdr-wc-order-status").val(),J=$(b).find(".float_only_field").val(),K=$(b).find(".specific_product").val();0==K.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-selector .select2-selection").focus()):$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid #7e8993"),0==I.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-status .select2-selection").focus()):$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid #7e8993"),""==J?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_quantities_for_specific_product":let L=$(b).find(".wdr-wc-order-status").val(),M=$(b).find(".float_only_field").val(),N=$(b).find(".specific_product").val();N?$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid #7e8993"):(a.push("fails"),$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-selector .select2-selection").focus()),0==L.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-status .select2-selection").focus()):$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid #7e8993"),""==M?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_spent":let O=$(b).find(".wdr-wc-order-status").val(),P=$(b).find(".float_only_field").val();0==O.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==P?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"shipping_city":case"shipping_zipcode":case"Billing_city":case"user_email":""==$(b).find(".awdr-validation").val()?(a.push("fails"),$(b).find(".awdr-validation").css("border","1px solid red"),$(b).find(".awdr-validation").focus()):$(b).find(".awdr-validation").css("border","1px solid #7e8993");break;case"shipping_country":0==$(b).find(".get_awdr_shipping_country").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"shipping_state":let Q=$(b).find(".get_awdr_shipping_state").val(),R=$(b).find(".get_awdr_state_based_country").val();0==Q.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),0==R.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"user_list":0==$(b).find(".wdr_user_list").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"user_role":0==$(b).find(".wdr_user_role").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993")}}),a}function q(d,e="success",a=null){switch(e){case"error":var b="wdr-alert-error";break;case"warning":var b="wdr-alert-warning";break;default:var b="wdr-alert-success"}let c="wdr-notify-msg-"+a.counts,f='<div style="display: none;" class="wdr-alert '+b+'" id="'+c+'">'+d+"</div>";$("#notify-msg-holder").append(f);let g=$("#"+c);var h=a.counts;a.counts=parseInt(h)+parseInt(1),g.fadeIn(500),setTimeout(function(){g.fadeOut(500),g.remove()},5e3)}$(".edit-all-loaded-values").each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")}),$("#wdr-save-rule").submit(function(a){if(a.preventDefault(),!function(f){let b=$(".awdr-product-discount-type").val(),c=[],d=[],a=[];switch(b){case"wdr_simple_discount":case"wdr_cart_discount":case"wdr_bulk_discount":case"wdr_set_discount":case"wdr_buy_x_get_x_discount":case"wdr_buy_x_get_y_discount":let e;c=(e=[],$(".wdr-filter-group").each(function(d,a){let b=$(a).find(".wdr-product-filter-type").val(),c=$(a).find(".awdr_validation").val();switch(b){case"all_products":case"product_on_sale":break;default:0==c.length?(e.push("fails"),$(a).find(".select2-selection").css("border","1px solid red"),$(a).find(".select2-selection").focus()):$(a).find(".select2-selection").css("border","1px solid #7e8993")}}),e),d=function e(d){let a=[];switch(d){case"wdr_simple_discount":let b=$(".product_discount_value").val();""!=b&&b?$(".product_discount_value").css("border","1px solid #7e8993"):(a.push("fails"),$(".product_discount_value").css("border","1px solid red"),$(".product_discount_value").focus());break;case"wdr_cart_discount":let c=$(".awdr_cart_discount_value").val();""!=c&&c?$(".awdr_cart_discount_value").css("border","1px solid #7e8993"):(a.push("fails"),$(".awdr_cart_discount_value").css("border","1px solid red"),$(".awdr_cart_discount_value").focus());break;case"wdr_free_shipping":break;case"wdr_bulk_discount":$(".bulk_range_setter").find(".awdr-bulk-group").each(function(g,b){let d=$(b).find(".bulk_discount_min").val(),e=$(b).find(".bulk_discount_max").val(),c=$(b).find(".bulk_discount_value").val();""==d&&""==e?(a.push("fails"),$(b).find(".bulk_discount_min").css("border","1px solid red"),$(b).find(".bulk_discount_min").focus(),$(b).find(".bulk_discount_max").css("border","1px solid red"),$(b).find(".bulk_discount_max").focus()):($(b).find(".bulk_discount_min").css("border","1px solid #7e8993"),$(b).find(".bulk_discount_max").css("border","1px solid #7e8993"));let f=parseInt(c);""==c||f<0?(a.push("fails"),$(b).find(".bulk_discount_value").css("border","1px solid red"),$(b).find(".bulk_discount_value").focus()):$(b).find(".bulk_discount_value").css("border","1px solid #7e8993")});break;case"wdr_set_discount":$(".set_range_setter").find(".bundle-set-range-main").each(function(e,b){let c=$(b).find(".set_discount_min").val(),d=$(b).find(".set_discount_value").val();""==c?(a.push("fails"),$(b).find(".set_discount_min").css("border","1px solid red"),$(b).find(".set_discount_min").focus()):$(b).find(".set_discount_min").css("border","1px solid #7e8993"),""==d?(a.push("fails"),$(b).find(".set_discount_value").css("border","1px solid red"),$(b).find(".set_discount_value").focus()):$(b).find(".set_discount_value").css("border","1px solid #7e8993")});break;case"wdr_buy_x_get_x_discount":$(".buyx_getx_range_setter").find(".buyx_getx_individual_range").each(function(h,b){let c=$(b).find(".bxgx-min").val(),d=$(b).find(".bxgx-max").val(),e=$(b).find(".bxgx-qty").val(),f=$(b).find(".buyx_getx_discount_select").val(),g=$(b).find(".bxgx-value").val();!0==$(b).find(".awdr-bogo-recurcive").prop("checked")&&(""==c?(a.push("fails"),$(b).find(".bxgx-min").css("border","1px solid red"),$(b).find(".bxgx-min").focus()):$(b).find(".bxgx-min").css("border","1px solid #7e8993")),""==c&&""==d?(a.push("fails"),$(b).find(".bxgx-min").css("border","1px solid red"),$(b).find(".bxgx-min").focus(),$(b).find(".bxgx-max").css("border","1px solid red"),$(b).find(".bxgx-max").focus()):($(b).find(".bxgx-min").css("border","1px solid #7e8993"),$(b).find(".bxgx-max").css("border","1px solid #7e8993")),""==e?(a.push("fails"),$(b).find(".bxgx-qty").css("border","1px solid red"),$(b).find(".bxgx-qty").focus()):$(b).find(".bxgx-qty").css("border","1px solid #7e8993"),"free_product"!=f&&""==g?(a.push("fails"),$(b).find(".bxgx-value").css("border","1px solid red"),$(b).find(".bxgx-value").focus()):$(b).find(".bxgx-value").css("border","1px solid #7e8993")});break;case"wdr_buy_x_get_y_discount":let f=$(".select_bxgy_type").val();$(".awdr_buyx_gety_range_setter").find(".buyx_gety_individual_range").each(function(k,b){let c=$(b).find(".bxgy-min").val(),d=$(b).find(".bxgy-max").val(),e=$(b).find(".bxgy-product-selector").val(),g=$(b).find(".bxgy-category-selector").val(),h=$(b).find(".bxgy-qty").val(),i=$(b).find(".buyx_gety_discount_select").val(),j=$(b).find(".bxgy-val").val();"bxgy_product"==f?0==e.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"):"bxgy_category"==f?0==g.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"):"0"!=f&&f?$(".select_bxgy_type").css("border","1px solid #7e8993"):(a.push("fails"),$(".select_bxgy_type").css("border","1px solid red"),$(".select_bxgy_type").focus()),!0==$(b).find(".awdr-bogo-recurcive").prop("checked")&&(""==c?(a.push("fails"),$(b).find(".bxgy-min").css("border","1px solid red"),$(b).find(".bxgy-min").focus()):$(b).find(".bxgy-min").css("border","1px solid #7e8993")),""==c&&""==d?(a.push("fails"),$(b).find(".bxgy-min").css("border","1px solid red"),$(b).find(".bxgy-min").focus(),$(b).find(".bxgy-max").css("border","1px solid red"),$(b).find(".bxgy-max").focus()):($(b).find(".bxgy-min").css("border","1px solid #7e8993"),$(b).find(".bxgy-max").css("border","1px solid #7e8993")),""==h?(a.push("fails"),$(b).find(".bxgy-qty").css("border","1px solid red"),$(b).find(".bxgy-qty").focus()):$(b).find(".bxgy-qty").css("border","1px solid #7e8993"),"free_product"!=i&&""==j?(a.push("fails"),$(b).find(".bxgy-val").css("border","1px solid red"),$(b).find(".bxgy-val").focus()):$(b).find(".bxgy-val").css("border","1px solid #7e8993")});break;default:a.push("fails")}return a}(b),a=p();break;case"wdr_free_shipping":a=p()}return -1===c.indexOf("fails")&& -1===d.indexOf("fails")&& -1===a.indexOf("fails")}($(this)))return!1;let b=$(".woo_discount_loader");$.ajax({data:$(this).serialize(),type:"post",url:ajaxurl,beforeSend:function(){b.show()},complete:function(){b.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){var a=b.data;if(b.success)void 0!=a.build_index&&m(a.build_index),a.redirect?(window.location.href=a.redirect,q(wdr_data.localization_data.save_rule,"success",i)):($(".wdr_desc_text.coupon_error_msg").hide(),$(".coupon_name_msg").css("border",""),q(wdr_data.localization_data.save_rule,"success",i));else if(a.coupon_message)$(".coupon_name_msg").css("border","1px solid #FF0000").focus(),q(wdr_data.localization_data.coupon_exists,"error",i);else for(let[c,d]of Object.entries(a))a.hasOwnProperty(c)&&d.forEach(function(a){q(a,"error",i)})}})}),$(document).on("click",".wdr_save_close",function(){$("input[name=wdr_save_close]").val("1"),$(".wdr_save_stay").click()}),$("#configuration-form").submit(function(a){a.preventDefault();let b=$(this).serialize(),c=$(".woo_discount_loader");$.ajax({data:b,type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){switch(a.data.save_popup){case"alert_in_popup":"alert_in_popup"==a.data.save_popup&&"passed"==a.data.security_pass?($(".awdr-save-green").show(),setTimeout(function(){$(".awdr-save-green").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},2e3)):"alert_in_popup"==a.data.save_popup&&"fails"==a.data.security_pass&&($(".awdr-error-red").show(),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},2e3));break;case"alert_in_normal":"alert_in_normal"==a.data.save_popup&&"passed"==a.data.security_pass?(q(wdr_data.localization_data.save_settings,"success",i),setTimeout(function(){window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3)):"alert_in_normal"==a.data.save_popup&&"fails"==a.data.security_pass&&(q(wdr_data.localization_data.error,"error",i),setTimeout(function(){window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3));break;default:$(".awdr-error-red").show(),q(wdr_data.localization_data.error,"error",i),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3)}}})}),$("#awdr_advanced_configuration_form").submit(function(a){a.preventDefault();let b=$(this).serialize(),c=$(".woo_discount_loader");$.ajax({data:b,type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"passed"==a.data.security_pass?($(".awdr-save-green").show(),setTimeout(function(){$(".awdr-save-green").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=advanced_section")},2e3)):"fails"==a.data.security_pass&&($(".awdr-error-red").show(),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=advanced_section")},2e3))}})}),$(document).on("click",".bulk-table-customized-setting",function(){$("input[name=customizer_save_alert]").val("1"),$(".save-configuration-submit").click()}),$("#sort_customizable_table").dragtable({persistState:function(a){a.el.find("th").each(function(b){""!=this.id&&(a.sortOrder[this.id]=b,"customize-bulk-table-title"==this.id?$(".customize_bulk_table_title").val(b):"customize-bulk-table-discount"==this.id?$(".customize_bulk_table_discount").val(b):"customize-bulk-table-range"==this.id&&$(".customize_bulk_table_range").val(b))})}}),$("#wdr-bulk-action-top").submit(function(c){if(c.preventDefault(),!($('input[name="saved_rules[]"]:checked').length>0))return!1;{let b=$("#bulk-action-selector-top").val(),a;if("enable"==b)a=confirm("Are you sure to enable the selected rules?");else if("disable"==b)a=confirm("Are you sure to disable the selected rules?");else{if("delete"!=b)return!1;a=confirm("Are you sure to delete the selected rules?")}if(!1==a)return!1}let d=$(".woo_discount_loader");$.ajax({data:$(this).serialize(),type:"post",url:ajaxurl,beforeSend:function(){d.show()},complete:function(){d.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"disabled"==a.disable?q(wdr_data.localization_data.disabled_rule,"success",i):"enabled"==a.enable?q(wdr_data.localization_data.enabled_rule,"success",i):"deleted"==a.delete?q(wdr_data.localization_data.deleted_rule,"success",i):q(wdr_data.localization_data.error,"error",i),window.location.replace(wdr_data.admin_url)}})}),$("#wdr-search-top").submit(function(b){b.preventDefault();var a=$(this).serializeArray(),c=a[0].value,d=a[1].value;window.location.replace(c+"&name="+d)}),$(document).on("keypress keyup blur",".float_only_field",function(a){$(this).val($(this).val().replace(/[^0-9\.]/g,"")),(46!==a.which|| -1!==$(this).val().indexOf("."))&&(a.which<48||a.which>57)&&a.preventDefault()}),$(document).on("keypress keyup blur",".number_only_field",function(a){(a.which<48||a.which>57)&&a.preventDefault()}),$('[data-class="start_dateonly"]').datetimepicker({timepicker:!1,format:"Y-m-d",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_dateonly"]').val()&&$('[data-class="end_dateonly"]').val()})}}),$('[data-class="end_dateonly"]').datetimepicker({timepicker:!1,format:"Y-m-d",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_dateonly"]').val()&&$('[data-class="start_dateonly"]').val()})}}),$('[data-class="start_datetimeonly"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_datetimeonly"]').val()&&$('[data-class="end_datetimeonly"]').val()})}}),$('[data-class="end_datetimeonly"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_datetimeonly"]').val()&&$('[data-class="start_datetimeonly"]').val()})}}),$(".wdr_time_picker").datetimepicker({datepicker:!1,format:"H:i"}),$(document).on("change",".wdr-bulk-type",function(){"product_selected_categories"==$(this).val()?$(".wdr-bulk-cat-selector").show():$(".wdr-bulk-cat-selector").hide()}),$(".settings_option_show_hide").click(function(){var a=$(this).data("name");"1"==$(this).val()?($("."+a).show(),"hide_table_position"==a&&$(".wdr-popup-link").show()):($("."+a).hide(),"hide_table_position"==a&&$(".wdr-popup-link").hide())}),$(".bulk_table_customizer_preview").click(function(){var a=$(this).data("colname");"show"==$(this).data("showhide")?$("."+a).show():$("."+a).hide()}),$(".settings_option_show_hide_on_change").change(function(){"disabled"==$(this).val()?$(".display_you_saved_text").hide():$(".display_you_saved_text").show()}),$(document).on("change",".wdr-rules-select",function(){var a=$(".wdr-rules-select"),b=$(this).val();"off"==b?(a.val("on"),$(".wdr-rules-selector").prop("checked",!0)):"on"==b&&(a.val("off"),$(".wdr-rules-selector").prop("checked",!1))}),$(document).on("change",".wdr-rules-selector",function(){var a=$(".wdr-rules-select"),b=$(".wdr-ruleboard input:checkbox").length,c=$(".wdr-ruleboard input:checkbox:checked").length;b==c?(a.val("on"),a.prop("checked",!0)):b!=c&&(a.val("off"),a.prop("checked",!1))}),document.getElementById("ruleHeader");var a,e=!1;function f(){$("#sortable").sortable({handle:".awdr-sortable-handle",delay:150,stop:function(b,c){var a=new Array;$("#sortable>tr").each(function(){a.push($(this).attr("id"))}),r(a)}})}function r(a){$.ajax({data:{position:a,method:"update_priority_order",action:"wdr_ajax",awdr_nonce:$("input[name=awdr_rule_list_nonce]").val()},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){!1===a?q(wdr_data.localization_data.error,"error",i):q(wdr_data.localization_data.save_priority,"success",i)}})}(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))&&(e=!0),$(window).width()>1024?!0==e?f():$("#sortable").sortable({delay:150,stop:function(b,c){var a=new Array;$("#sortable>tr").each(function(){a.push($(this).attr("id"))}),r(a)}}):f(),$("#sortable").disableSelection(),$(document).on("click",".help-popup",function(){var a="#"+$(this).attr("data-id");$(a).dialog({modal:!0,closeText:""})}),$(document).on("click",".remove-clicked-discount-block",function(){var a=$(this).data("showblock"),b=$(this).data("removeval"),c=$(this).data("removeopt");$("."+a).hide(),$("."+b).removeAttr("value"),$("."+c).prop("selectedIndex",0),$("[data-dtype="+a+"]").show(),"wdr-bulk-discount"==a&&($(".bulk_product_category_selector option:selected").remove(),$(".wdr-bulk-cat-selector").hide())}),$(".wdr-btn-add-message").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-advanced-layout-block",hideBlockId:".wdr-discount-template, .wdr-filter-block",thisObject:this})});var b=$(".bulk-min").length;if(b>=2){var c=$(".bulk_discount_min").val(),h=$(".bulk_discount_max").val(),d=$(".bulk_discount_value").val();(c||h||d)&&$(".adv-msg-min-qty, .adv-msg-max-qty").show()}var b=$(".set-min").length;if(b>=2){var c=$(".set_discount_min").val(),d=$(".set_discount_value").val();(c||d)&&($(".adv-msg-min-qty").show(),$(".adv-msg-max-qty").hide())}function s(){$(".wdr-condition-group").each(function(c,b){let a=$(b).find(".wdr-product-condition-type").val();void 0!==a&&"cart_item_product_onsale"===a&&$(this).remove()})}$(".popup_table_discount_column_value").click(function(){1==$(this).val()?($(".wdr_table_discounted_value").show(),$(".wdr_table_discounted_price").hide()):($(".wdr_table_discounted_value").hide(),$(".wdr_table_discounted_price").show())}),$(".modal-trigger").click(function(a){a.preventDefault(),dataModal=$(this).attr("data-modal"),$("#"+dataModal).css({display:"block"})}),$(".close-modal, .modal-sandbox").click(function(){$(".modal").css({display:"none"})}),$("#badge_colorpicker").on("change",function(){$("#badge_hexcolor").val(this.value)}),$("#badge_hexcolor").on("change",function(){$("#badge_colorpicker").val(this.value)}),$("#text_colorpicker").on("change",function(){$("#text_hexcolor").val(this.value)}),$("#text_hexcolor").on("change",function(){$("#text_colorpicker").val(this.value)}),$("#awdr_shortcode_copy_btn").on("click",function(){b="#awdr_shortcode_text",c=$("<input>"),$("body").append(c),c.val($(b).text()).select(),document.execCommand("copy"),c.remove();var b,c,a=$(this);a.html(wdr_data.localization_data.copied),setTimeout(function(){a.html(wdr_data.localization_data.copy_shortcode)},2e3)}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$(".awdr_popup_col_name_text_box").keyup(function(){var a=$(this).val(),b=$(this).data("keyup");$("."+b).html(a)}),$(".awdr_popup_col_name_text_box").blur(function(){var a=$(this).val(),b=$(this).data("keyup");$("."+b).html(a)}),$(".apply_product_and_cart_discount_to").change(function(){let a=$(this).data("subsequent");"all"==$(this).val()?$("."+a).show():$("."+a).hide()}),$(document).on("change",".awdr-bogo-discount-type",function(){let c=$(this).val(),a=$(this).attr("data-parent"),b=$(this).attr("data-siblings");switch(c){case"flat":$(this).parent("."+a).siblings("."+b).show(),$(this).parent("."+a).siblings("."+b).find(".wdr_desc_text").text(wdr_data.localization_data.buyx_getx_value);break;case"percentage":$(this).parent("."+a).siblings("."+b).show(),$(this).parent("."+a).siblings("."+b).find(".wdr_desc_text").text(wdr_data.localization_data.buyx_getx_percentage);break;default:$(this).parent("."+a).siblings("."+b).hide()}}),$(document).on("change",".awdr-bogo-recurcive",function(){let c=$(this).attr("data-recursive-row"),a=$(this).attr("data-recursive-parent"),d=$(this).attr("data-hide-add-range"),b=$(this).attr("data-bogo-max-range"),e=$(this).attr("data-bogo-min-range"),f=$(this).attr("data-bogo-border"),h=$("."+c).length,g=$(this).attr("data-ranges-row-parent");if(!1==$(this).prop("checked")){$(this).parents("."+g).siblings("."+d).show(),""!=b&&($(this).parents("."+a).siblings("."+b).show(),$(this).parents("."+a).siblings().find("."+b).show()),$(this).parents("."+a).siblings("."+e).find(".wdr_desc_text").text(wdr_data.localization_data.recursive_min_qty),$("."+f).css("border-bottom","1px solid #ddd");return}h>3&&(confirm(wdr_data.localization_data.recursive_warning)?$(this).parents("."+c).siblings().remove():$(this).prop("checked",!1)),!0==$(this).prop("checked")&&($(this).parents("."+g).siblings("."+d).hide(),""!=b&&($(this).parents("."+a).siblings("."+b).hide(),$(this).parents("."+a).siblings().find("."+b).hide()),$(this).parents("."+a).siblings("."+e).find(".wdr_desc_text").text(wdr_data.localization_data.recursive_qty),$("."+f).css("border-bottom","unset"))}),$(document).on("change",".awdr_mode_of_operator",function(){let a=$(this).val();if("wdr_buy_x_get_y_discount"==$(".awdr-product-discount-type").val()){"variation"==a?($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_variants_discount_description_tool_tip),$(".awdr-example").html(wdr_data.localization_data.mode_variation_cumulative_example)):"product"==a?($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_individual_product_discount_description_tool_tip),$(".awdr-example").html("")):($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_filter_together_discount_description_tool_tip),$(".awdr-example").html(""));return}"variation"==a?($(".awdr-discount-content").html(wdr_data.localization_data.bulk_variants_discount_description),$(".awdr-example").html(wdr_data.localization_data.mode_variation_cumulative_example)):"product"==a?($(".awdr-discount-content").html(wdr_data.localization_data.bulk_individual_product_discount_description),$(".awdr-example").html("")):($(".awdr-discount-content").html(wdr_data.localization_data.bulk_filter_together_discount_description),$(".awdr-example").html(""))}),$(document).on("change",".awdr-product-discount-type",function(){$(".awdr-example").html("");var c=$(this).data("placement");let a=$(this).val(),b="awdr_doc_";switch(a){case"wdr_simple_discount":$("."+b+a).show(),$(".awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_cart_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_free_shipping":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_bulk_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_set_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_buy_x_get_x_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_buy_x_get_y_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount").hide();break;default:$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide()}"not_selected"!=$(this).val()&&"wdr_free_shipping"!=$(this).val()?(wdr_buildrule.wdr_clone_field({addFilterMethod:"."+$(this).val(),ruleAppendTo:"."+c,addDiscountType:"enable"}),$(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".calculate_cart_from option[value='from_filter']").show(),$(".adv-msg-discount, .adv-msg-discount-price").show(),$(".awdr-hidden-new-rule").fadeIn(500),$(".awdr-filter-section").fadeIn(500),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"),n($("."+c).find('[data-field="autocomplete"]')),$(".awdr-discount-container").show(),$("."+c).find(".bulk_range_setter_group").addClass("bulk_range_setter").attr("id","bulk_adjustment_sortable"),$("."+c).find(".set_range_setter_group").addClass("set_range_setter").attr("id","bulk_adjustment_sortable"),$(window).width()>1024?!0==e?$("#bulk_adjustment_sortable").sortable({handle:".awdr-sortable-handle"}):$("#bulk_adjustment_sortable").sortable():$("#bulk_adjustment_sortable").sortable({handle:".awdr-sortable-handle"}),$("#bulk_adjustment_sortable").disableSelection(),$(".awdr-filter-heading").html(wdr_data.localization_data.common_filter_heading),$(".awdr-filter-content").html(wdr_data.localization_data.common_filter_description),$(".awdr-discount-heading").html(wdr_data.localization_data.common_discount_heading),$(".awdr-discount-content").html(wdr_data.localization_data.common_discount_description),$(".awdr-rules-content").html(wdr_data.localization_data.common_rules_description),"wdr_buy_x_get_y_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_bxgy_discount_heading),n($("."+c).find('[data-list="product_category"]')),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide()),"wdr_buy_x_get_x_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide()),"wdr_bulk_discount"==$(this).val()?($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_bulk_discount_heading),$(".awdr_mode_of_operator").trigger("change"),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").show()):"wdr_set_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr_mode_of_operator").trigger("change"),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_set_discount_heading),$(".adv-msg-min-qty, .adv-msg-discount, .adv-msg-discount-price").show(),$(".adv-msg-max-qty").hide())):"wdr_free_shipping"==$(this).val()?($(".awdr-free-shipping-special-condition").removeClass("wdr-hide"),$(".awdr-hidden-new-rule").fadeIn(500),$(".awdr-filter-section").fadeOut(),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"),$("."+c).html(""),$(".awdr-discount-container").hide(),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide(),$(".calculate_cart_from option[value='from_filter']").hide()):($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!0).addClass("wdr_save_btn_disabled"),$(".awdr-hidden-new-rule").fadeOut(500)),$(this).trigger("advanced_woo_discount_rules_on_change_adjustment_type",[$(this).val()])}),$(".awdr-product-discount-type").trigger("change"),"view"==wdr_data.rule_id?$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"):$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!0).addClass("wdr_save_btn_disabled"),$(document).on("change",".apply_fee_coupon_checkbox",function(){!0==$(this).prop("checked")?$(this).parents(".awdr_rtl_compatible").siblings(".apply_fee_coupon_label").show():$(this).parents(".awdr_rtl_compatible").siblings(".apply_fee_coupon_label").hide()}),$(document).on("change",".bulk_table_customizer_show_hide_column",function(){var a=$(this).data("colname");!0==$(this).prop("checked")?$("."+a).show():$("."+a).hide()});var g=document.getElementsByClassName("awdr-accordion");for(a=0;a<g.length;a++)g[a].addEventListener("click",function(b){b.preventDefault(),this.classList.toggle("awdr-accordion-active");var a=this.nextElementSibling;"block"===a.style.display?$(a).slideUp(1e3):$(a).slideDown(1e3)});$(document).on("change",".on_sale_badge_condition",function(){"disabled"===$(this).val()?($(".sale_badge_toggle").hide(),$(".sale_badge_customizer,.sale_badge_percentage_customizer").hide()):($(".sale_badge_toggle").show(),!0==$("#customize_on_sale_badge").prop("checked")?($(".sale_badge_customizer").show(),$(".display_percentage_on_sale_badge_con").show()):($(".sale_badge_customizer").hide(),$("#display_percentage_on_sale_badge").prop("checked",!1).trigger("change"),$(".display_percentage_on_sale_badge_con").hide()),!0==$("#display_percentage_on_sale_badge").prop("checked")?$(".sale_badge_percentage_customizer").show():$(".sale_badge_percentage_customizer").hide())}),$(document).on("change","#customize_on_sale_badge",function(){!0==$(this).prop("checked")?($(".sale_badge_customizer").show(),$(".display_percentage_on_sale_badge_con").show()):($(".sale_badge_customizer").hide(),$("#display_percentage_on_sale_badge").prop("checked",!1).trigger("change"),$(".display_percentage_on_sale_badge_con").hide())}),$(document).on("change","#display_percentage_on_sale_badge",function(){!0==$(this).prop("checked")?$(".sale_badge_percentage_customizer").show():$(".sale_badge_percentage_customizer").hide()}),$(document).on("change","#badge_colorpicker",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("background-color",a)}),$(document).on("change","#badge_hexcolor",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("background-color",a)}),$(document).on("change","#text_colorpicker",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("color",a)}),$(document).on("change","#text_hexcolor",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("color",a)}),$(document).on("change","#awdr_discount_bar_content",function(){let a=$(this).val();$(".awdr_admin_discount_bar").html(a)}),$(document).on("click",".awdr-hidden-search",function(){let a=$(".awdr-hidden-name").val();$(".wdr-rule-search-key").val(a),$("#wdr-search-top").submit()}),$(document).on("change","#select_usage_limits",function(){let a=$("#select_usage_limits").val();if(""==a)$(".awdr-rule-limit-disabled-outer .rule_limit_msg_outer").hide(),$(".awdr-rule-limit-disabled").hide();else{var b=$(".awdr-used-limit-total").html();a<=parseInt(b)?($(".awdr-rule-limit-disabled").hide(),$(".awdr-rule-limit-disabled-outer").show(),$(".awdr-rule-limit-disabled-outer .rule_limit_msg_outer").html(wdr_data.localization_data.invalid_rule_limit)):($(".awdr-rule-limit-disabled").hide(),$(".awdr-rule-limit-disabled-outer").hide())}}),$("#awdr-import-csv").on("submit",function(){return!!new RegExp("([a-zA-Z0-9s_\\.-:])+(.csv)$").test($("#awdr-file-uploader").val().toLowerCase())||($("#awdr-upload-response").html(wdr_data.localization_data.invalid_file_type),!1)}),$(document).on("change",".get_awdr_state_based_country",function(){let a=$(this).val();if(!a||""==a||0==a.length)return!1;let b=$(this).parents(".wdr-conditions-container").attr("data-index"),e=$(this).parents(".wdr_shipping_state_group"),f=$(this).parent().siblings(".wdr-shipping-state-value"),g=$(".woo_discount_loader"),c=$(this).parent().siblings(".wdr-shipping-state-value").find(".get_awdr_shipping_state").val();var d={action:"wdr_ajax",method:"get_state_details",selected_country:a,selected_state:c,selected_index:b,awdr_nonce:$("input[name=wdr_ajax_select2]").val()||""};$.ajax({url:ajaxurl,data:d,type:"POST",beforeSend:function(){g.show()},complete:function(){g.hide()},success:function(a){f.remove(),e.append("<div class='wdr-shipping-state-value wdr-select-filed-hight wdr-search-box' style='width: min-content;'>"+a.data+"<span class='wdr_select2_desc_text'>"+wdr_data.localization_data.select_state+"</span> </div>"),$(".append-preloaded-values").selectWoo()},error:function(a){console.log("error")}})}),$(".get_awdr_state_based_country").trigger("change"),$(document).on("change",".wdr_copon_type",function(){var a=$(this).val();"custom_coupon"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one, .wdr-cart-coupon-url-all").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","block")):"at_least_one"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom, .wdr-cart-coupon-url-all").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","block")):"all"===a&&($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom, .wdr-cart-coupon-url-one").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","block"))}),$(document).on("click",".wdr-copy-coupon-url",function(a){a.preventDefault(),$(this).parents(".wdr-coupon-url-group").find("input[type=url]").select(),document.execCommand("copy")?($(this).html(wdr_data.localization_data.coupon_url_copied),q(wdr_data.localization_data.coupon_url_success,"success",i)):q(wdr_data.localization_data.error,"error",i)}),$(document).on("change",".wdr-cart-coupon-url-enable",function(a){a.preventDefault(),$(this).closest(".wdr-cart-coupon-url").find(".wdr-cart-coupon-url-lists").slideToggle()}),$(document).on("change keyup",".wdr-cart-coupon-value input",function(){var b=wdr_data.home_url,a=$(this).val();""!==a?($group='<span class="wdr-coupon-url-group"><label>',$group+=' <input type="url" value="'+b+"?wdr_coupon="+encodeURIComponent(a)+'"></label>',$group+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span>",$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").html($group),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","block")):$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","none")}),$(document).on("change",".wdr-cart-coupon-search select, select.wdr_copon_type",function(){var a=wdr_data.home_url,b=$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search select").val(),c=$(this).parents(".wdr_cart_coupon_group").find("select.wdr_copon_type").val();if(0!==b.length){if("at_least_one"===c)$groups="",b.forEach(function(b){$groups+='<span class="wdr-coupon-url-group"><label>',$groups+=' <input type="url" value="'+a+"?wdr_coupon="+encodeURIComponent(b)+'"></label>',$groups+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span><br>"}),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").html($groups),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","block");else if("all"===c){var d="";a+="?wdr_coupon=",b.forEach(function(b){d+=b+", ",a+=encodeURIComponent(b)+","}),d=d.replace(/(^, )|(, $)/g,""),a=a.replace(/(^,)|(,$)/g,""),$group='<span class="wdr-coupon-url-group"><label>',$group+=' <input type="url" value="'+a+'"></label>',$group+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span>",$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").html($group),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","block")}}else $(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","none")})})
1
+ jQuery(document).ready(function($){let i={counts:1};function j(a){let b=a.val(),c=a.parents(".wdr-conditions-container").attr("data-index");"greater_than_or_equal"==b||"greater_than"==b?$(".promo_show_hide_"+c).show():$(".promo_show_hide_"+c).hide()}function k(a){$.ajax({data:{method:"do_v1_v2_migration",action:"wdr_ajax",awdr_nonce:a},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){void 0!=b.data.status?("completed"==b.data.status?(q(wdr_data.localization_data.processing_migration_success_message,"success",i),location.reload()):k(a),$(".wdr_migration_process_status").html(b.data.display_text)):location.reload()}})}function l(a,b,c=!1){$.ajax({data:{method:"rebuild_onsale_list",action:"wdr_ajax",rules:a,update:c?1:0,awdr_nonce:b.attr("data-awdr_nonce")},type:"post",url:ajaxurl,error:function(a,c){q(wdr_data.localization_data.error,"error",i),b.removeAttr("disabled")},success:function(a){b.html(wdr_data.localization_data.rebuild_on_sale_list_processed_text),b.removeAttr("disabled")}})}function m(a){void 0!==a.required_rebuild&& !0==a.required_rebuild&&($("#awdr_rebuild_on_sale_list_on_rule_page").html(wdr_data.localization_data.rebuild_on_sale_list_build_text),$(".awdr_rebuild_on_sale_rule_page_con").addClass("need_attention"))}function n(a){a.selectWoo({width:"100%",minimumInputLength:1,placeholder:a.data("placeholder"),escapeMarkup:function(a){return a},language:{noResults:function(){return wdr_data.labels.select2_no_results},errorLoading:function(){return wdr_data.labels.searching_text}},ajax:{url:ajaxurl,type:"POST",dataType:"json",delay:250,data:function(b){return{query:b.term,action:"wdr_ajax",method:a.data("list")||"products",awdr_nonce:$("input[name=wdr_ajax_select2]").val()||"",taxonomy:a.data("taxonomy")||"",selected:a.val()}},processResults:function(a){return{results:a.data||[]}}}}),a.parent().find(".select2-search__field").css("width","100%")}function o(a){return 0===a?0:parseInt(a)+1}$(".wdr-btn-add-product-filter").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-filter-block",hideBlockId:".wdr-discount-template, .wdr-advanced-layout-block",thisObject:this})}),$(".add-product-filter").click(function(){var a=$(".wdr-filter-group-items").children().last().attr("data-index");a=o(a),wdr_buildrule.wdr_clone_field({addFilterType:".wdr-build-filter-type",addFilterMethod:".products",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-filter-group-items",newIndex:a}),n($('.wdr-filter-group[data-index="'+a+'"]').find('[data-field="autocomplete"]')),$(".wdr-filter-group[data-index="+a+"]").append("<div class='wdr_filter_desc_text'>"+wdr_data.localization_data.filter_products+"</div>")}),$(document).on("click",".remove-current-row",function(){$(".wdr-filter-group-items > div").length>=2&&wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-filter-group",thisObject:this})}),$(document).on("change",".wdr-product-filter-type",function(){let a=$(this).parents(".wdr-filter-group").data("index"),b=$(this).val();switch(wdr_buildrule.remove_wdr_field_group({parentRow:$(this).parent()}),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+b,addRemoveIcon:".wdr-icon-remove",ruleAppendTo:$(this).parents(".wdr-filter-group"),newIndex:a}),b){case"products":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_products+"</div>");break;case"product_category":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Category+"</div>");break;case"product_attributes":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Attributes+"</div>");break;case"product_tags":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_Tags+"</div>");break;case"product_sku":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_SKUs+"</div>");break;case"product_on_sale":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_On_sale_products+"</div>");break;case"all_products":$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_all_products+"</div>");break;default:$('.wdr-filter-group[data-index="'+a+'"]').append('<div class="wdr_filter_desc_text">'+wdr_data.localization_data.filter_custom_taxonomies+"</div>")}n($(this).parents(".wdr-filter-group").find('[data-field="autocomplete"]'))}),$(".wdr-btn-add-condition").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-condition-template",hideBlockId:".wdr-filter-block, .wdr-discount-template, .wdr-advanced-layout-block",thisObject:this})}),$(".add-product-condition").click(function(){var a=$(".wdr-condition-group-items").children().last().attr("data-index");a=o(a),wdr_buildrule.wdr_clone_field({addConditionType:".wdr-build-condition-type",addFilterMethod:".cart_subtotal",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:a}),"1"==wdr_data.enable_subtotal_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-subtotal-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:a}),$(".subtotal_operator").trigger("change")}),$(document).on("change",".subtotal_operator",function(){"1"==wdr_data.enable_subtotal_promo_text&&j($(this))}),$(document).on("change",".wdr_quantity_operator",function(){"1"==wdr_data.enable_cart_quantity_promo_text&&j($(this))}),$(document).on("click",".remove-current-row",function(){if($(".wdr-condition-group-items > div").length>=2&&(wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-conditions-container",thisObject:this}),"1"==wdr_data.enable_subtotal_promo_text||"1"==wdr_data.enable_cart_quantity_promo_text)){let a=$(this).parent(".wdr-btn-remove").siblings(".wdr-condition-type").find(".wdr-product-condition-type").val();if("cart_subtotal"==a){let b=$(this).parents(".wdr-conditions-container").attr("data-index");$(".promo_show_hide_"+b).remove()}if("cart_items_quantity"==a){let c=$(this).parents(".wdr-conditions-container").attr("data-index");$(".promo_show_hide_"+c).remove()}}}),$(document).on("change",".wdr-product-condition-type",function(){var b=$(this).parents(".wdr-condition-group").data("index"),a=$(this).val();wdr_buildrule.remove_wdr_field_group({parentRow:$(this).parent()}),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+a,addRemoveIcon:".wdr-icon-remove",ruleAppendTo:$(this).parents(".wdr-conditions-container"),newIndex:b});var c=$(this).parents(".wdr-conditions-container").attr("data-index");"undefined"!=$(".promo_show_hide_"+c)[0]&&$(".promo_show_hide_"+c).remove(),"order_time"==a?$(".wdr_time_picker").datetimepicker({datepicker:!1,format:"H:i"}):"cart_subtotal"==a?("1"==wdr_data.enable_subtotal_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-subtotal-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:b}),$(".subtotal_operator").trigger("change")):"cart_items_quantity"==a&&("1"==wdr_data.enable_cart_quantity_promo_text&&wdr_buildrule.wdr_clone_field({addConditionType:"empty-promo",addFilterMethod:".wdr-cart-quantity-promo-messeage-main",addRemoveIcon:".wdr-icon-remove",ruleAppendTo:".wdr-condition-group-items",newIndex:b}),$(".wdr_quantity_operator").trigger("change")),n($(this).parents(".wdr-conditions-container").find('[data-field="autocomplete"]')),function(a){a.each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},minimumInputLength:1,placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")})}($(this).parents(".wdr-conditions-container").find('[data-field="preloaded"]')),function(a){a.each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")})}($(this).parents(".wdr-conditions-container").find('[data-field="autoloaded"]')),function b(a){a.each(function(c,b){var a=$(b).data("class");"start_dateonly"==a?$('[data-class="'+a+'"]').datetimepicker({format:"Y-m-d",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_dateonly"]').val()&&$('[data-class="end_dateonly"]').val()})},timepicker:!1}):"end_dateonly"==a?$('[data-class="'+a+'"]').datetimepicker({format:"Y-m-d",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_dateonly"]').val()&&$('[data-class="start_dateonly"]').val()})},timepicker:!1}):"start_datetimeonly"==a?$('[data-class="'+a+'"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_datetimeonly"]').val()&&$('[data-class="end_datetimeonly"]').val()})}}):"end_datetimeonly"==a&&$('[data-class="'+a+'"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_datetimeonly"]').val()&&$('[data-class="start_datetimeonly"]').val()})}})})}($(this).parents(".wdr-conditions-container").find('[data-field="date"]'))}),$(document).on("change",".wdr_copon_type",function(){var a=$(this).val();"at_least_one_any"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none")):"none_at_all"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none")):"custom_coupon"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","block")):($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-value").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search").css("display","block"),n($(this).parents(".wdr-conditions-container").find('[data-field="autocomplete"]')))}),$(".wdr-btn-add-discount").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-discount-template",hideBlockId:".wdr-filter-block, .wdr-advanced-layout-block",thisObject:this})}),$(document).on("click",".add_discount_elements",function(){var a=$(this).data("append"),e=$(this).data("discount-method"),c=$(this).data("next-starting-value"),b=$("."+a).children().last().attr("data-index");if(b=o(b),wdr_buildrule.wdr_clone_field({addFilterMethod:"."+e,ruleAppendTo:"."+a,addDiscountElement:"enable",newIndex:b}),""!=c&&"undefined"!=c){$("."+a+" "+c+":last-child").find(".awdr_value_selector").val("");let d=$("."+a+" "+c+":nth-last-child(2)").find(".awdr_auto_add_value").val();""==(d=parseInt(d)+1)||isNaN(d)||$("."+a+" "+c+":nth-last-child(1)").find(".awdr_next_value").val(d)}"add_buyx_gety_range"==e?($(".buyx_gety_individual_range[data-index="+b+"]").find(".awdr-buyx-gety-max").show(),$(".buyx_gety_individual_range[data-index="+b+"]").find(".awdr-bogo-recurcive").prop("checked",!1),$(".wdr-buyx-gety-discount-inner").css("border-bottom","1px solid #ddd")):"add_buyx_getx_range"==e&&($(".buyx_getx_individual_range[data-index="+b+"]").find(".awdr-buyx-getx-max").show(),$(".buyx_getx_individual_range[data-index="+b+"]").find(".awdr-bogo-recurcive").prop("checked",!1),$(".buyx_getx_individual_range").css("border-bottom","1px solid #ddd")),n($("."+a+" div:last-child").find('[data-field="autocomplete"]')),n($("."+a+" div:last-child").find('[data-list="product_category"]'))}),$(document).on("click",".wdr_discount_remove",function(){wdr_buildrule.remove_wdr_field_group({parentsRow:".wdr-discount-group",thisObject:this})}),$(document).on("click",'[data-click="wdr-bottombar"]',function(){var a=$(this).data("dtype");$(this).hide(),$("."+a).show()}),$(document).on("click","#awdr_rebuild_on_sale_list",function(){var a=$("#awdr_rebuild_on_sale_rules").val();$(".awdr_rebuild_on_sale_list_notice").html(""),null!=a?($("#awdr_rebuild_on_sale_list").attr("disabled","disabled"),$("#awdr_rebuild_on_sale_list").html(wdr_data.localization_data.rebuild_on_sale_list_processing_text),l(a,$(this),!0)):$(".awdr_rebuild_on_sale_list_notice").html(wdr_data.localization_data.rebuild_on_sale_list_error_please_select_rule)}),$(document).on("click","#awdr_rebuild_on_sale_list_on_rule_page",function(){$(this).attr("disabled","disabled"),$(this).html(wdr_data.localization_data.rebuild_on_sale_list_processing_text),l(null,$(this),!1)}),$(document).on("click","#awdr_do_v1_v2_migration",function(){$(".wdr_migration_process").append(wdr_data.localization_data.processing_migration_text),k($(this).attr("data-awdr_nonce"))}),$(document).on("click","#awdr_skip_v1_v2_migration",function(){$(".wdr_migration_process").append(wdr_data.localization_data.skip_migration_text),$.ajax({data:{method:"skip_v1_v2_migration",action:"wdr_ajax"},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"failed"===a?q(wdr_data.localization_data.error,"error",i):!0===a.data&&($(".wdr_migration_process").append(wdr_data.localization_data.skip_migration_success_message),q(wdr_data.localization_data.skip_migration_success_message,"success",i)),location.reload()}})}),$(".awdr-switch-version-button").on("click",function(a){a.preventDefault();var b=$(this).attr("data-version"),c=$(this).attr("data-page"),d=$(this).attr("data-nonce");$.ajax({url:ajaxurl,type:"POST",data:{action:"awdr_switch_version",version:b,page:c,wdr_nonce:d},success:function(a){!0==a.data.status&&window.location.replace(a.data.url),$(".wdr_switch_message").html(a.data.message)}})}),$(document).on("click",".wdr_duplicate_rule",function(){let a=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("duplicate-rule"),awdr_nonce:$(this).data("awdr_nonce"),method:"duplicate_rule",action:"wdr_ajax"},type:"post",url:ajaxurl,beforeSend:function(){a.show()},complete:function(){a.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"failed"===a?q(wdr_data.localization_data.error,"error",i):q(wdr_data.localization_data.duplicate_rule,"success",i),location.reload()}})}),$(document).on("click",".wdr_delete_rule",function(){var a=$(this).closest("tr");if(confirm(wdr_data.localization_data.delete_confirm)){let b=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("delete-rule"),awdr_nonce:$(this).data("awdr_nonce"),method:"delete_rule",action:"wdr_ajax"},type:"post",url:ajaxurl,beforeSend:function(){b.show()},complete:function(){b.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){b?("failed"===b.status?q(wdr_data.localization_data.error,"error",i):(q(wdr_data.localization_data.deleted_rule,"success",i),a.hide(500,function(){a.remove()})),void 0!==b.build_index&&m(b.build_index)):q(wdr_data.localization_data.error,"error",i)}})}}),$(document).on("change",".wdr_manage_status",function(){let a="",b=$(this).closest("tr");a=!0==$(this).prop("checked")?1:0;let c=$(".woo_discount_loader");$.ajax({data:{rowid:$(this).data("manage-status"),awdr_nonce:$(this).data("awdr_nonce"),method:"manage_status",action:"wdr_ajax",changeto:a},type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(c){c?"failed"===c.status?q(wdr_data.localization_data.error,"error",i):(1==a?($(b).find(".awdr-enabled-status").show(),q(wdr_data.localization_data.enabled_rule,"success",i)):($(b).find(".awdr-enabled-status").hide(),q(wdr_data.localization_data.disabled_rule,"success",i)),void 0!==c.build_index&&m(c.build_index)):q(wdr_data.localization_data.error,"error",i)}})}),$(".edit-filters").selectWoo({width:"100%",minimumInputLength:1,placeholder:wdr_data.labels.placeholders,language:{noResults:function(){return wdr_data.labels.select2_no_results}},ajax:{url:ajaxurl,type:"POST",dataType:"json",delay:250,data:function(a){return{query:a.term,action:"wdr_ajax",method:$(this).data("list")||"products",awdr_nonce:$("input[name=wdr_ajax_select2]").val()||"",taxonomy:$(this).data("taxonomy")||"",selected:$(this).val()}},processResults:function(a){return{results:a.data||[]}}}}),$(".edit-filters").parent().find(".select2-search__field").css("width","100%"),$(".edit-preloaded-values").each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},minimumInputLength:1,placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")});function p(){let a=[];return $(".wdr-condition-group").each(function(S,b){let c=$(b).find(".wdr-product-condition-type").val();if(void 0!==c)switch(c){case"cart_subtotal":case"cart_items_quantity":case"cart_items_weight":case"cart_line_items_count":""==$(b).find(".float_only_field").val()?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"cart_coupon":let f=$(b).find(".wdr_copon_type").val(),g=$(b).find(".coupon_name_msg").val(),h=$(b).find("#rm-coupon").val();"custom_coupon"==f?""==g?(a.push("fails"),$(b).find(".coupon_name_msg").css("border","1px solid red"),$(b).find(".coupon_name_msg").focus()):$(b).find(".coupon_name_msg").css("border","1px solid #7e8993"):h?$(b).find(".select2-selection").css("border","1px solid #7e8993"):(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus());break;case"cart_payment_method":0==$(b).find(".select2-hidden-accessible").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"cart_item_product_attributes":let i=$(b).find(".awdr-attribute-validation").val(),j=$(b).find(".awdr-num-validation").val();0==i.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==j?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_category":let k=$(b).find(".awdr-category-validation").val(),l=$(b).find(".awdr-num-validation").val();0==k.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==l?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_combination":let m=$(b).find(".awdr-product-validation").val(),d=$(b).find(".product_from_qty").val(),n=$(b).find(".product_to_qty").val(),o=$(b).find(".combination_operator").val();0==m.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),"in_range"==o?""==d&&""==n?(a.push("fails"),$(b).find(".product_from_qty").css("border","1px solid red"),$(b).find(".product_from_qty").focus(),$(b).find(".product_to_qty").css("border","1px solid red"),$(b).find(".product_to_qty").focus()):($(b).find(".product_from_qty").css("border","1px solid #7e8993"),$(b).find(".product_to_qty").css("border","1px solid #7e8993")):""==d?(a.push("fails"),$(b).find(".product_from_qty").css("border","1px solid red"),$(b).find(".product_from_qty").focus()):$(b).find(".product_from_qty").css("border","1px solid #7e8993");break;case"cart_item_product_sku":let p=$(b).find(".awdr-sku-validation").val(),q=$(b).find(".awdr-num-validation").val();0==p.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==q?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_product_tags":let r=$(b).find(".awdr-tag-validation").val(),s=$(b).find(".awdr-num-validation").val();0==r.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==s?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_products":let t=$(b).find(".awdr-product-validation").val(),u=$(b).find(".awdr-num-validation").val();0==t.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==u?(a.push("fails"),$(b).find(".awdr-num-validation").css("border","1px solid red"),$(b).find(".awdr-num-validation").focus()):$(b).find(".awdr-num-validation").css("border","1px solid #7e8993");break;case"cart_item_category_combination":let v=$(b).find(".awdr-cat-validation").val(),e=$(b).find(".cat_from_qty").val(),w=$(b).find(".cat_to_qty").val(),x=$(b).find(".cat_combination_operator").val();0==v.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),"in_range"==x?""==e&&""==w?(a.push("fails"),$(b).find(".cat_from_qty").css("border","1px solid red"),$(b).find(".cat_from_qty").focus(),$(b).find(".cat_to_qty").css("border","1px solid red"),$(b).find(".cat_to_qty").focus()):($(b).find(".cat_from_qty").css("border","1px solid #7e8993"),$(b).find(".cat_to_qty").css("border","1px solid #7e8993")):""==e?(a.push("fails"),$(b).find(".cat_from_qty").css("border","1px solid red"),$(b).find(".cat_from_qty").focus()):$(b).find(".cat_from_qty").css("border","1px solid #7e8993");break;case"order_date":let y=$(b).find(".awdr-from-date").val(),z=$(b).find(".awdr-end-date").val();""==y&&""==z?(a.push("fails"),$(b).find(".awdr-from-date").css("border","1px solid red"),$(b).find(".awdr-from-date").focus(),$(b).find(".awdr-end-date").css("border","1px solid red"),$(b).find(".awdr-end-date").focus()):($(b).find(".awdr-from-date").css("border","1px solid #7e8993"),$(b).find(".awdr-end-date").css("border","1px solid #7e8993"));break;case"order_date_and_time":let A=$(b).find(".awdr-from-date").val(),B=$(b).find(".awdr-end-date").val();""==A&&""==B?(a.push("fails"),$(b).find(".awdr-from-date").css("border","1px solid red"),$(b).find(".awdr-from-date").focus(),$(b).find(".awdr-end-date").css("border","1px solid red"),$(b).find(".awdr-end-date").focus()):($(b).find(".awdr-from-date").css("border","1px solid #7e8993"),$(b).find(".awdr-end-date").css("border","1px solid #7e8993"));break;case"order_days":0==$(b).find(".wdr_order_days").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"order_time":let C=$(b).find(".wdr-from-time").val(),D=$(b).find(".wdr-to-time").val();""==C&&""==D?(a.push("fails"),$(b).find(".wdr-from-time").css("border","1px solid red"),$(b).find(".wdr-from-time").focus(),$(b).find(".wdr-to-time").css("border","1px solid red"),$(b).find(".wdr-to-time").focus()):($(b).find(".wdr-from-time").css("border","1px solid #7e8993"),$(b).find(".wdr-to-time").css("border","1px solid #7e8993"));break;case"purchase_last_order":0==$(b).find(".wdr-wc-order-status").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"purchase_last_order_amount":let E=$(b).find(".wdr-wc-order-status").val(),F=$(b).find(".float_only_field").val();0==E.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==F?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_previous_orders":let G=$(b).find(".wdr-wc-order-status").val(),H=$(b).find(".float_only_field").val();0==G.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==H?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_previous_orders_for_specific_product":let I=$(b).find(".wdr-wc-order-status").val(),J=$(b).find(".float_only_field").val(),K=$(b).find(".specific_product").val();0==K.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-selector .select2-selection").focus()):$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid #7e8993"),0==I.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-status .select2-selection").focus()):$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid #7e8993"),""==J?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_quantities_for_specific_product":let L=$(b).find(".wdr-wc-order-status").val(),M=$(b).find(".float_only_field").val(),N=$(b).find(".specific_product").val();N?$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid #7e8993"):(a.push("fails"),$(b).find(".wdr-previous-order-product-selector .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-selector .select2-selection").focus()),0==L.length?(a.push("fails"),$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid red"),$(b).find(".wdr-previous-order-product-status .select2-selection").focus()):$(b).find(".wdr-previous-order-product-status .select2-selection").css("border","1px solid #7e8993"),""==M?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"purchase_spent":let O=$(b).find(".wdr-wc-order-status").val(),P=$(b).find(".float_only_field").val();0==O.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),""==P?(a.push("fails"),$(b).find(".float_only_field").css("border","1px solid red"),$(b).find(".float_only_field").focus()):$(b).find(".float_only_field").css("border","1px solid #7e8993");break;case"shipping_city":case"shipping_zipcode":case"Billing_city":case"user_email":""==$(b).find(".awdr-validation").val()?(a.push("fails"),$(b).find(".awdr-validation").css("border","1px solid red"),$(b).find(".awdr-validation").focus()):$(b).find(".awdr-validation").css("border","1px solid #7e8993");break;case"shipping_country":0==$(b).find(".get_awdr_shipping_country").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"shipping_state":let Q=$(b).find(".get_awdr_shipping_state").val(),R=$(b).find(".get_awdr_state_based_country").val();0==Q.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"),0==R.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"user_list":0==$(b).find(".wdr_user_list").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;case"user_role":0==$(b).find(".wdr_user_role").val().length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993")}}),a}function q(d,e="success",a=null){switch(e){case"error":var b="wdr-alert-error";break;case"warning":var b="wdr-alert-warning";break;default:var b="wdr-alert-success"}let c="wdr-notify-msg-"+a.counts,f='<div style="display: none;" class="wdr-alert '+b+'" id="'+c+'">'+d+"</div>";$("#notify-msg-holder").append(f);let g=$("#"+c);var h=a.counts;a.counts=parseInt(h)+parseInt(1),g.fadeIn(500),setTimeout(function(){g.fadeOut(500),g.remove()},5e3)}$(".edit-all-loaded-values").each(function(d,b){var a=$(b),c=wdr_data.lists[a.data("list")];a.selectWoo({width:"100%",escapeMarkup:function(a){return a},placeholder:a.data("placeholder"),language:{noResults:function(){return wdr_data.labels.select2_no_results}},data:c}),a.parent().find(".select2-search__field").css("width","100%")}),$("#wdr-save-rule").submit(function(a){if(a.preventDefault(),!function(e){let b=$(".awdr-product-discount-type").val(),c=[],d=[],a=[];switch(b){case"wdr_simple_discount":case"wdr_cart_discount":case"wdr_bulk_discount":case"wdr_set_discount":case"wdr_buy_x_get_x_discount":case"wdr_buy_x_get_y_discount":c=wdr_filter_validation(),d=function e(d){let a=[];switch(d){case"wdr_simple_discount":let b=$(".product_discount_value").val();""!=b&&b?$(".product_discount_value").css("border","1px solid #7e8993"):(a.push("fails"),$(".product_discount_value").css("border","1px solid red"),$(".product_discount_value").focus());break;case"wdr_cart_discount":let c=$(".awdr_cart_discount_value").val();""!=c&&c?$(".awdr_cart_discount_value").css("border","1px solid #7e8993"):(a.push("fails"),$(".awdr_cart_discount_value").css("border","1px solid red"),$(".awdr_cart_discount_value").focus());break;case"wdr_free_shipping":break;case"wdr_bulk_discount":$(".bulk_range_setter").find(".awdr-bulk-group").each(function(g,b){let d=$(b).find(".bulk_discount_min").val(),e=$(b).find(".bulk_discount_max").val(),c=$(b).find(".bulk_discount_value").val();""==d&&""==e?(a.push("fails"),$(b).find(".bulk_discount_min").css("border","1px solid red"),$(b).find(".bulk_discount_min").focus(),$(b).find(".bulk_discount_max").css("border","1px solid red"),$(b).find(".bulk_discount_max").focus()):($(b).find(".bulk_discount_min").css("border","1px solid #7e8993"),$(b).find(".bulk_discount_max").css("border","1px solid #7e8993"));let f=parseInt(c);""==c||f<0?(a.push("fails"),$(b).find(".bulk_discount_value").css("border","1px solid red"),$(b).find(".bulk_discount_value").focus()):$(b).find(".bulk_discount_value").css("border","1px solid #7e8993")});break;case"wdr_set_discount":$(".set_range_setter").find(".bundle-set-range-main").each(function(e,b){let c=$(b).find(".set_discount_min").val(),d=$(b).find(".set_discount_value").val();""==c?(a.push("fails"),$(b).find(".set_discount_min").css("border","1px solid red"),$(b).find(".set_discount_min").focus()):$(b).find(".set_discount_min").css("border","1px solid #7e8993"),""==d?(a.push("fails"),$(b).find(".set_discount_value").css("border","1px solid red"),$(b).find(".set_discount_value").focus()):$(b).find(".set_discount_value").css("border","1px solid #7e8993")});break;case"wdr_buy_x_get_x_discount":$(".buyx_getx_range_setter").find(".buyx_getx_individual_range").each(function(h,b){let c=$(b).find(".bxgx-min").val(),d=$(b).find(".bxgx-max").val(),e=$(b).find(".bxgx-qty").val(),f=$(b).find(".buyx_getx_discount_select").val(),g=$(b).find(".bxgx-value").val();!0==$(b).find(".awdr-bogo-recurcive").prop("checked")&&(""==c?(a.push("fails"),$(b).find(".bxgx-min").css("border","1px solid red"),$(b).find(".bxgx-min").focus()):$(b).find(".bxgx-min").css("border","1px solid #7e8993")),""==c&&""==d?(a.push("fails"),$(b).find(".bxgx-min").css("border","1px solid red"),$(b).find(".bxgx-min").focus(),$(b).find(".bxgx-max").css("border","1px solid red"),$(b).find(".bxgx-max").focus()):($(b).find(".bxgx-min").css("border","1px solid #7e8993"),$(b).find(".bxgx-max").css("border","1px solid #7e8993")),""==e?(a.push("fails"),$(b).find(".bxgx-qty").css("border","1px solid red"),$(b).find(".bxgx-qty").focus()):$(b).find(".bxgx-qty").css("border","1px solid #7e8993"),"free_product"!=f&&""==g?(a.push("fails"),$(b).find(".bxgx-value").css("border","1px solid red"),$(b).find(".bxgx-value").focus()):$(b).find(".bxgx-value").css("border","1px solid #7e8993")});break;case"wdr_buy_x_get_y_discount":let f=$(".select_bxgy_type").val();$(".awdr_buyx_gety_range_setter").find(".buyx_gety_individual_range").each(function(k,b){let c=$(b).find(".bxgy-min").val(),d=$(b).find(".bxgy-max").val(),e=$(b).find(".bxgy-product-selector").val(),g=$(b).find(".bxgy-category-selector").val(),h=$(b).find(".bxgy-qty").val(),i=$(b).find(".buyx_gety_discount_select").val(),j=$(b).find(".bxgy-val").val();"bxgy_product"==f?0==e.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"):"bxgy_category"==f?0==g.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993"):"0"!=f&&f?$(".select_bxgy_type").css("border","1px solid #7e8993"):(a.push("fails"),$(".select_bxgy_type").css("border","1px solid red"),$(".select_bxgy_type").focus()),!0==$(b).find(".awdr-bogo-recurcive").prop("checked")&&(""==c?(a.push("fails"),$(b).find(".bxgy-min").css("border","1px solid red"),$(b).find(".bxgy-min").focus()):$(b).find(".bxgy-min").css("border","1px solid #7e8993")),""==c&&""==d?(a.push("fails"),$(b).find(".bxgy-min").css("border","1px solid red"),$(b).find(".bxgy-min").focus(),$(b).find(".bxgy-max").css("border","1px solid red"),$(b).find(".bxgy-max").focus()):($(b).find(".bxgy-min").css("border","1px solid #7e8993"),$(b).find(".bxgy-max").css("border","1px solid #7e8993")),""==h?(a.push("fails"),$(b).find(".bxgy-qty").css("border","1px solid red"),$(b).find(".bxgy-qty").focus()):$(b).find(".bxgy-qty").css("border","1px solid #7e8993"),"free_product"!=i&&""==j?(a.push("fails"),$(b).find(".bxgy-val").css("border","1px solid red"),$(b).find(".bxgy-val").focus()):$(b).find(".bxgy-val").css("border","1px solid #7e8993")});break;default:a.push("fails")}return a}(b),a=p();break;case"wdr_free_shipping":a=p()}return -1===c.indexOf("fails")&& -1===d.indexOf("fails")&& -1===a.indexOf("fails")}($(this)))return!1;let b=$(".woo_discount_loader");$.ajax({data:$(this).serialize(),type:"post",url:ajaxurl,beforeSend:function(){b.show()},complete:function(){b.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(b){var a=b.data;if(b.success)void 0!=a.build_index&&m(a.build_index),a.redirect?(window.location.href=a.redirect,q(wdr_data.localization_data.save_rule,"success",i)):($(".wdr_desc_text.coupon_error_msg").hide(),$(".coupon_name_msg").css("border",""),q(wdr_data.localization_data.save_rule,"success",i));else if(a.coupon_message)$(".coupon_name_msg").css("border","1px solid #FF0000").focus(),q(wdr_data.localization_data.coupon_exists,"error",i);else for(let[c,d]of Object.entries(a))a.hasOwnProperty(c)&&d.forEach(function(a){q(a,"error",i)})}})}),$(document).on("click",".wdr_save_close",function(){$("input[name=wdr_save_close]").val("1"),$(".wdr_save_stay").click()}),window.wdr_filter_validation=function(){let a=[];return $(".wdr-filter-group").each(function(e,b){let d=$(b).find(".wdr-product-filter-type").val(),c=$(b).find(".awdr_validation").val();switch(d){case"all_products":case"product_on_sale":break;case"products":case"product_category":case"product_attributes":case"product_tags":case"product_sku":0==c.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993");break;default:null==c||0==c.length?(a.push("fails"),$(b).find(".select2-selection").css("border","1px solid red"),$(b).find(".select2-selection").focus()):$(b).find(".select2-selection").css("border","1px solid #7e8993")}}),a},$("#configuration-form").submit(function(a){a.preventDefault();let b=$(this).serialize(),c=$(".woo_discount_loader");$.ajax({data:b,type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){switch(a.data.save_popup){case"alert_in_popup":"alert_in_popup"==a.data.save_popup&&"passed"==a.data.security_pass?($(".awdr-save-green").show(),setTimeout(function(){$(".awdr-save-green").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},2e3)):"alert_in_popup"==a.data.save_popup&&"fails"==a.data.security_pass&&($(".awdr-error-red").show(),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},2e3));break;case"alert_in_normal":"alert_in_normal"==a.data.save_popup&&"passed"==a.data.security_pass?(q(wdr_data.localization_data.save_settings,"success",i),setTimeout(function(){window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3)):"alert_in_normal"==a.data.save_popup&&"fails"==a.data.security_pass&&(q(wdr_data.localization_data.error,"error",i),setTimeout(function(){window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3));break;default:$(".awdr-error-red").show(),q(wdr_data.localization_data.error,"error",i),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=settings")},1e3)}}})}),$("#awdr_advanced_configuration_form").submit(function(a){a.preventDefault();let b=$(this).serialize(),c=$(".woo_discount_loader");$.ajax({data:b,type:"post",url:ajaxurl,beforeSend:function(){c.show()},complete:function(){c.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"passed"==a.data.security_pass?($(".awdr-save-green").show(),setTimeout(function(){$(".awdr-save-green").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=advanced_section")},2e3)):"fails"==a.data.security_pass&&($(".awdr-error-red").show(),setTimeout(function(){$(".awdr-error-red").fadeOut(500),window.location.replace(wdr_data.admin_url+"&tab=advanced_section")},2e3))}})}),$(document).on("click",".bulk-table-customized-setting",function(){$("input[name=customizer_save_alert]").val("1"),$(".save-configuration-submit").click()}),$("#sort_customizable_table").dragtable({persistState:function(a){a.el.find("th").each(function(b){""!=this.id&&(a.sortOrder[this.id]=b,"customize-bulk-table-title"==this.id?$(".customize_bulk_table_title").val(b):"customize-bulk-table-discount"==this.id?$(".customize_bulk_table_discount").val(b):"customize-bulk-table-range"==this.id&&$(".customize_bulk_table_range").val(b))})}}),$("#wdr-bulk-action-top").submit(function(c){if(c.preventDefault(),!($('input[name="saved_rules[]"]:checked').length>0))return!1;{let b=$("#bulk-action-selector-top").val(),a;if("enable"==b)a=confirm("Are you sure to enable the selected rules?");else if("disable"==b)a=confirm("Are you sure to disable the selected rules?");else{if("delete"!=b)return!1;a=confirm("Are you sure to delete the selected rules?")}if(!1==a)return!1}let d=$(".woo_discount_loader");$.ajax({data:$(this).serialize(),type:"post",url:ajaxurl,beforeSend:function(){d.show()},complete:function(){d.hide()},error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){"disabled"==a.disable?q(wdr_data.localization_data.disabled_rule,"success",i):"enabled"==a.enable?q(wdr_data.localization_data.enabled_rule,"success",i):"deleted"==a.delete?q(wdr_data.localization_data.deleted_rule,"success",i):q(wdr_data.localization_data.error,"error",i),window.location.replace(wdr_data.admin_url)}})}),$("#wdr-search-top").submit(function(b){b.preventDefault();var a=$(this).serializeArray(),c=a[0].value,d=a[1].value;window.location.replace(c+"&name="+d)}),$(document).on("keypress keyup blur",".float_only_field",function(a){$(this).val($(this).val().replace(/[^0-9\.]/g,"")),(46!==a.which|| -1!==$(this).val().indexOf("."))&&(a.which<48||a.which>57)&&a.preventDefault()}),$(document).on("keypress keyup blur",".number_only_field",function(a){(a.which<48||a.which>57)&&a.preventDefault()}),$('[data-class="start_dateonly"]').datetimepicker({timepicker:!1,format:"Y-m-d",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_dateonly"]').val()&&$('[data-class="end_dateonly"]').val()})}}),$('[data-class="end_dateonly"]').datetimepicker({timepicker:!1,format:"Y-m-d",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_dateonly"]').val()&&$('[data-class="start_dateonly"]').val()})}}),$('[data-class="start_datetimeonly"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({maxDate:!!$('[data-class="end_datetimeonly"]').val()&&$('[data-class="end_datetimeonly"]').val()})}}),$('[data-class="end_datetimeonly"]').datetimepicker({timepicker:!0,format:"Y-m-d H:i",onShow:function(a){this.setOptions({minDate:!!$('[data-class="start_datetimeonly"]').val()&&$('[data-class="start_datetimeonly"]').val()})}}),$(".wdr_time_picker").datetimepicker({datepicker:!1,format:"H:i"}),$(document).on("change",".wdr-bulk-type",function(){"product_selected_categories"==$(this).val()?$(".wdr-bulk-cat-selector").show():$(".wdr-bulk-cat-selector").hide()}),$(".settings_option_show_hide").click(function(){var a=$(this).data("name");"1"==$(this).val()?($("."+a).show(),"hide_table_position"==a&&$(".wdr-popup-link").show()):($("."+a).hide(),"hide_table_position"==a&&$(".wdr-popup-link").hide())}),$(".bulk_table_customizer_preview").click(function(){var a=$(this).data("colname");"show"==$(this).data("showhide")?$("."+a).show():$("."+a).hide()}),$(".settings_option_show_hide_on_change").change(function(){"disabled"==$(this).val()?$(".display_you_saved_text").hide():$(".display_you_saved_text").show()}),$(document).on("change",".wdr-rules-select",function(){var a=$(".wdr-rules-select"),b=$(this).val();"off"==b?(a.val("on"),$(".wdr-rules-selector").prop("checked",!0)):"on"==b&&(a.val("off"),$(".wdr-rules-selector").prop("checked",!1))}),$(document).on("change",".wdr-rules-selector",function(){var a=$(".wdr-rules-select"),b=$(".wdr-ruleboard input:checkbox").length,c=$(".wdr-ruleboard input:checkbox:checked").length;b==c?(a.val("on"),a.prop("checked",!0)):b!=c&&(a.val("off"),a.prop("checked",!1))}),document.getElementById("ruleHeader");var a,e=!1;function f(){$("#sortable").sortable({handle:".awdr-sortable-handle",delay:150,stop:function(b,c){var a=new Array;$("#sortable>tr").each(function(){a.push($(this).attr("id"))}),r(a)}})}function r(a){$.ajax({data:{position:a,method:"update_priority_order",action:"wdr_ajax",awdr_nonce:$("input[name=awdr_rule_list_nonce]").val()},type:"post",url:ajaxurl,error:function(a,b){q(wdr_data.localization_data.error,"error",i)},success:function(a){!1===a?q(wdr_data.localization_data.error,"error",i):q(wdr_data.localization_data.save_priority,"success",i)}})}(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))&&(e=!0),$(window).width()>1024?!0==e?f():$("#sortable").sortable({delay:150,stop:function(b,c){var a=new Array;$("#sortable>tr").each(function(){a.push($(this).attr("id"))}),r(a)}}):f(),$("#sortable").disableSelection(),$(document).on("click",".help-popup",function(){var a="#"+$(this).attr("data-id");$(a).dialog({modal:!0,closeText:""})}),$(document).on("click",".remove-clicked-discount-block",function(){var a=$(this).data("showblock"),b=$(this).data("removeval"),c=$(this).data("removeopt");$("."+a).hide(),$("."+b).removeAttr("value"),$("."+c).prop("selectedIndex",0),$("[data-dtype="+a+"]").show(),"wdr-bulk-discount"==a&&($(".bulk_product_category_selector option:selected").remove(),$(".wdr-bulk-cat-selector").hide())}),$(".wdr-btn-add-message").click(function(){wdr_buildrule.show_hide_rule_block({showBlockId:".wdr-advanced-layout-block",hideBlockId:".wdr-discount-template, .wdr-filter-block",thisObject:this})});var b=$(".bulk-min").length;if(b>=2){var c=$(".bulk_discount_min").val(),h=$(".bulk_discount_max").val(),d=$(".bulk_discount_value").val();(c||h||d)&&$(".adv-msg-min-qty, .adv-msg-max-qty").show()}var b=$(".set-min").length;if(b>=2){var c=$(".set_discount_min").val(),d=$(".set_discount_value").val();(c||d)&&($(".adv-msg-min-qty").show(),$(".adv-msg-max-qty").hide())}function s(){$(".wdr-condition-group").each(function(c,b){let a=$(b).find(".wdr-product-condition-type").val();void 0!==a&&"cart_item_product_onsale"===a&&$(this).remove()})}$(".popup_table_discount_column_value").click(function(){1==$(this).val()?($(".wdr_table_discounted_value").show(),$(".wdr_table_discounted_price").hide()):($(".wdr_table_discounted_value").hide(),$(".wdr_table_discounted_price").show())}),$(".modal-trigger").click(function(a){a.preventDefault(),dataModal=$(this).attr("data-modal"),$("#"+dataModal).css({display:"block"})}),$(".close-modal, .modal-sandbox").click(function(){$(".modal").css({display:"none"})}),$("#badge_colorpicker").on("change",function(){$("#badge_hexcolor").val(this.value)}),$("#badge_hexcolor").on("change",function(){$("#badge_colorpicker").val(this.value)}),$("#text_colorpicker").on("change",function(){$("#text_hexcolor").val(this.value)}),$("#text_hexcolor").on("change",function(){$("#text_colorpicker").val(this.value)}),$("#awdr_shortcode_copy_btn").on("click",function(){b="#awdr_shortcode_text",c=$("<input>"),$("body").append(c),c.val($(b).text()).select(),document.execCommand("copy"),c.remove();var b,c,a=$(this);a.html(wdr_data.localization_data.copied),setTimeout(function(){a.html(wdr_data.localization_data.copy_shortcode)},2e3)}),$(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),$(".awdr_popup_col_name_text_box").keyup(function(){var a=$(this).val(),b=$(this).data("keyup");$("."+b).html(a)}),$(".awdr_popup_col_name_text_box").blur(function(){var a=$(this).val(),b=$(this).data("keyup");$("."+b).html(a)}),$(".apply_product_and_cart_discount_to").change(function(){let a=$(this).data("subsequent");"all"==$(this).val()?$("."+a).show():$("."+a).hide()}),$(document).on("change",".awdr-bogo-discount-type",function(){let c=$(this).val(),a=$(this).attr("data-parent"),b=$(this).attr("data-siblings");switch(c){case"flat":$(this).parent("."+a).siblings("."+b).show(),$(this).parent("."+a).siblings("."+b).find(".wdr_desc_text").text(wdr_data.localization_data.buyx_getx_value);break;case"percentage":$(this).parent("."+a).siblings("."+b).show(),$(this).parent("."+a).siblings("."+b).find(".wdr_desc_text").text(wdr_data.localization_data.buyx_getx_percentage);break;default:$(this).parent("."+a).siblings("."+b).hide()}}),$(document).on("change",".awdr-bogo-recurcive",function(){let c=$(this).attr("data-recursive-row"),a=$(this).attr("data-recursive-parent"),d=$(this).attr("data-hide-add-range"),b=$(this).attr("data-bogo-max-range"),e=$(this).attr("data-bogo-min-range"),f=$(this).attr("data-bogo-border"),h=$("."+c).length,g=$(this).attr("data-ranges-row-parent");if(!1==$(this).prop("checked")){$(this).parents("."+g).siblings("."+d).show(),""!=b&&($(this).parents("."+a).siblings("."+b).show(),$(this).parents("."+a).siblings().find("."+b).show()),$(this).parents("."+a).siblings("."+e).find(".wdr_desc_text").text(wdr_data.localization_data.recursive_min_qty),$("."+f).css("border-bottom","1px solid #ddd");return}h>3&&(confirm(wdr_data.localization_data.recursive_warning)?$(this).parents("."+c).siblings().remove():$(this).prop("checked",!1)),!0==$(this).prop("checked")&&($(this).parents("."+g).siblings("."+d).hide(),""!=b&&($(this).parents("."+a).siblings("."+b).hide(),$(this).parents("."+a).siblings().find("."+b).hide()),$(this).parents("."+a).siblings("."+e).find(".wdr_desc_text").text(wdr_data.localization_data.recursive_qty),$("."+f).css("border-bottom","unset"))}),$(document).on("change",".awdr_mode_of_operator",function(){let a=$(this).val();if("wdr_buy_x_get_y_discount"==$(".awdr-product-discount-type").val()){"variation"==a?($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_variants_discount_description_tool_tip),$(".awdr-example").html(wdr_data.localization_data.mode_variation_cumulative_example)):"product"==a?($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_individual_product_discount_description_tool_tip),$(".awdr-example").html("")):($(".awdr-bxgy-dynamic-tip").attr("title",wdr_data.localization_data.bulk_filter_together_discount_description_tool_tip),$(".awdr-example").html(""));return}"variation"==a?($(".awdr-discount-content").html(wdr_data.localization_data.bulk_variants_discount_description),$(".awdr-example").html(wdr_data.localization_data.mode_variation_cumulative_example)):"product"==a?($(".awdr-discount-content").html(wdr_data.localization_data.bulk_individual_product_discount_description),$(".awdr-example").html("")):($(".awdr-discount-content").html(wdr_data.localization_data.bulk_filter_together_discount_description),$(".awdr-example").html(""))}),$(document).on("change",".awdr-product-discount-type",function(){$(".awdr-example").html("");var c=$(this).data("placement");let a=$(this).val(),b="awdr_doc_";switch(a){case"wdr_simple_discount":$("."+b+a).show(),$(".awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_cart_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_free_shipping":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_bulk_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_set_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_buy_x_get_x_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide();break;case"wdr_buy_x_get_y_discount":$("."+b+a).show(),$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount").hide();break;default:$(".awdr_doc_wdr_simple_discount,.awdr_doc_wdr_cart_discount,.awdr_doc_wdr_free_shipping,.awdr_doc_wdr_bulk_discount,.awdr_doc_wdr_set_discount,.awdr_doc_wdr_buy_x_get_x_discount,.awdr_doc_wdr_buy_x_get_y_discount").hide()}"not_selected"!=$(this).val()&&"wdr_free_shipping"!=$(this).val()?(wdr_buildrule.wdr_clone_field({addFilterMethod:"."+$(this).val(),ruleAppendTo:"."+c,addDiscountType:"enable"}),$(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".calculate_cart_from option[value='from_filter']").show(),$(".adv-msg-discount, .adv-msg-discount-price").show(),$(".awdr-hidden-new-rule").fadeIn(500),$(".awdr-filter-section").fadeIn(500),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"),n($("."+c).find('[data-field="autocomplete"]')),$(".awdr-discount-container").show(),$("."+c).find(".bulk_range_setter_group").addClass("bulk_range_setter").attr("id","bulk_adjustment_sortable"),$("."+c).find(".set_range_setter_group").addClass("set_range_setter").attr("id","bulk_adjustment_sortable"),$(window).width()>1024?!0==e?$("#bulk_adjustment_sortable").sortable({handle:".awdr-sortable-handle"}):$("#bulk_adjustment_sortable").sortable():$("#bulk_adjustment_sortable").sortable({handle:".awdr-sortable-handle"}),$("#bulk_adjustment_sortable").disableSelection(),$(".awdr-filter-heading").html(wdr_data.localization_data.common_filter_heading),$(".awdr-filter-content").html(wdr_data.localization_data.common_filter_description),$(".awdr-discount-heading").html(wdr_data.localization_data.common_discount_heading),$(".awdr-discount-content").html(wdr_data.localization_data.common_discount_description),$(".awdr-rules-content").html(wdr_data.localization_data.common_rules_description),"wdr_buy_x_get_y_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_bxgy_discount_heading),n($("."+c).find('[data-list="product_category"]')),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide()),"wdr_buy_x_get_x_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide()),"wdr_bulk_discount"==$(this).val()?($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_bulk_discount_heading),$(".awdr_mode_of_operator").trigger("change"),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").show()):"wdr_set_discount"==$(this).val()&&($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$(".awdr_mode_of_operator").trigger("change"),$(".awdr-discount-heading").html(wdr_data.localization_data.two_column_set_discount_heading),$(".adv-msg-min-qty, .adv-msg-discount, .adv-msg-discount-price").show(),$(".adv-msg-max-qty").hide())):"wdr_free_shipping"==$(this).val()?($(".awdr-free-shipping-special-condition").removeClass("wdr-hide"),$(".awdr-hidden-new-rule").fadeIn(500),$(".awdr-filter-section").fadeOut(),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"),$("."+c).html(""),$(".awdr-discount-container").hide(),$(".adv-msg-min-qty, .adv-msg-max-qty, .adv-msg-discount, .adv-msg-discount-price").hide(),$(".calculate_cart_from option[value='from_filter']").hide()):($(".awdr-free-shipping-special-condition").hasClass("wdr-hide")||$(".awdr-free-shipping-special-condition").addClass("wdr-hide"),s(),$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!0).addClass("wdr_save_btn_disabled"),$(".awdr-hidden-new-rule").fadeOut(500)),$(this).trigger("advanced_woo_discount_rules_on_change_adjustment_type",[$(this).val()])}),$(".awdr-product-discount-type").trigger("change"),"view"==wdr_data.rule_id?$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!1).removeClass("wdr_save_btn_disabled"):$("button.wdr_save_stay, button.wdr_save_close").attr("disabled",!0).addClass("wdr_save_btn_disabled"),$(document).on("change",".apply_fee_coupon_checkbox",function(){!0==$(this).prop("checked")?$(this).parents(".awdr_rtl_compatible").siblings(".apply_fee_coupon_label").show():$(this).parents(".awdr_rtl_compatible").siblings(".apply_fee_coupon_label").hide()}),$(document).on("change",".bulk_table_customizer_show_hide_column",function(){var a=$(this).data("colname");!0==$(this).prop("checked")?$("."+a).show():$("."+a).hide()});var g=document.getElementsByClassName("awdr-accordion");for(a=0;a<g.length;a++)g[a].addEventListener("click",function(b){b.preventDefault(),this.classList.toggle("awdr-accordion-active");var a=this.nextElementSibling;"block"===a.style.display?$(a).slideUp(1e3):$(a).slideDown(1e3)});$(document).on("change",".on_sale_badge_condition",function(){"disabled"===$(this).val()?($(".sale_badge_toggle").hide(),$(".sale_badge_customizer,.sale_badge_percentage_customizer").hide()):($(".sale_badge_toggle").show(),!0==$("#customize_on_sale_badge").prop("checked")?($(".sale_badge_customizer").show(),$(".display_percentage_on_sale_badge_con").show()):($(".sale_badge_customizer").hide(),$("#display_percentage_on_sale_badge").prop("checked",!1).trigger("change"),$(".display_percentage_on_sale_badge_con").hide()),!0==$("#display_percentage_on_sale_badge").prop("checked")?$(".sale_badge_percentage_customizer").show():$(".sale_badge_percentage_customizer").hide())}),$(document).on("change","#customize_on_sale_badge",function(){!0==$(this).prop("checked")?($(".sale_badge_customizer").show(),$(".display_percentage_on_sale_badge_con").show()):($(".sale_badge_customizer").hide(),$("#display_percentage_on_sale_badge").prop("checked",!1).trigger("change"),$(".display_percentage_on_sale_badge_con").hide())}),$(document).on("change","#display_percentage_on_sale_badge",function(){!0==$(this).prop("checked")?$(".sale_badge_percentage_customizer").show():$(".sale_badge_percentage_customizer").hide()}),$(document).on("change","#badge_colorpicker",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("background-color",a)}),$(document).on("change","#badge_hexcolor",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("background-color",a)}),$(document).on("change","#text_colorpicker",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("color",a)}),$(document).on("change","#text_hexcolor",function(){let a=$(this).val();$(".awdr_admin_discount_bar").css("color",a)}),$(document).on("change","#awdr_discount_bar_content",function(){let a=$(this).val();$(".awdr_admin_discount_bar").html(a)}),$(document).on("click",".awdr-hidden-search",function(){let a=$(".awdr-hidden-name").val();$(".wdr-rule-search-key").val(a),$("#wdr-search-top").submit()}),$(document).on("change","#select_usage_limits",function(){let a=$("#select_usage_limits").val();if(""==a)$(".awdr-rule-limit-disabled-outer .rule_limit_msg_outer").hide(),$(".awdr-rule-limit-disabled").hide();else{var b=$(".awdr-used-limit-total").html();a<=parseInt(b)?($(".awdr-rule-limit-disabled").hide(),$(".awdr-rule-limit-disabled-outer").show(),$(".awdr-rule-limit-disabled-outer .rule_limit_msg_outer").html(wdr_data.localization_data.invalid_rule_limit)):($(".awdr-rule-limit-disabled").hide(),$(".awdr-rule-limit-disabled-outer").hide())}}),$("#awdr-import-csv").on("submit",function(){return!!new RegExp("([a-zA-Z0-9s_\\.-:])+(.csv)$").test($("#awdr-file-uploader").val().toLowerCase())||($("#awdr-upload-response").html(wdr_data.localization_data.invalid_file_type),!1)}),$(document).on("change",".get_awdr_state_based_country",function(){let a=$(this).val();if(!a||""==a||0==a.length)return!1;let b=$(this).parents(".wdr-conditions-container").attr("data-index"),e=$(this).parents(".wdr_shipping_state_group"),f=$(this).parent().siblings(".wdr-shipping-state-value"),g=$(".woo_discount_loader"),c=$(this).parent().siblings(".wdr-shipping-state-value").find(".get_awdr_shipping_state").val();var d={action:"wdr_ajax",method:"get_state_details",selected_country:a,selected_state:c,selected_index:b,awdr_nonce:$("input[name=wdr_ajax_select2]").val()||""};$.ajax({url:ajaxurl,data:d,type:"POST",beforeSend:function(){g.show()},complete:function(){g.hide()},success:function(a){f.remove(),e.append("<div class='wdr-shipping-state-value wdr-select-filed-hight wdr-search-box' style='width: min-content;'>"+a.data+"<span class='wdr_select2_desc_text'>"+wdr_data.localization_data.select_state+"</span> </div>"),$(".append-preloaded-values").selectWoo()},error:function(a){console.log("error")}})}),$(".get_awdr_state_based_country").trigger("change"),$(document).on("change",".wdr_copon_type",function(){var a=$(this).val();"custom_coupon"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one, .wdr-cart-coupon-url-all").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","block")):"at_least_one"===a?($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom, .wdr-cart-coupon-url-all").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","block")):"all"===a&&($(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom, .wdr-cart-coupon-url-one").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","block"))}),$(document).on("click",".wdr-copy-coupon-url",function(a){a.preventDefault(),$(this).parents(".wdr-coupon-url-group").find("input[type=url]").select(),document.execCommand("copy")?($(this).html(wdr_data.localization_data.coupon_url_copied),q(wdr_data.localization_data.coupon_url_success,"success",i)):q(wdr_data.localization_data.error,"error",i)}),$(document).on("change",".wdr-cart-coupon-url-enable",function(a){a.preventDefault(),$(this).closest(".wdr-cart-coupon-url").find(".wdr-cart-coupon-url-lists").slideToggle()}),$(document).on("change keyup",".wdr-cart-coupon-value input",function(){var b=wdr_data.home_url,a=$(this).val();""!==a?($group='<span class="wdr-coupon-url-group"><label>',$group+=' <input type="url" value="'+b+"?wdr_coupon="+encodeURIComponent(a)+'"></label>',$group+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span>",$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").html($group),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","block")):$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-custom").css("display","none")}),$(document).on("change",".wdr-cart-coupon-search select, select.wdr_copon_type",function(){var a=wdr_data.home_url,b=$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-search select").val(),c=$(this).parents(".wdr_cart_coupon_group").find("select.wdr_copon_type").val();if(0!==b.length){if("at_least_one"===c)$groups="",b.forEach(function(b){$groups+='<span class="wdr-coupon-url-group"><label>',$groups+=' <input type="url" value="'+a+"?wdr_coupon="+encodeURIComponent(b)+'"></label>',$groups+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span><br>"}),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").html($groups),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","block");else if("all"===c){var d="";a+="?wdr_coupon=",b.forEach(function(b){d+=b+", ",a+=encodeURIComponent(b)+","}),d=d.replace(/(^, )|(, $)/g,""),a=a.replace(/(^,)|(,$)/g,""),$group='<span class="wdr-coupon-url-group"><label>',$group+=' <input type="url" value="'+a+'"></label>',$group+='<button class="wdr-copy-coupon-url">'+wdr_data.localization_data.coupon_url_copy+"</button></span>",$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").html($group),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","block")}}else $(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-one").css("display","none"),$(this).parents(".wdr_cart_coupon_group").find(".wdr-cart-coupon-url-all").css("display","none")})})
woo-discount-rules.php CHANGED
@@ -5,13 +5,13 @@
5
  * Description: Simple to complex discount rules for your WooCommerce store. Core package.
6
  * Author: Flycart
7
  * Author URI: https://www.flycart.org
8
- * Version: 2.4.2
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 3.0
14
- * WC tested up to: 6.6
15
  */
16
  if (!defined('ABSPATH')) {
17
  exit;
@@ -21,7 +21,7 @@ if (!defined('ABSPATH')) {
21
  * Current version of our app
22
  */
23
  if (!defined('WDR_VERSION')) {
24
- define('WDR_VERSION', '2.4.2');
25
  }
26
 
27
  global $awdr_load_version;
5
  * Description: Simple to complex discount rules for your WooCommerce store. Core package.
6
  * Author: Flycart
7
  * Author URI: https://www.flycart.org
8
+ * Version: 2.4.4
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 3.0
14
+ * WC tested up to: 6.7
15
  */
16
  if (!defined('ABSPATH')) {
17
  exit;
21
  * Current version of our app
22
  */
23
  if (!defined('WDR_VERSION')) {
24
+ define('WDR_VERSION', '2.4.4');
25
  }
26
 
27
  global $awdr_load_version;