Version Description
- 10/06/20 =
- Fix - Showing duplicate strikeout.
- Fix - Showing discount table even the rule disabled.
- Fix - Showing discount table even the rule disabled.
- Fix - Migration: all rules are not migrated.
- Fix - Disable discount rule coupon will work option is not working.
- Fix - Displaying price as 1 when the price has zero value.
- Improvement - Apply this rule if matched and ignore all other rules option work flow changed.
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.9.10 |
Comparing to | |
See all releases |
Code changes from version 1.9.9 to 1.9.10
- readme.txt +10 -1
- v2/App/Controllers/DiscountCalculator.php +109 -1
- v2/App/Controllers/ManageDiscount.php +40 -20
- v2/App/Helpers/Migration.php +2 -1
- v2/App/Helpers/Rule.php +14 -9
- v2/App/Helpers/RuleForm.php +1 -1
- v2/App/Models/DBTable.php +1 -1
- woo-discount-rules.php +2 -2
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
|
|
4 |
Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.4
|
7 |
-
Stable tag: 1.9.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -336,6 +336,15 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
336 |
|
337 |
== Changelog ==
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
= 1.9.9 - 02/06/20 =
|
340 |
* Improvement - Product addon compatible.
|
341 |
* Improvement - V2 UI improvements.
|
4 |
Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.4
|
7 |
+
Stable tag: 1.9.10
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
336 |
|
337 |
== Changelog ==
|
338 |
|
339 |
+
= 1.9.10 - 10/06/20 =
|
340 |
+
* Fix - Showing duplicate strikeout.
|
341 |
+
* Fix - Showing discount table even the rule disabled.
|
342 |
+
* Fix - Showing discount table even the rule disabled.
|
343 |
+
* Fix - Migration: all rules are not migrated.
|
344 |
+
* Fix - Disable discount rule coupon will work option is not working.
|
345 |
+
* Fix - Displaying price as 1 when the price has zero value.
|
346 |
+
* Improvement - Apply this rule if matched and ignore all other rules option work flow changed.
|
347 |
+
|
348 |
= 1.9.9 - 02/06/20 =
|
349 |
* Improvement - Product addon compatible.
|
350 |
* Improvement - V2 UI improvements.
|
v2/App/Controllers/DiscountCalculator.php
CHANGED
@@ -9,7 +9,7 @@ if (!defined('ABSPATH')) exit; // Exit if accessed directly
|
|
9 |
|
10 |
class DiscountCalculator extends Base
|
11 |
{
|
12 |
-
public static $rules, $applied_rules = array(), $total_discounts = array(), $cart_adjustments = array(), $price_discount_apply_as_cart_discount = array(), $tax_display_type = NULL;
|
13 |
public $is_cart = false;
|
14 |
|
15 |
/**
|
@@ -72,6 +72,9 @@ class DiscountCalculator extends Base
|
|
72 |
$language_helper_object = self::$language_helper;
|
73 |
$discount_calculator = $this;
|
74 |
foreach (self::$rules as $rule) {
|
|
|
|
|
|
|
75 |
$rule_id = $rule->getId();
|
76 |
$hide_bulk_table = apply_filters('advanced_woo_discount_rules_hide_specific_rules_in_bulk_table', false, $rule_id, $rule);
|
77 |
if ($hide_bulk_table) {
|
@@ -173,6 +176,9 @@ class DiscountCalculator extends Base
|
|
173 |
$language_helper_object = self::$language_helper;
|
174 |
$discount_calculator = $this;
|
175 |
foreach (self::$rules as $rule) {
|
|
|
|
|
|
|
176 |
$discounted_title_text = $rule->getTitle();
|
177 |
$chosen_languages = $rule->getLanguages();
|
178 |
if (!empty($chosen_languages)) {
|
@@ -370,6 +376,100 @@ class DiscountCalculator extends Base
|
|
370 |
//}
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
/**
|
374 |
* check the product has the price discount
|
375 |
* @param $product
|
@@ -382,6 +482,7 @@ class DiscountCalculator extends Base
|
|
382 |
*/
|
383 |
function mayApplyPriceDiscount($product, $quantity, $custom_price = 0, $ajax_price = false, $cart_item = array(), $is_cart=true, $manual_request = false)
|
384 |
{
|
|
|
385 |
if (!empty(self::$rules) && !empty($product)) {
|
386 |
$calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
|
387 |
if (empty($custom_price)) {
|
@@ -664,6 +765,9 @@ class DiscountCalculator extends Base
|
|
664 |
if (!empty(self::$rules)) {
|
665 |
$language_helper_object = self::$language_helper;
|
666 |
foreach (self::$rules as $rule) {
|
|
|
|
|
|
|
667 |
$chosen_languages = $rule->getLanguages();
|
668 |
if (!empty($chosen_languages)) {
|
669 |
$current_language = $language_helper_object::getCurrentLanguage();
|
@@ -808,6 +912,10 @@ class DiscountCalculator extends Base
|
|
808 |
return $rules;
|
809 |
}
|
810 |
|
|
|
|
|
|
|
|
|
811 |
static public function getUsedCoupons(){
|
812 |
$all_used_coupons = array();
|
813 |
foreach (self::$rules as $rule) {
|
9 |
|
10 |
class DiscountCalculator extends Base
|
11 |
{
|
12 |
+
public static $filtered_exclusive_rule = false, $rules, $applied_rules = array(), $total_discounts = array(), $cart_adjustments = array(), $price_discount_apply_as_cart_discount = array(), $tax_display_type = NULL;
|
13 |
public $is_cart = false;
|
14 |
|
15 |
/**
|
72 |
$language_helper_object = self::$language_helper;
|
73 |
$discount_calculator = $this;
|
74 |
foreach (self::$rules as $rule) {
|
75 |
+
if (!$rule->isEnabled()) {
|
76 |
+
continue;
|
77 |
+
}
|
78 |
$rule_id = $rule->getId();
|
79 |
$hide_bulk_table = apply_filters('advanced_woo_discount_rules_hide_specific_rules_in_bulk_table', false, $rule_id, $rule);
|
80 |
if ($hide_bulk_table) {
|
176 |
$language_helper_object = self::$language_helper;
|
177 |
$discount_calculator = $this;
|
178 |
foreach (self::$rules as $rule) {
|
179 |
+
if (!$rule->isEnabled()) {
|
180 |
+
continue;
|
181 |
+
}
|
182 |
$discounted_title_text = $rule->getTitle();
|
183 |
$chosen_languages = $rule->getLanguages();
|
184 |
if (!empty($chosen_languages)) {
|
376 |
//}
|
377 |
}
|
378 |
|
379 |
+
/**
|
380 |
+
* Check has exclusive rule
|
381 |
+
* */
|
382 |
+
function hasExclusiveFromRules(){
|
383 |
+
$rules = array();
|
384 |
+
if(!empty(self::$rules)){
|
385 |
+
foreach (self::$rules as $key => $values){
|
386 |
+
if($values->rule->enabled == 1 && $values->rule->exclusive == 1){
|
387 |
+
$rules[$key] = $values;
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
return $rules;
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Filter exclusive rule
|
397 |
+
* */
|
398 |
+
function filterExclusiveRule($quantity, $ajax_price, $is_cart, $manual_request){
|
399 |
+
if(self::$filtered_exclusive_rule === true){
|
400 |
+
// if we doesn't do this. BUY X GET Y auto add will calculate wrong
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
self::$filtered_exclusive_rule = true;
|
404 |
+
$exclusive_rules = $this->hasExclusiveFromRules();
|
405 |
+
if(!empty($exclusive_rules)){
|
406 |
+
$cart = self::$woocommerce_helper->getCart();
|
407 |
+
$rule_passed = $has_exclusive_rule = false;
|
408 |
+
if(!empty($cart)){
|
409 |
+
$price_display_condition = self::$config->getConfig('show_strikeout_when', 'show_when_matched');
|
410 |
+
foreach ($cart as $key => $cart_item){
|
411 |
+
foreach ($exclusive_rules as $rule_id => $rule){
|
412 |
+
$product = $cart_item['data'];
|
413 |
+
$quantity = $cart_item['quantity'];
|
414 |
+
$calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
|
415 |
+
if (empty($custom_price)) {
|
416 |
+
if ($calculate_discount_from == 'regular_price') {
|
417 |
+
$product_price = self::$woocommerce_helper->getProductRegularPrice($product);
|
418 |
+
} else {
|
419 |
+
$product_price = self::$woocommerce_helper->getProductPrice($product);
|
420 |
+
}
|
421 |
+
} else {
|
422 |
+
$product_price = $custom_price;
|
423 |
+
}
|
424 |
+
|
425 |
+
if ($rule->isFilterPassed($product)) {
|
426 |
+
if ($rule->hasConditions()) {
|
427 |
+
if ($rule->isCartConditionsPassed($cart)) {
|
428 |
+
$rule_passed = true;
|
429 |
+
}
|
430 |
+
} else {
|
431 |
+
$rule_passed = true;
|
432 |
+
}
|
433 |
+
if($rule_passed){
|
434 |
+
if(!in_array($rule->rule->discount_type, array('wdr_buy_x_get_x_discount'))){
|
435 |
+
if ($discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart, $manual_request)) {
|
436 |
+
$has_exclusive_rule = true;
|
437 |
+
} else {
|
438 |
+
$rule_passed = apply_filters('advanced_woo_discount_rules_is_rule_passed_with_out_discount_for_exclusive_rule', false, $product, $rule, $cart_item);
|
439 |
+
if($rule_passed){
|
440 |
+
$has_exclusive_rule = true;
|
441 |
+
}
|
442 |
+
}
|
443 |
+
} else {
|
444 |
+
$rule_passed = apply_filters('advanced_woo_discount_rules_is_rule_passed_with_out_discount_for_exclusive_rule', false, $product, $rule, $cart_item);
|
445 |
+
if($rule_passed){
|
446 |
+
$has_exclusive_rule = true;
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
} else {
|
451 |
+
$process_discount = apply_filters('advanced_woo_discount_rules_process_discount_for_product_which_do_not_matched_filters', false, $product, $rule, $cart_item);
|
452 |
+
if($process_discount){
|
453 |
+
$discounted_price = $rule->calculateDiscount($product_price, $quantity, $product, $ajax_price, $cart_item, $price_display_condition, $is_cart);
|
454 |
+
if($discounted_price > 0){
|
455 |
+
$has_exclusive_rule = true;
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
$has_exclusive_rule = apply_filters('advanced_woo_discount_rules_is_rule_passed_for_exclusive_rule', $has_exclusive_rule, $product, $rule, $cart_item);
|
460 |
+
if($has_exclusive_rule){
|
461 |
+
self::$rules = array($rule_id => $rule);
|
462 |
+
break;
|
463 |
+
}
|
464 |
+
}
|
465 |
+
if($has_exclusive_rule){
|
466 |
+
break;
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
/**
|
474 |
* check the product has the price discount
|
475 |
* @param $product
|
482 |
*/
|
483 |
function mayApplyPriceDiscount($product, $quantity, $custom_price = 0, $ajax_price = false, $cart_item = array(), $is_cart=true, $manual_request = false)
|
484 |
{
|
485 |
+
$this->filterExclusiveRule($quantity, $ajax_price, $is_cart, $manual_request);
|
486 |
if (!empty(self::$rules) && !empty($product)) {
|
487 |
$calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
|
488 |
if (empty($custom_price)) {
|
765 |
if (!empty(self::$rules)) {
|
766 |
$language_helper_object = self::$language_helper;
|
767 |
foreach (self::$rules as $rule) {
|
768 |
+
if (!$rule->isEnabled()) {
|
769 |
+
continue;
|
770 |
+
}
|
771 |
$chosen_languages = $rule->getLanguages();
|
772 |
if (!empty($chosen_languages)) {
|
773 |
$current_language = $language_helper_object::getCurrentLanguage();
|
912 |
return $rules;
|
913 |
}
|
914 |
|
915 |
+
/**
|
916 |
+
* get used coupons from discount rules
|
917 |
+
* @return array
|
918 |
+
*/
|
919 |
static public function getUsedCoupons(){
|
920 |
$all_used_coupons = array();
|
921 |
foreach (self::$rules as $rule) {
|
v2/App/Controllers/ManageDiscount.php
CHANGED
@@ -168,27 +168,14 @@ class ManageDiscount extends Base
|
|
168 |
*/
|
169 |
function getPriceHtml($price_html, $product, $quantity = 1, $ajax_price = false)
|
170 |
{
|
171 |
-
$initial_price_html = $price_html;
|
172 |
-
if ($ajax_price) {
|
173 |
-
$calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
|
174 |
-
if ($calculate_discount_from == 'regular_price') {
|
175 |
-
$product_price = self::$woocommerce_helper->getProductRegularPrice($product);
|
176 |
-
} else {
|
177 |
-
$product_price = self::$woocommerce_helper->getProductPrice($product);
|
178 |
-
}
|
179 |
-
$price_html = self::$woocommerce_helper->formatPrice($product_price);
|
180 |
-
$price_html = $price_html.Woocommerce::getProductPriceSuffix($product, $product_price);
|
181 |
-
if(!$price_html || empty($product_price) || !$product_price){
|
182 |
-
return false;
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
if (empty(self::$available_rules)) {
|
187 |
if($ajax_price){
|
188 |
return false;
|
189 |
}
|
190 |
return $price_html;
|
191 |
}
|
|
|
|
|
192 |
|
193 |
$modify_price = apply_filters('advanced_woo_discount_rules_modify_price_html', true, $price_html, $product, $quantity);
|
194 |
if (!$modify_price) {
|
@@ -215,6 +202,12 @@ class ManageDiscount extends Base
|
|
215 |
}
|
216 |
return $price_html;
|
217 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
//Check the product object is from WC_Product Class
|
220 |
if (is_a($product, 'WC_Product')) {
|
@@ -264,6 +257,29 @@ class ManageDiscount extends Base
|
|
264 |
return $price_html;
|
265 |
}
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
/**
|
268 |
* Modify the product's price before modified by our plugin to adjust sale price.
|
269 |
*
|
@@ -284,9 +300,11 @@ class ManageDiscount extends Base
|
|
284 |
$sale_price = Woocommerce::getProductSalePrice($product);
|
285 |
$regular_price = Woocommerce::getProductRegularPrice($product);
|
286 |
if ($sale_price <= 0) {
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
290 |
return $price_html;
|
291 |
}
|
292 |
}
|
@@ -364,10 +382,10 @@ class ManageDiscount extends Base
|
|
364 |
$max_original_price = $calculator->mayHaveTax($product, $max_original_price);
|
365 |
}
|
366 |
if(!empty($min_price)){
|
367 |
-
$
|
368 |
}
|
369 |
if(!empty($max_price)){
|
370 |
-
$
|
371 |
}
|
372 |
$price_range_suffix = self::$woocommerce_helper->getProductPriceSuffix($product);
|
373 |
if ($min_original_price == $max_original_price) {
|
@@ -711,6 +729,8 @@ class ManageDiscount extends Base
|
|
711 |
break;
|
712 |
}
|
713 |
}
|
|
|
|
|
714 |
}
|
715 |
|
716 |
return $has_third_party_coupon;
|
168 |
*/
|
169 |
function getPriceHtml($price_html, $product, $quantity = 1, $ajax_price = false)
|
170 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
if (empty(self::$available_rules)) {
|
172 |
if($ajax_price){
|
173 |
return false;
|
174 |
}
|
175 |
return $price_html;
|
176 |
}
|
177 |
+
// $initial_price_html = $price_html;
|
178 |
+
$initial_price_html = $this->getCalculateDiscountPriceFrom($product, $price_html, $ajax_price);
|
179 |
|
180 |
$modify_price = apply_filters('advanced_woo_discount_rules_modify_price_html', true, $price_html, $product, $quantity);
|
181 |
if (!$modify_price) {
|
202 |
}
|
203 |
return $price_html;
|
204 |
}
|
205 |
+
if ($ajax_price) {
|
206 |
+
$price_html = $initial_price_html;
|
207 |
+
if(!$price_html || empty($product_price) || !$product_price){
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
}
|
211 |
|
212 |
//Check the product object is from WC_Product Class
|
213 |
if (is_a($product, 'WC_Product')) {
|
257 |
return $price_html;
|
258 |
}
|
259 |
|
260 |
+
/**
|
261 |
+
* getCalculateDiscountPriceFrom
|
262 |
+
*
|
263 |
+
* @param $product
|
264 |
+
* @param $price_html
|
265 |
+
* @param $ajax_price
|
266 |
+
* @return string
|
267 |
+
*/
|
268 |
+
function getCalculateDiscountPriceFrom($product, $price_html, $ajax_price){
|
269 |
+
$calculate_discount_from = self::$config->getConfig('calculate_discount_from', 'sale_price');
|
270 |
+
if ($calculate_discount_from == 'regular_price') {
|
271 |
+
$product_price = self::$woocommerce_helper->getProductRegularPrice($product);
|
272 |
+
$price_html = self::$woocommerce_helper->formatPrice($product_price);
|
273 |
+
return $price_html.Woocommerce::getProductPriceSuffix($product, $product_price);
|
274 |
+
}
|
275 |
+
if($ajax_price){
|
276 |
+
$product_price = self::$woocommerce_helper->getProductPrice($product);
|
277 |
+
$price_html = self::$woocommerce_helper->formatPrice($product_price);
|
278 |
+
return $price_html.Woocommerce::getProductPriceSuffix($product, $product_price);
|
279 |
+
}
|
280 |
+
return $price_html;
|
281 |
+
}
|
282 |
+
|
283 |
/**
|
284 |
* Modify the product's price before modified by our plugin to adjust sale price.
|
285 |
*
|
300 |
$sale_price = Woocommerce::getProductSalePrice($product);
|
301 |
$regular_price = Woocommerce::getProductRegularPrice($product);
|
302 |
if ($sale_price <= 0) {
|
303 |
+
if($regular_price > 0){
|
304 |
+
$regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? Woocommerce::getExcludingTaxPrice($product, 1, $regular_price) : Woocommerce::getIncludingTaxPrice($product, 1, $regular_price);
|
305 |
+
$price_to_display = Woocommerce::formatPrice($regular_price);
|
306 |
+
$price_html = (($price_to_display) . Woocommerce::getProductPriceSuffix($product));
|
307 |
+
}
|
308 |
return $price_html;
|
309 |
}
|
310 |
}
|
382 |
$max_original_price = $calculator->mayHaveTax($product, $max_original_price);
|
383 |
}
|
384 |
if(!empty($min_price)){
|
385 |
+
$min_price = $calculator->mayHaveTax($product, $min_price);
|
386 |
}
|
387 |
if(!empty($max_price)){
|
388 |
+
$max_price = $calculator->mayHaveTax($product, $max_price);
|
389 |
}
|
390 |
$price_range_suffix = self::$woocommerce_helper->getProductPriceSuffix($product);
|
391 |
if ($min_original_price == $max_original_price) {
|
729 |
break;
|
730 |
}
|
731 |
}
|
732 |
+
}elseif(!empty($applied_coupons) && is_array($applied_coupons) && empty($used_coupons)){
|
733 |
+
$has_third_party_coupon = true;
|
734 |
}
|
735 |
|
736 |
return $has_third_party_coupon;
|
v2/App/Helpers/Migration.php
CHANGED
@@ -991,11 +991,12 @@ class Migration
|
|
991 |
* Alter query
|
992 |
* */
|
993 |
public function filter_where( $where = '', $object ) {
|
|
|
994 |
$query_array = $object->query;
|
995 |
if(isset($query_array['awdr_last_upgrade_id'])){
|
996 |
if($query_array['awdr_last_upgrade_id'] > 0){
|
997 |
$last_id = (int)$query_array['awdr_last_upgrade_id'];
|
998 |
-
$where .= " AND
|
999 |
}
|
1000 |
}
|
1001 |
|
991 |
* Alter query
|
992 |
* */
|
993 |
public function filter_where( $where = '', $object ) {
|
994 |
+
global $wpdb;
|
995 |
$query_array = $object->query;
|
996 |
if(isset($query_array['awdr_last_upgrade_id'])){
|
997 |
if($query_array['awdr_last_upgrade_id'] > 0){
|
998 |
$last_id = (int)$query_array['awdr_last_upgrade_id'];
|
999 |
+
$where .= " AND ".$wpdb->posts.".ID > ".$last_id." ";
|
1000 |
}
|
1001 |
}
|
1002 |
|
v2/App/Helpers/Rule.php
CHANGED
@@ -383,18 +383,19 @@ class Rule
|
|
383 |
foreach($conditions as $condition){
|
384 |
$cart = array();
|
385 |
$options = isset($condition->options) ? $condition->options : array();
|
386 |
-
|
|
|
387 |
$user_role_passed = true;
|
388 |
-
if (!empty($options) && isset($this->available_conditions[$
|
389 |
-
$this->available_conditions[$
|
390 |
-
$filter_passed_user_role = $this->available_conditions[$
|
391 |
}
|
392 |
}
|
393 |
-
if( $
|
394 |
$user_list_passed = true;
|
395 |
-
if (!empty($options) && isset($this->available_conditions[$
|
396 |
-
$this->available_conditions[$
|
397 |
-
$filter_passed_user_list = $this->available_conditions[$
|
398 |
}
|
399 |
}
|
400 |
}
|
@@ -410,7 +411,7 @@ class Rule
|
|
410 |
$filter_passed = false;
|
411 |
}
|
412 |
$rule = $this;
|
413 |
-
return apply_filters('advanced_woo_discount_rules_filter_passed', $filter_passed, $rule, $product);
|
414 |
}
|
415 |
|
416 |
/**
|
@@ -1016,6 +1017,7 @@ class Rule
|
|
1016 |
if (isset($this->available_conditions[$type]['object'])) {
|
1017 |
$this->available_conditions[$type]['object']->rule = $this;
|
1018 |
$is_condition_passed = $this->available_conditions[$type]['object']->check($cart, $options);
|
|
|
1019 |
}elseif(!isset($this->available_conditions[$type]['object'])){
|
1020 |
$object_not_available = apply_filters('advanced_woo_discount_rules_condition_object_not_available', false, $cart, $this, $condition_relationship);
|
1021 |
if($object_not_available){
|
@@ -1041,12 +1043,15 @@ class Rule
|
|
1041 |
if (isset($is_condition_passed) && !$is_condition_passed) {
|
1042 |
$conditions_result[] = false;
|
1043 |
}
|
|
|
1044 |
} else {
|
|
|
1045 |
//return false when particular condition not available
|
1046 |
return false;
|
1047 |
}
|
1048 |
}
|
1049 |
}
|
|
|
1050 |
if (in_array(false, $conditions_result)) {
|
1051 |
return false;
|
1052 |
}
|
383 |
foreach($conditions as $condition){
|
384 |
$cart = array();
|
385 |
$options = isset($condition->options) ? $condition->options : array();
|
386 |
+
$condition_type = isset($condition->type) ? $condition->type : array();
|
387 |
+
if( !empty($condition_type) && $condition_type == 'user_role' ){
|
388 |
$user_role_passed = true;
|
389 |
+
if (!empty($options) && isset($this->available_conditions[$condition_type]['object'])) {
|
390 |
+
$this->available_conditions[$condition_type]['object']->rule = $this;
|
391 |
+
$filter_passed_user_role = $this->available_conditions[$condition_type]['object']->check($cart, $options);
|
392 |
}
|
393 |
}
|
394 |
+
if( !empty($condition_type) && $condition_type == 'user_list'){
|
395 |
$user_list_passed = true;
|
396 |
+
if (!empty($options) && isset($this->available_conditions[$condition_type]['object'])) {
|
397 |
+
$this->available_conditions[$condition_type]['object']->rule = $this;
|
398 |
+
$filter_passed_user_list = $this->available_conditions[$condition_type]['object']->check($cart, $options);
|
399 |
}
|
400 |
}
|
401 |
}
|
411 |
$filter_passed = false;
|
412 |
}
|
413 |
$rule = $this;
|
414 |
+
return apply_filters('advanced_woo_discount_rules_filter_passed', $filter_passed, $rule, $product, $sale_badge);
|
415 |
}
|
416 |
|
417 |
/**
|
1017 |
if (isset($this->available_conditions[$type]['object'])) {
|
1018 |
$this->available_conditions[$type]['object']->rule = $this;
|
1019 |
$is_condition_passed = $this->available_conditions[$type]['object']->check($cart, $options);
|
1020 |
+
|
1021 |
}elseif(!isset($this->available_conditions[$type]['object'])){
|
1022 |
$object_not_available = apply_filters('advanced_woo_discount_rules_condition_object_not_available', false, $cart, $this, $condition_relationship);
|
1023 |
if($object_not_available){
|
1043 |
if (isset($is_condition_passed) && !$is_condition_passed) {
|
1044 |
$conditions_result[] = false;
|
1045 |
}
|
1046 |
+
|
1047 |
} else {
|
1048 |
+
//echo "<pre>"; var_dump($is_condition_passed); echo "</pre>";
|
1049 |
//return false when particular condition not available
|
1050 |
return false;
|
1051 |
}
|
1052 |
}
|
1053 |
}
|
1054 |
+
|
1055 |
if (in_array(false, $conditions_result)) {
|
1056 |
return false;
|
1057 |
}
|
v2/App/Helpers/RuleForm.php
CHANGED
@@ -119,7 +119,7 @@ class RuleForm
|
|
119 |
|
120 |
public function setProductAdjustment($type, $value, $apply_as_cart_rule = ''){
|
121 |
$this->form['product_adjustments'] = array(
|
122 |
-
"
|
123 |
"value" => $value,
|
124 |
"apply_as_cart_rule" => $apply_as_cart_rule,
|
125 |
);
|
119 |
|
120 |
public function setProductAdjustment($type, $value, $apply_as_cart_rule = ''){
|
121 |
$this->form['product_adjustments'] = array(
|
122 |
+
"type" => $type,
|
123 |
"value" => $value,
|
124 |
"apply_as_cart_rule" => $apply_as_cart_rule,
|
125 |
);
|
v2/App/Models/DBTable.php
CHANGED
@@ -361,7 +361,7 @@ class DBTable
|
|
361 |
*/
|
362 |
public function updateTable(){
|
363 |
//Version of currently activated plugin
|
364 |
-
$current_version = '1.9.
|
365 |
//Database version - this may need upgrading.
|
366 |
$installed_version = get_option('awdr_activity_log_version');
|
367 |
if( $installed_version != $current_version ){
|
361 |
*/
|
362 |
public function updateTable(){
|
363 |
//Version of currently activated plugin
|
364 |
+
$current_version = '1.9.10';
|
365 |
//Database version - this may need upgrading.
|
366 |
$installed_version = get_option('awdr_activity_log_version');
|
367 |
if( $installed_version != $current_version ){
|
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 Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
-
* Version: 1.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: 4.
|
15 |
*/
|
16 |
if (!defined('ABSPATH')) {
|
17 |
exit;
|
5 |
* Description: Simple to complex discount rules for your WooCommerce store. Core package.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 1.9.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: 4.2
|
15 |
*/
|
16 |
if (!defined('ABSPATH')) {
|
17 |
exit;
|