Discount Rules for WooCommerce - Version 1.5.1

Version Description

  • 27/02/18 =
  • Fix - Dependant product not applied for product variants(if choose only child)
Download this release

Release Info

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

Code changes from version 1.5.0 to 1.5.1

includes/discount-base.php CHANGED
@@ -64,6 +64,26 @@ if (!class_exists('FlycartWooDiscountBase')) {
64
  $cart_discount->analyse($woocommerce);
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  /**
68
  * For adding script in checkout page
69
  * */
64
  $cart_discount->analyse($woocommerce);
65
  }
66
 
67
+ /**
68
+ * Managing discount of Cart.
69
+ */
70
+ public function handleCartDiscount()
71
+ {
72
+ global $woocommerce;
73
+ $cart_discount = $this->getInstance('FlycartWooDiscountRulesCartRules');
74
+ $cart_discount->analyse($woocommerce);
75
+ }
76
+
77
+ /**
78
+ * Managing discount of Price.
79
+ */
80
+ public function handlePriceDiscount()
81
+ {
82
+ global $woocommerce;
83
+ $price_discount = $this->getInstance('FlycartWooDiscountRulesPricingRules');
84
+ $price_discount->analyse($woocommerce);
85
+ }
86
+
87
  /**
88
  * For adding script in checkout page
89
  * */
includes/pricing-rules.php CHANGED
@@ -890,6 +890,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
890
  $discount_value = isset($product_based_discounts['discount_value']) ? $product_based_discounts['discount_value'] : '';
891
  $cart = FlycartWoocommerceCart::get_cart();
892
  $_quantity = array();
 
 
 
 
893
  if ( sizeof( $cart ) > 0 ) {
894
  foreach ($product_to_buy as $key => $productId) {
895
  foreach ($cart as $cart_item_key => $values) {
@@ -901,7 +905,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
901
  }
902
  }
903
  $quantity = FlycartWooDiscountRulesPriceProductBased::adjustQuantity($buy_type, $_quantity);
904
- if((in_array($item['product_id'], $product_to_buy) || in_array($item['product_id'], $product_to_apply)) && !empty($_quantity)){
905
  $proceed = 1;
906
  if($buy_type == 'each'){
907
  $allProductsInCart = array_keys($_quantity);
890
  $discount_value = isset($product_based_discounts['discount_value']) ? $product_based_discounts['discount_value'] : '';
891
  $cart = FlycartWoocommerceCart::get_cart();
892
  $_quantity = array();
893
+ if(isset($item['variation_id']) && $item['variation_id'])
894
+ $product_id = $item['variation_id'];
895
+ else
896
+ $product_id = $item['product_id'];
897
  if ( sizeof( $cart ) > 0 ) {
898
  foreach ($product_to_buy as $key => $productId) {
899
  foreach ($cart as $cart_item_key => $values) {
905
  }
906
  }
907
  $quantity = FlycartWooDiscountRulesPriceProductBased::adjustQuantity($buy_type, $_quantity);
908
+ if((in_array($product_id, $product_to_buy) || in_array($product_id, $product_to_apply)) && !empty($_quantity)){
909
  $proceed = 1;
910
  if($buy_type == 'each'){
911
  $allProductsInCart = array_keys($_quantity);
loader.php CHANGED
@@ -114,10 +114,18 @@ if(!class_exists('FlycartWooDiscountRules')){
114
  * Apply discount rules
115
  * */
116
  public function applyDiscountRules(){
117
- $this->discountBase->handleDiscount();
118
  remove_action('woocommerce_before_calculate_totals', array($this, 'applyDiscountRules'), 1000);
119
  }
120
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Load Admin scripts
123
  * */
@@ -141,6 +149,7 @@ if(!class_exists('FlycartWooDiscountRules')){
141
  } else {
142
  if(version_compare($woocommerce_version, '3.0', '>=')){
143
  add_action('woocommerce_before_calculate_totals', array($this, 'applyDiscountRules'), 1000);
 
144
  } else {
145
  add_action('woocommerce_cart_loaded_from_session', array($this->discountBase, 'handleDiscount'), 100);
146
  }
114
  * Apply discount rules
115
  * */
116
  public function applyDiscountRules(){
117
+ $this->discountBase->handlePriceDiscount();
118
  remove_action('woocommerce_before_calculate_totals', array($this, 'applyDiscountRules'), 1000);
119
  }
120
 
121
+ /**
122
+ * Apply discount rules
123
+ * */
124
+ public function applyCartDiscountRules(){
125
+ $this->discountBase->handleCartDiscount();
126
+ remove_action('woocommerce_cart_loaded_from_session', array($this, 'applyCartDiscountRules'), 100);
127
+ }
128
+
129
  /**
130
  * Load Admin scripts
131
  * */
149
  } else {
150
  if(version_compare($woocommerce_version, '3.0', '>=')){
151
  add_action('woocommerce_before_calculate_totals', array($this, 'applyDiscountRules'), 1000);
152
+ add_action('woocommerce_cart_loaded_from_session', array($this, 'applyCartDiscountRules'), 100);
153
  } else {
154
  add_action('woocommerce_cart_loaded_from_session', array($this->discountBase, 'handleDiscount'), 100);
155
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.9
7
- Stable tag: 1.5.0
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -241,6 +241,9 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
241
 
242
  == Changelog ==
243
 
 
 
 
244
  = 1.5.0 - 21/02/18 =
245
  * Feature - Price rule buy from category X and get discount in category Y (Pro)
246
  * Feature - Cart rule based on shipping state (Pro)
4
  Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.9
7
+ Stable tag: 1.5.1
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
241
 
242
  == Changelog ==
243
 
244
+ = 1.5.1 - 27/02/18 =
245
+ * Fix - Dependant product not applied for product variants(if choose only child)
246
+
247
  = 1.5.0 - 21/02/18 =
248
  * Feature - Price rule buy from category X and get discount in category Y (Pro)
249
  * Feature - Cart rule based on shipping state (Pro)
woo-discount-rules.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
- * Version: 1.5.0
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 1.5.1
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1