Discount Rules for WooCommerce - Version 1.7.15

Version Description

  • 28/05/19 =
  • Fix - Load coupon based on post title in multi select ajax
  • Improvement - Event apply_filters('woo_discount_rules_load_product_price_discount_based_on_tax_in_product_page', true, $cart_item);
  • Improvement - Event apply_filters('woo_discount_rules_discount_amount_before_apply', $amount, $discount_item, $price, $product_page, $product);
Download this release

Release Info

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

Code changes from version 1.7.14 to 1.7.15

includes/discount-base.php CHANGED
@@ -311,8 +311,12 @@ if (!class_exists('FlycartWooDiscountBase')) {
311
  public static function loadSelectedCouponOptions($selected){
312
  $html_options = '';
313
  if(!empty($selected) && is_array($selected)){
314
- $args = array( 'numberposts' => '-1', 'post_type' => 'shop_coupon', 'post_name__in' => $selected);
315
- $posts = get_posts($args);
 
 
 
 
316
  if(!empty($posts)){
317
  if(count($posts)){
318
  foreach ($posts as $post){
311
  public static function loadSelectedCouponOptions($selected){
312
  $html_options = '';
313
  if(!empty($selected) && is_array($selected)){
314
+ // $args = array( 'numberposts' => '-1', 'post_type' => 'shop_coupon', 'post_name__in' => $selected);
315
+ // $posts = get_posts($args);
316
+ $in_data = "'".implode("','", $selected)."'";
317
+ global $wpdb;
318
+ $query = "SELECT `post_title`, `post_name` FROM $wpdb->posts WHERE `post_type` = 'shop_coupon' AND `post_title` IN (".$in_data.")";
319
+ $posts = $wpdb->get_results($query);
320
  if(!empty($posts)){
321
  if(count($posts)){
322
  foreach ($posts as $post){
includes/pricing-rules.php CHANGED
@@ -3101,6 +3101,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3101
  }
3102
  }
3103
  }
 
3104
  if(isset($set['rule_order'])){
3105
  $rule_data = array($set['rule_order'] => $set['item']);
3106
  } else {
@@ -3113,6 +3114,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3113
  // For All, All rules going to apply.
3114
  if (isset($set['amount']['percentage_discount'])) {
3115
  $discount = ($price / 100) * $set['amount']['percentage_discount'];
 
3116
  // Append all Discounts.
3117
  $overall_discount = $overall_discount + $discount;
3118
  $has_discount = 1;
@@ -3125,6 +3127,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3125
  }
3126
  }
3127
  }
 
3128
  // Append all Discounts.
3129
  $overall_discount = $overall_discount + $discount;
3130
  $has_discount = 1;
@@ -3169,7 +3172,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3169
  }
3170
  }
3171
  }
3172
-
3173
  if ($big < $amount) {
3174
  $big = $amount;
3175
  if(isset($discount_item['rule_order'])){
@@ -4055,13 +4058,20 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4055
  $product_id = FlycartWoocommerceProduct::get_id($cart_item);
4056
  $adjustment_set = $this->matched_sets[$cart_item_key];
4057
  $do_discount_from_regular_price = FlycartWooDiscountRulesGeneralHelper::applyDiscountFromRegularPrice();
 
4058
  if(!($price > 0)){
4059
  if($do_discount_from_regular_price){
4060
  $product_for_getting_regular_price = FlycartWoocommerceProduct::wc_get_product($product_id);
4061
  $regular_price = FlycartWoocommerceProduct::get_price($product_for_getting_regular_price);
4062
- $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product_for_getting_regular_price, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product_for_getting_regular_price, 1, $regular_price);
 
 
 
 
4063
  } else {
4064
- $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($cart_item) : FlycartWoocommerceProduct::get_price_including_tax($cart_item);
 
 
4065
  }
4066
  }
4067
 
@@ -4073,9 +4083,15 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4073
  $product_id = FlycartWoocommerceProduct::get_id($product);
4074
  if($do_discount_from_regular_price){
4075
  $regular_price = FlycartWoocommerceProduct::get_price($product);
4076
- $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);
 
 
 
 
4077
  } else {
4078
- $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product) : FlycartWoocommerceProduct::get_price_including_tax($product);
 
 
4079
  }
4080
  }
4081
  }
3101
  }
3102
  }
3103
  }
3104
+ $discount = apply_filters('woo_discount_rules_discount_amount_before_apply', $discount, $set, $price, $product_page, $product);
3105
  if(isset($set['rule_order'])){
3106
  $rule_data = array($set['rule_order'] => $set['item']);
3107
  } else {
3114
  // For All, All rules going to apply.
3115
  if (isset($set['amount']['percentage_discount'])) {
3116
  $discount = ($price / 100) * $set['amount']['percentage_discount'];
3117
+ $discount = apply_filters('woo_discount_rules_discount_amount_before_apply', $discount, $set, $price, $product_page, $product);
3118
  // Append all Discounts.
3119
  $overall_discount = $overall_discount + $discount;
3120
  $has_discount = 1;
3127
  }
3128
  }
3129
  }
