Version Description
- 08/02/19 =
- Fix - Displays sale badge for all products while a bogo rule is enabled for specific products
- Fix - Not displaying sale badge for dependent product rule
- Fix - Sale price not displaying for normal sale product while option Apply discount based on Regular price is enabled
- Fix - Hide zero while apply coupon
- Improvement - Event woo_discount_rules_exclude_cart_item_from_discount to handle skip a cart item
Download this release
Release Info
Developer | flycart |
Plugin | Discount Rules for WooCommerce |
Version | 1.7.9 |
Comparing to | |
See all releases |
Code changes from version 1.7.8 to 1.7.9
- helper/general-helper.php +1 -0
- includes/pricing-rules.php +49 -21
- readme.txt +8 -1
- woo-discount-rules.php +1 -1
helper/general-helper.php
CHANGED
@@ -777,6 +777,7 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
|
|
777 |
} else if(in_array($wc_ajax, array('apply_coupon'))){
|
778 |
echo "<style>".$styles."</style>";
|
779 |
}
|
|
|
780 |
}
|
781 |
}
|
782 |
}
|
777 |
} else if(in_array($wc_ajax, array('apply_coupon'))){
|
778 |
echo "<style>".$styles."</style>";
|
779 |
}
|
780 |
+
add_action('woocommerce_before_cart_totals', 'FlycartWooDiscountRulesGeneralHelper::woo_discount_rules_custom_styles');
|
781 |
}
|
782 |
}
|
783 |
}
|
includes/pricing-rules.php
CHANGED
@@ -1144,6 +1144,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1144 |
}
|
1145 |
}
|
1146 |
|
|
|
|
|
|
|
1147 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
1148 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
1149 |
if($product_page && !$bogo){
|
@@ -1255,17 +1258,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1255 |
|
1256 |
case 'all_products':
|
1257 |
default:
|
1258 |
-
|
1259 |
if (!$this->isItemInProductList($rule['product_to_exclude'], $item) && $is_not_in_exclude_sale_items) {
|
1260 |
if(isset($rule['is_cumulative_for_products']) && $rule['is_cumulative_for_products']){
|
1261 |
-
|
1262 |
else $quantity = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
|
1263 |
-
}
|
1264 |
-
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo, $rule['product_to_exclude']);
|
1265 |
-
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
1266 |
}
|
|
|
|
|
|
|
1267 |
|
1268 |
-
|
1269 |
}
|
1270 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
1271 |
if(!empty($applied_rules[$i]['amount']['product_ids'])){
|
@@ -1290,6 +1293,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1290 |
}
|
1291 |
} else if(isset($rule['method']) && $rule['method'] == 'product_based'){
|
1292 |
$checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
|
|
|
1293 |
if(!empty($checkRuleMatches)){
|
1294 |
if(class_exists('FlycartWooDiscountRulesPriceProductDependent'))
|
1295 |
$discountInEachProducts = FlycartWooDiscountRulesPriceProductDependent::getDiscountInEachProducts($item, $rule, $checkRuleMatches, $product_page, $index);
|
@@ -1444,6 +1448,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1444 |
}
|
1445 |
}
|
1446 |
|
|
|
|
|
|
|
1447 |
// if(isset($cartItem['variation']) && !empty($cartItem['variation'])){
|
1448 |
// if(isset($cartItem['variation']['Type']) && !empty($cartItem['variation']['Type'])){
|
1449 |
// if($cartItem['variation']['Type'] == "Free Item") continue;
|
@@ -1573,6 +1580,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1573 |
if($is_exclude_sale_items){
|
1574 |
continue;
|
1575 |
}
|
|
|
|
|
1576 |
if($hasExcludeProduct){
|
1577 |
$product_id = $cartItem['product_id'];
|
1578 |
if(isset($cartItem['variation_id']) && $cartItem['variation_id']){
|
@@ -1827,6 +1836,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
1827 |
continue;
|
1828 |
}
|
1829 |
}
|
|
|
|
|
|
|
1830 |
$_product = $values['data'];
|
1831 |
$productId = FlycartWoocommerceProduct::get_id($_product);
|
1832 |
$loadOriginalPrice = apply_filters('woo_discount_rules_load_original_price_on_get_cheapest_product', false);
|
@@ -2447,8 +2459,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
2447 |
$product_to_buy = isset($product_based_conditions['product_to_buy']) ? $product_based_conditions['product_to_buy'] : array();
|
2448 |
$product_to_buy = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_buy);
|
2449 |
$product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
|
|
2450 |
$product_to_apply = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_apply);
|
2451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2452 |
$product_based_discounts = json_decode((isset($rule->product_based_discount) ? $rule->product_based_discount : '{}'), true);
|
2453 |
$product_based_discount_type = isset($product_based_discounts['discount_type']) ? $product_based_discounts['discount_type'] : 'percentage_discount';
|
2454 |
$product_based_discount_value = isset($product_based_discounts['discount_value']) ? $product_based_discounts['discount_value'] : '';
|
@@ -3056,6 +3077,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
3056 |
}
|
3057 |
}
|
3058 |
|
|
|
|
|
|
|
3059 |
$product = $woocommerce->cart->cart_contents[$item]['data'];
|
3060 |
|
3061 |
$product_id = FlycartWoocommerceProduct::get_id($product);
|
@@ -3369,17 +3393,6 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
3369 |
}
|
3370 |
}
|
3371 |
|
3372 |
-
$do_discount_from_regular_price = FlycartWooDiscountRulesGeneralHelper::applyDiscountFromRegularPrice();
|
3373 |
-
if($do_discount_from_regular_price){
|
3374 |
-
if($product->is_type(array('variable', 'subscription_variation', 'variable-subscription'))){
|
3375 |
-
$item_price = $this->getVariantMinAndMaxRegularPrice($product, $item_price);
|
3376 |
-
} else {
|
3377 |
-
$regular_price = FlycartWoocommerceProduct::get_price($product);
|
3378 |
-
$regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
|
3379 |
-
$item_price = FlycartWoocommerceProduct::wc_price($regular_price);
|
3380 |
-
}
|
3381 |
-
}
|
3382 |
-
|
3383 |
$notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
|
3384 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
|
3385 |
if($show_price_discount_on_product_page == 'show' && ($notAdmin || $runTheRulesEvenInAjax)){
|
@@ -3389,6 +3402,16 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
3389 |
}
|
3390 |
if(isset(self::$product_has_strike_out[$product_id]) && self::$product_has_strike_out[$product_id]['has_strikeout']){
|
3391 |
if(self::$product_has_strike_out[$product_id]['has_strikeout'] && !empty(self::$product_has_strike_out[$product_id]['new_strikeout_html'])){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3392 |
$item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
|
3393 |
$item_price = apply_filters('woo_discount_rules_price_strikeout_before_discount_price', $item_price, $product);
|
3394 |
$item_price = '<span class="cart_price wdr_product_strikeout"><del>' . $item_price . '</del> <ins>' . (self::$product_has_strike_out[$product_id]['new_strikeout_html']) . '</ins></span>';
|
@@ -3441,9 +3464,14 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
|
|
3441 |
$on_sale = true;
|
3442 |
self::$woo_discount_product_on_sale_is_active[$product_id] = true;
|
3443 |
}
|
3444 |
-
if(
|
3445 |
-
$
|
3446 |
-
|
|
|
|
|
|
|
|
|
|
|
3447 |
}
|
3448 |
}
|
3449 |
}
|
1144 |
}
|
1145 |
}
|
1146 |
|
1147 |
+
$exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $item);
|
1148 |
+
if($exclude_cart_item) continue;
|
1149 |
+
|
1150 |
if(isset($rule['method']) && $rule['method'] == 'qty_based'){
|
1151 |
if (isset($rule['type']) && isset($rule['apply_to'])) {
|
1152 |
if($product_page && !$bogo){
|
1258 |
|
1259 |
case 'all_products':
|
1260 |
default:
|
1261 |
+
$is_not_in_exclude_sale_items = !$this->isItemInSaleItems($rule['exclude_sale_items'], $item['data']);
|
1262 |
if (!$this->isItemInProductList($rule['product_to_exclude'], $item) && $is_not_in_exclude_sale_items) {
|
1263 |
if(isset($rule['is_cumulative_for_products']) && $rule['is_cumulative_for_products']){
|
1264 |
+
if($bogo) $quantity = $this->getProductQuantityForCumulativeProducts($item, 0, $rule);
|
1265 |
else $quantity = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
|
|
|
|
|
|
|
1266 |
}
|
1267 |
+
$discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo, $rule['product_to_exclude']);
|
1268 |
+
$applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
|
1269 |
+
}
|
1270 |
|
1271 |
+
break;
|
1272 |
}
|
1273 |
if(isset($applied_rules[$i]['amount']['product_ids'])){
|
1274 |
if(!empty($applied_rules[$i]['amount']['product_ids'])){
|
1293 |
}
|
1294 |
} else if(isset($rule['method']) && $rule['method'] == 'product_based'){
|
1295 |
$checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
|
1296 |
+
self::$product_on_sale_details[$index] = array('type' => 'product_dependent', 'details' => $rule);
|
1297 |
if(!empty($checkRuleMatches)){
|
1298 |
if(class_exists('FlycartWooDiscountRulesPriceProductDependent'))
|
1299 |
$discountInEachProducts = FlycartWooDiscountRulesPriceProductDependent::getDiscountInEachProducts($item, $rule, $checkRuleMatches, $product_page, $index);
|
1448 |
}
|
1449 |
}
|
1450 |
|
1451 |
+
$exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $cartItem);
|
1452 |
+
if($exclude_cart_item) continue;
|
1453 |
+
|
1454 |
// if(isset($cartItem['variation']) && !empty($cartItem['variation'])){
|
1455 |
// if(isset($cartItem['variation']['Type']) && !empty($cartItem['variation']['Type'])){
|
1456 |
// if($cartItem['variation']['Type'] == "Free Item") continue;
|
1580 |
if($is_exclude_sale_items){
|
1581 |
continue;
|
1582 |
}
|
1583 |
+
$exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $cartItem);
|
1584 |
+
if($exclude_cart_item) continue;
|
1585 |
if($hasExcludeProduct){
|
1586 |
$product_id = $cartItem['product_id'];
|
1587 |
if(isset($cartItem['variation_id']) && $cartItem['variation_id']){
|
1836 |
continue;
|
1837 |
}
|
1838 |
}
|
1839 |
+
$exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $values);
|
1840 |
+
if($exclude_cart_item) continue;
|
1841 |
+
|
1842 |
$_product = $values['data'];
|
1843 |
$productId = FlycartWoocommerceProduct::get_id($_product);
|
1844 |
$loadOriginalPrice = apply_filters('woo_discount_rules_load_original_price_on_get_cheapest_product', false);
|
2459 |
$product_to_buy = isset($product_based_conditions['product_to_buy']) ? $product_based_conditions['product_to_buy'] : array();
|
2460 |
$product_to_buy = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_buy);
|
2461 |
$product_to_apply = isset($product_based_conditions['product_to_apply']) ? $product_based_conditions['product_to_apply'] : array();
|
2462 |
+
$get_discount_type = isset($product_based_conditions['get_discount_type']) ? $product_based_conditions['get_discount_type'] : 'product';
|
2463 |
$product_to_apply = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_to_apply);
|
2464 |
+
$matched_category = false;
|
2465 |
+
if($get_discount_type == 'category'){
|
2466 |
+
$category = FlycartWooDiscountRulesGeneralHelper::getCategoryByPost($id, true);
|
2467 |
+
$category_to_apply = isset($product_based_conditions['category_to_apply']) ? $product_based_conditions['category_to_apply'] : array();
|
2468 |
+
if (count(array_intersect($category_to_apply, $category)) > 0) {
|
2469 |
+
$matched_category = true;
|
2470 |
+
}
|
2471 |
+
}
|
2472 |
+
if ((in_array($id, $product_to_buy) || in_array($id, $product_to_apply)) || $matched_category) {
|
2473 |
$product_based_discounts = json_decode((isset($rule->product_based_discount) ? $rule->product_based_discount : '{}'), true);
|
2474 |
$product_based_discount_type = isset($product_based_discounts['discount_type']) ? $product_based_discounts['discount_type'] : 'percentage_discount';
|
2475 |
$product_based_discount_value = isset($product_based_discounts['discount_value']) ? $product_based_discounts['discount_value'] : '';
|
3077 |
}
|
3078 |
}
|
3079 |
|
3080 |
+
$exclude_cart_item = apply_filters('woo_discount_rules_exclude_cart_item_from_discount', false, $woocommerce->cart->cart_contents[$item]);
|
3081 |
+
if($exclude_cart_item) return;
|
3082 |
+
|
3083 |
$product = $woocommerce->cart->cart_contents[$item]['data'];
|
3084 |
|
3085 |
$product_id = FlycartWoocommerceProduct::get_id($product);
|
3393 |
}
|
3394 |
}
|
3395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3396 |
$notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
|
3397 |
$show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
|
3398 |
if($show_price_discount_on_product_page == 'show' && ($notAdmin || $runTheRulesEvenInAjax)){
|
3402 |
}
|
3403 |
if(isset(self::$product_has_strike_out[$product_id]) && self::$product_has_strike_out[$product_id]['has_strikeout']){
|
3404 |
if(self::$product_has_strike_out[$product_id]['has_strikeout'] && !empty(self::$product_has_strike_out[$product_id]['new_strikeout_html'])){
|
3405 |
+
$do_discount_from_regular_price = FlycartWooDiscountRulesGeneralHelper::applyDiscountFromRegularPrice();
|
3406 |
+
if($do_discount_from_regular_price){
|
3407 |
+
if($product->is_type(array('variable', 'subscription_variation', 'variable-subscription'))){
|
3408 |
+
$item_price = $this->getVariantMinAndMaxRegularPrice($product, $item_price);
|
3409 |
+
} else {
|
3410 |
+
$regular_price = FlycartWoocommerceProduct::get_price($product);
|
3411 |
+
$regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
|
3412 |
+
$item_price = FlycartWoocommerceProduct::wc_price($regular_price);
|
3413 |
+
}
|
3414 |
+
}
|
3415 |
$item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
|
3416 |
$item_price = apply_filters('woo_discount_rules_price_strikeout_before_discount_price', $item_price, $product);
|
3417 |
$item_price = '<span class="cart_price wdr_product_strikeout"><del>' . $item_price . '</del> <ins>' . (self::$product_has_strike_out[$product_id]['new_strikeout_html']) . '</ins></span>';
|
3464 |
$on_sale = true;
|
3465 |
self::$woo_discount_product_on_sale_is_active[$product_id] = true;
|
3466 |
}
|
3467 |
+
if(!$on_sale){
|
3468 |
+
if(!empty(self::$product_on_sale_details[$product_id])){
|
3469 |
+
$has_discount = $this->generateDiscountTableData($product);
|
3470 |
+
if(!empty($has_discount) && count($has_discount) > 0){
|
3471 |
+
$on_sale = true;
|
3472 |
+
self::$woo_discount_product_on_sale_is_active[$product_id] = true;
|
3473 |
+
}
|
3474 |
+
}
|
3475 |
}
|
3476 |
}
|
3477 |
}
|
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, pricing deals
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.0
|
7 |
-
Stable tag: 1.7.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -312,6 +312,13 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
|
|
312 |
|
313 |
== Changelog ==
|
314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
= 1.7.8 - 06/02/19 =
|
316 |
* Fix - Coupon based rule doesn't work when Woocommerce coupon title updated
|
317 |
* Fix - Warning when regular price returns string value
|
4 |
Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts, pricing deals
|
5 |
Requires at least: 4.4.1
|
6 |
Tested up to: 5.0
|
7 |
+
Stable tag: 1.7.9
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
312 |
|
313 |
== Changelog ==
|
314 |
|
315 |
+
= 1.7.9 - 08/02/19 =
|
316 |
+
* Fix - Displays sale badge for all products while a bogo rule is enabled for specific products
|
317 |
+
* Fix - Not displaying sale badge for dependent product rule
|
318 |
+
* Fix - Sale price not displaying for normal sale product while option Apply discount based on Regular price is enabled
|
319 |
+
* Fix - Hide zero while apply coupon
|
320 |
+
* Improvement - Event woo_discount_rules_exclude_cart_item_from_discount to handle skip a cart item
|
321 |
+
|
322 |
= 1.7.8 - 06/02/19 =
|
323 |
* Fix - Coupon based rule doesn't work when Woocommerce coupon title updated
|
324 |
* Fix - Warning when regular price returns string value
|
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.7.
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|
5 |
* Description: Simple Discount Rules for WooCommerce.
|
6 |
* Author: Flycart Technologies LLP
|
7 |
* Author URI: https://www.flycart.org
|
8 |
+
* Version: 1.7.9
|
9 |
* Slug: woo-discount-rules
|
10 |
* Text Domain: woo-discount-rules
|
11 |
* Domain Path: /i18n/languages/
|