Discount Rules for WooCommerce - Version 2.3.10

Version Description

  • 15/11/21 =
  • Improvement - Event advanced_woo_discount_rules_calculate_cheapest_discount.
  • Improvement - Event advanced_woo_discount_rules_use_sale_badge_percentage_customization.
  • Improvement - Revert First order condition doesn't worked for mix guest and login
  • Fix - Not displaying variation title in BXGY auto add select on cart.
  • Fix - BXGY doesn't auto remove on checkout on rule failed.
  • Fix - Handle BXGY sale badge on user group condition.
  • Fix - Same price strikeout issue.
  • Fix - Fatal error on product object as null.
Download this release

Release Info

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

Code changes from version 2.3.9 to 2.3.10

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.8
7
- Stable tag: 2.3.9
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -336,6 +336,16 @@ Note : Enable recursive checkbox if the discounts should be applied in sequentia
336
 
337
  == Changelog ==
338
 
 
 
 
 
 
 
 
 
 
 
339
  = 2.3.9 - 21/10/21 =
340
  * Feature - Option to hide other shipping methods when free shipping is available.
341
  * Improvement - Skip invisible variant price for doing strikeout.
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.8
7
+ Stable tag: 2.3.10
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
336
 
337
  == Changelog ==
338
 
339
+ = 2.3.10 - 15/11/21 =
340
+ * Improvement - Event advanced_woo_discount_rules_calculate_cheapest_discount.
341
+ * Improvement - Event advanced_woo_discount_rules_use_sale_badge_percentage_customization.
342
+ * Improvement - Revert First order condition doesn't worked for mix guest and login
343
+ * Fix - Not displaying variation title in BXGY auto add select on cart.
344
+ * Fix - BXGY doesn't auto remove on checkout on rule failed.
345
+ * Fix - Handle BXGY sale badge on user group condition.
346
+ * Fix - Same price strikeout issue.
347
+ * Fix - Fatal error on product object as null.
348
+
349
  = 2.3.9 - 21/10/21 =
350
  * Feature - Option to hide other shipping methods when free shipping is available.
351
  * Improvement - Skip invisible variant price for doing strikeout.
v2/App/Controllers/ManageDiscount.php CHANGED
@@ -77,6 +77,9 @@ class ManageDiscount extends Base
77
  */
78
  function isProductInSale($on_sale, $product)