3130
+ $discount = apply_filters('woo_discount_rules_discount_amount_before_apply', $discount, $set, $price, $product_page, $product);
3131
  // Append all Discounts.
3132
  $overall_discount = $overall_discount + $discount;
3133
  $has_discount = 1;
3172
  }
3173
  }
3174
  }
3175
+ $amount = apply_filters('woo_discount_rules_discount_amount_before_apply', $amount, $discount_item, $price, $product_page, $product);
3176
  if ($big < $amount) {
3177
  $big = $amount;
3178
  if(isset($discount_item['rule_order'])){
4058
  $product_id = FlycartWoocommerceProduct::get_id($cart_item);
4059
  $adjustment_set = $this->matched_sets[$cart_item_key];
4060
  $do_discount_from_regular_price = FlycartWooDiscountRulesGeneralHelper::applyDiscountFromRegularPrice();
4061
+ $price_based_on_tax = apply_filters('woo_discount_rules_load_product_price_discount_based_on_tax_in_product_page', true, $cart_item);
4062
  if(!($price > 0)){
4063
  if($do_discount_from_regular_price){
4064
  $product_for_getting_regular_price = FlycartWoocommerceProduct::wc_get_product($product_id);
4065
  $regular_price = FlycartWoocommerceProduct::get_price($product_for_getting_regular_price);
4066
+ if($price_based_on_tax){
4067
+ $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product_for_getting_regular_price, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product_for_getting_regular_price, 1, $regular_price);
4068
+ } else {
4069
+ $price = $regular_price;
4070
+ }
4071
  } else {
4072
+ if($price_based_on_tax) {
4073
+ $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($cart_item) : FlycartWoocommerceProduct::get_price_including_tax($cart_item);
4074
+ }
4075
  }
4076
  }
4077
 
4083
  $product_id = FlycartWoocommerceProduct::get_id($product);
4084
  if($do_discount_from_regular_price){
4085
  $regular_price = FlycartWoocommerceProduct::get_price($product);
4086
+ if($price_based_on_tax){
4087
+ $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);
4088
+ } else {
4089
+ $price = $regular_price;
4090
+ }
4091
  } else {
4092
+ if($price_based_on_tax){
4093
+ $price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product) : FlycartWoocommerceProduct::get_price_including_tax($product);
4094
+ }
4095
  }
4096
  }
4097
  }
readme.txt CHANGED
@@ -4,16 +4,16 @@ 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.2
7
- Stable tag: 1.7.14
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Create simple to complex discount rules, dynamic pricing and discounts for your WooCommerce online store.
12
  == Description ==
13
 
14
- Discount Rules for WooCommerce helps you to create any type of bulk discounts, dynamic pricing, advanced discounts, percentage discounts, user role based discounts for your products. Offer Product quantity based discounts, cart based discounts at a percentage or fixed amount or Buy One and Get one free (BOGO) deals or discount based on total order. Increase your sales multifold by offering dynamic pricing and discounts based on categories, products, user roles, cart items, purchase history and much more.
15
 
16
- You can set discounts for products, product variations, categories, attributes and more. You can also create customer specific, user roles based discounts.
17
 
18
  Discounts will be visible in product page, product details page, cart, checkout and in email notifications.
19
 
@@ -312,6 +312,11 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
312
 
313
  == Changelog ==
314
 
 
 
 
 
 
315
  = 1.7.14 - 13/05/19 =
316
  * Improvement - BOGO auto add made compatible with WooCommerce v3.6.2
317
  * Improvement - Avoid error while selecting additional taxonomy and if it is not valid.
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.2
7
+ Stable tag: 1.7.15
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Create simple to complex discount rules, dynamic pricing and discounts for your WooCommerce online store.
12
  == Description ==
13
 
14
+ [Discount Rules for WooCommerce](https://www.flycart.org/products/wordpress/woocommerce-discount-rules) helps you to create any type of bulk discounts, dynamic pricing, advanced discounts, percentage discounts, product based discounts, tiered discounts for your products. Offer Product quantity based discounts, cart based discounts at a percentage or fixed amount or discount based on total order. Create Buy One and Get one free (BOGO) deals and increase your sales multifold by offering dynamic pricing and discounts based on categories, products, user roles, cart items, purchase history and much more in the pro version.
15
 
16
+ You can set discounts for products and product variations. You can also set discounts based on categories, attributes, customers, user roles in the pro version.
17
 
18
  Discounts will be visible in product page, product details page, cart, checkout and in email notifications.
19
 
312
 
313
  == Changelog ==
314
 
315
+ = 1.7.15 - 28/05/19 =
316
+ * Fix - Load coupon based on post title in multi select ajax
317
+ * Improvement - Event apply_filters('woo_discount_rules_load_product_price_discount_based_on_tax_in_product_page', true, $cart_item);
318
+ * Improvement - Event apply_filters('woo_discount_rules_discount_amount_before_apply', $amount, $discount_item, $price, $product_page, $product);
319
+
320
  = 1.7.14 - 13/05/19 =
321
  * Improvement - BOGO auto add made compatible with WooCommerce v3.6.2
322
  * Improvement - Avoid error while selecting additional taxonomy and if it is not valid.
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.14
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.15
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/