79
  {
 
 
 
80
  remove_filter('woocommerce_product_is_on_sale', array($this, 'isProductInSale'), 100);
81
  //Need to check if conditions also passed
82
  $show_on_sale_badge = self::$config->getConfig('show_on_sale_badge', 'disabled');
@@ -130,11 +133,15 @@ class ManageDiscount extends Base
130
  * Replace sale tag text
131
  * */
132
  public function replaceSaleTagText($html, $post, $_product){
 
 
 
133
  $use_sale_badge_customize = apply_filters('advanced_woo_discount_rules_use_sale_badge_customization', false, $post, $_product);
 
134
  $product_id = Woocommerce::getProductId($_product);
135
  if(self::isProductOnSale($product_id) || $use_sale_badge_customize){
136
  $display_percentage_on_sale_badge = self::$config->getConfig('display_percentage_on_sale_badge', '');
137
- if($display_percentage_on_sale_badge == 1){
138
  if (Woocommerce::productTypeIs($_product, array('variable'))) {
139
  $variations = Woocommerce::getProductChildren($_product);
140
  if (!empty($variations)) {
@@ -232,6 +239,9 @@ class ManageDiscount extends Base
232
  */
233
  function getPriceHtml($price_html, $product, $quantity = 1, $ajax_price = false)
234
  {
 
 
 
235
  if($this->doProcessStrikeOut($price_html, $product, $quantity, $ajax_price)){
236
  if (empty(self::$available_rules)) {
237
  if($ajax_price){
@@ -382,6 +392,9 @@ class ManageDiscount extends Base
382
  * */
383
  function getPriceHtmlSalePriceAdjustment($price_html, $product, $quantity = 1)
384
  {
 
 
 
385
  if (empty(self::$available_rules)) {
386
  return $price_html;
387
  }
@@ -420,6 +433,11 @@ class ManageDiscount extends Base
420
  $del_pattern = "/<del>(.*?)<\/del>/s";
421
  preg_match($del_pattern, $item_price, $matches);
422
  $del_content = isset($matches[1]) ? $matches[1] : '';
 
 
 
 
 
423
  $del_content = trim(strip_tags($del_content));
424
  $ins_pattern = "/<ins>(.*?)<\/ins>/s";
425
  preg_match($ins_pattern, $item_price, $matches);
@@ -445,6 +463,9 @@ class ManageDiscount extends Base
445
  */
446
  function getVariablePriceHtml($price_html, $product, $quantity = 1)
447
  {
 
 
 
448
  if($this->doProcessStrikeOut($price_html, $product, $quantity)){
449
  if (empty(self::$available_rules)) {
450
  return $price_html;
@@ -1249,6 +1270,7 @@ class ManageDiscount extends Base
1249
  if($disable_coupon_when_rule_applied == 'disable_rules'){
1250
  $has_third_party_coupon = $this->isCartContainsAnyThirdPartyCoupon();
1251
  if($has_third_party_coupon === true){
 
1252
  $calc = self::$calculator;
1253
  $calc::$applied_rules = array();
1254
  $run_rule = false;
@@ -1707,7 +1729,9 @@ class ManageDiscount extends Base
1707
  if(!empty($discount_lines)){
1708
  $calculator = self::$calculator;
1709
  $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
1710
-
 
 
1711
  $initial_price_with_tax_call = $discounted_price_with_tax_call = 0;
1712
  if(!empty($initial_price)){
1713
  $initial_price_with_tax_call = $calculator->mayHaveTax($product_obj, $initial_price);
77
  */
78
  function isProductInSale($on_sale, $product)
79
  {
80
+ if(is_null($product)){
81
+ return $on_sale;
82
+ }
83
  remove_filter('woocommerce_product_is_on_sale', array($this, 'isProductInSale'), 100);
84
  //Need to check if conditions also passed
85
  $show_on_sale_badge = self::$config->getConfig('show_on_sale_badge', 'disabled');
133
  * Replace sale tag text
134
  * */
135
  public function replaceSaleTagText($html, $post, $_product){
136
+ if(is_null($_product)){
137
+ return $html;
138
+ }
139
  $use_sale_badge_customize = apply_filters('advanced_woo_discount_rules_use_sale_badge_customization', false, $post, $_product);
140
+ $use_sale_badge_percentage_customize = apply_filters('advanced_woo_discount_rules_use_sale_badge_percentage_customization', true, $post, $_product);
141
  $product_id = Woocommerce::getProductId($_product);
142
  if(self::isProductOnSale($product_id) || $use_sale_badge_customize){
143
  $display_percentage_on_sale_badge = self::$config->getConfig('display_percentage_on_sale_badge', '');
144
+ if($display_percentage_on_sale_badge == 1 && $use_sale_badge_percentage_customize === true){
145
  if (Woocommerce::productTypeIs($_product, array('variable'))) {
146
  $variations = Woocommerce::getProductChildren($_product);
147
  if (!empty($variations)) {
239
  */
240
  function getPriceHtml($price_html, $product, $quantity = 1, $ajax_price = false)
241
  {
242
+ if(is_null($product)){
243
+ return $price_html;
244
+ }
245
  if($this->doProcessStrikeOut($price_html, $product, $quantity, $ajax_price)){
246
  if (empty(self::$available_rules)) {
247
  if($ajax_price){
392
  * */
393
  function getPriceHtmlSalePriceAdjustment($price_html, $product, $quantity = 1)
394
  {
395
+ if(is_null($product)){
396
+ return $price_html;
397
+ }
398
  if (empty(self::$available_rules)) {
399
  return $price_html;
400
  }
433
  $del_pattern = "/<del>(.*?)<\/del>/s";
434
  preg_match($del_pattern, $item_price, $matches);
435
  $del_content = isset($matches[1]) ? $matches[1] : '';
436
+ if($del_content === ''){
437
+ $del_pattern = '/<del aria-hidden="true">(.*?)<\/del>/s';
438
+ preg_match($del_pattern, $item_price, $matches);
439
+ $del_content = isset($matches[1]) ? $matches[1] : '';
440
+ }
441
  $del_content = trim(strip_tags($del_content));
442
  $ins_pattern = "/<ins>(.*?)<\/ins>/s";
443
  preg_match($ins_pattern, $item_price, $matches);
463
  */
464
  function getVariablePriceHtml($price_html, $product, $quantity = 1)
465
  {
466
+ if(is_null($product)){
467
+ return $price_html;
468
+ }
469
  if($this->doProcessStrikeOut($price_html, $product, $quantity)){
470
  if (empty(self::$available_rules)) {
471
  return $price_html;
1270
  if($disable_coupon_when_rule_applied == 'disable_rules'){
1271
  $has_third_party_coupon = $this->isCartContainsAnyThirdPartyCoupon();
1272
  if($has_third_party_coupon === true){
1273
+ do_action('advanced_woo_discount_rules_remove_applied_rules_on_coupon_applied');
1274
  $calc = self::$calculator;
1275
  $calc::$applied_rules = array();
1276
  $run_rule = false;
1729
  if(!empty($discount_lines)){
1730
  $calculator = self::$calculator;
1731
  $product_obj = isset($cart_item['data']) ? $cart_item['data'] : $cart_item;
1732
+ if(is_null($product_obj)){
1733
+ return $item_price;
1734
+ }
1735
  $initial_price_with_tax_call = $discounted_price_with_tax_call = 0;
1736
  if(!empty($initial_price)){
1737
  $initial_price_with_tax_call = $calculator->mayHaveTax($product_obj, $initial_price);
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.3.9', '>=')) {
336
  if (defined('WDR_PRO_VERSION')) {
337
- if (version_compare(WDR_PRO_VERSION, '2.3.9', '<')) {
338
  $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.3.10', '>=')) {
336
  if (defined('WDR_PRO_VERSION')) {
337
+ if (version_compare(WDR_PRO_VERSION, '2.3.10', '<')) {
338
  $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
@@ -385,6 +385,7 @@ class Rule
385
  return true;
386
  }
387
  $filters = $this->getFilter();
 
388
  if (!empty($filters)) {
389
  $filter_helper = new Filter();
390
  $filter_passed = $filter_helper->matchFilters($product, $filters, $sale_badge, $product_table);
@@ -433,18 +434,21 @@ class Rule
433
  if($filter_passed_user_role && $filter_passed_user_logged_in){
434
  }else{
435
  $filter_passed = false;
 
436
  }
437
  }
438
  if($user_list_passed && $user_logged_in_passed){
439
  if($filter_passed_user_list && $filter_passed_user_logged_in){
440
  }else{
441
  $filter_passed = false;
 
442
  }
443
  }
444
  if($purchase_first_order_passed && $user_logged_in_passed){
445
  if($filter_passed_purchase_first_order && $filter_passed_user_logged_in){
446
  }else{
447
  $filter_passed = false;
 
448
  }
449
  }
450
  //$this -> rule
@@ -455,9 +459,11 @@ class Rule
455
  if($has_other_conditions){
456
  } else {
457
  $filter_passed = false;
 
458
  }
459
  } else {
460
  $filter_passed = false;
 
461
  }
462
  }
463
  }
@@ -467,7 +473,7 @@ class Rule
467
  $filter_passed = false;
468
  }
469
  $rule = $this;
470
- return apply_filters('advanced_woo_discount_rules_filter_passed', $filter_passed, $rule, $product, $sale_badge, $product_table);
471
  }
472
 
473
  /**
385
  return true;
386
  }
387
  $filters = $this->getFilter();
388
+ $conditionFailed = false;
389
  if (!empty($filters)) {
390
  $filter_helper = new Filter();
391
  $filter_passed = $filter_helper->matchFilters($product, $filters, $sale_badge, $product_table);
434
  if($filter_passed_user_role && $filter_passed_user_logged_in){
435
  }else{
436
  $filter_passed = false;
437
+ $conditionFailed = true;
438
  }
439
  }
440
  if($user_list_passed && $user_logged_in_passed){
441
  if($filter_passed_user_list && $filter_passed_user_logged_in){
442
  }else{
443
  $filter_passed = false;
444
+ $conditionFailed = true;
445
  }
446
  }
447
  if($purchase_first_order_passed && $user_logged_in_passed){
448
  if($filter_passed_purchase_first_order && $filter_passed_user_logged_in){
449
  }else{
450
  $filter_passed = false;
451
+ $conditionFailed = true;
452
  }
453
  }
454
  //$this -> rule
459
  if($has_other_conditions){
460
  } else {
461
  $filter_passed = false;
462
+ $conditionFailed = true;
463
  }
464
  } else {
465
  $filter_passed = false;
466
+ $conditionFailed = true;
467
  }
468
  }
469
  }
473
  $filter_passed = false;
474
  }
475
  $rule = $this;
476
+ return apply_filters('advanced_woo_discount_rules_filter_passed', $filter_passed, $rule, $product, $sale_badge, $product_table, $conditionFailed);
477
  }
478
 
479
  /**
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.3.9
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: 5.8
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.3.9');
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.3.10
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: 5.9
15
  */
16
  if (!defined('ABSPATH')) {
17
  exit;
21
  * Current version of our app
22
  */
23
  if (!defined('WDR_VERSION')) {
24
+ define('WDR_VERSION', '2.3.10');
25
  }
26
 
27
  global $awdr_load_version;