Discount Rules for WooCommerce - Version 1.4.45

Version Description

  • 12/02/18 =
  • Feature - Option to disable the rules while having coupon(third party) in cart
Download this release

Release Info

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

Code changes from version 1.4.44 to 1.4.45

helper/general-helper.php CHANGED
@@ -379,5 +379,42 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
379
 
380
  return $status;
381
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
383
  }
379
 
380
  return $status;
381
  }
382
+
383
+ public static function haveToApplyTheRules(){
384
+ $status = true;
385
+ $config = new FlycartWooDiscountBase();
386
+ $do_not_run_while_have_third_party_coupon = $config->getConfigData('do_not_run_while_have_third_party_coupon', 0);
387
+ if($do_not_run_while_have_third_party_coupon){
388
+ $hasCoupon = self::hasCouponInCart();
389
+ if($hasCoupon){
390
+ $status = false;
391
+ }
392
+ }
393
+
394
+ return $status;
395
+ }
396
+
397
+ /**
398
+ * Check has coupon - not related to woo discount rules
399
+ * */
400
+ public static function hasCouponInCart(){
401
+ $result = false;
402
+ $cartRules = new FlycartWooDiscountRulesCartRules();
403
+ $coupon_code = $cartRules->getCouponCode();
404
+ $coupon_code = strtolower($coupon_code);
405
+ global $woocommerce;
406
+ if (!empty($woocommerce->cart->applied_coupons)) {
407
+ $appliedCoupons = $woocommerce->cart->applied_coupons;
408
+ if(in_array($coupon_code, $appliedCoupons)){
409
+ if(count($appliedCoupons) > 1){
410
+ $result = true;
411
+ }
412
+ } else {
413
+ $result = true;
414
+ }
415
+ }
416
+
417
+ return $result;
418
+ }
419
  }
420
  }
includes/cart-rules.php CHANGED
@@ -241,6 +241,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
241
  $this->getDiscountAmount();
242
  // Add a Coupon Virtually (Temporary access).
243
  if ($this->discount_total != 0) {
 
244
  add_filter('woocommerce_get_shop_coupon_data', array($this, 'addVirtualCoupon'), 10, 2);
245
  add_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
246
  }
241
  $this->getDiscountAmount();
242
  // Add a Coupon Virtually (Temporary access).
243
  if ($this->discount_total != 0) {
244
+ if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
245
  add_filter('woocommerce_get_shop_coupon_data', array($this, 'addVirtualCoupon'), 10, 2);
246
  add_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
247
  }
includes/discount-base.php CHANGED
@@ -329,6 +329,19 @@ if (!class_exists('FlycartWooDiscountBase')) {
329
  }
330
  }
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  // -------------------------------------------SETTINGS END----------------------------------------------------------
333
 
334
  /**
329
  }
330
  }
331
 
332
+ /**
333
+ * Get Config data
334
+ *
335
+ * @param String $key
336
+ * @param mixed $default
337
+ * @return mixed
338
+ * */
339
+ public function getConfigData($key, $default = ''){
340
+ $config = $this->getBaseConfig();
341
+ if (is_string($config)) $config = json_decode($config, true);
342
+ return isset($config[$key])? $config[$key] : $default;
343
+ }
344
+
345
  // -------------------------------------------SETTINGS END----------------------------------------------------------
346
 
347
  /**
includes/pricing-rules.php CHANGED
@@ -735,6 +735,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
735
  */
736
  public function matchRules($index, $item, $product_page = 0)
737
  {
 
738
  $applied_rules = array();
739
  $quantity = (isset($item['quantity']) ? $item['quantity'] : 0);
740
  $i = 0;
@@ -1660,6 +1661,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1660
  */
1661
  public function initAdjustment()
1662
  {
 
 
1663
  global $woocommerce;
1664
 
1665
  // Get settings
735
  */
736
  public function matchRules($index, $item, $product_page = 0)
737
  {
738
+ if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
739
  $applied_rules = array();
740
  $quantity = (isset($item['quantity']) ? $item['quantity'] : 0);
741
  $i = 0;
1661
  */
1662
  public function initAdjustment()
1663
  {
1664
+ if(!FlycartWooDiscountRulesGeneralHelper::haveToApplyTheRules()) return false;
1665
+
1666
  global $woocommerce;
1667
 
1668
  // Get settings
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.4.44
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.4.44 - 08/02/18 =
245
  * Feature - Buy any or more products and get 10% discount in one or more cheapest (Pro)
246
 
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.4.45
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
241
 
242
  == Changelog ==
243
 
244
+ = 1.4.45 - 12/02/18 =
245
+ * Feature - Option to disable the rules while having coupon(third party) in cart
246
+
247
  = 1.4.44 - 08/02/18 =
248
  * Feature - Buy any or more products and get 10% discount in one or more cheapest (Pro)
249
 
view/settings.php CHANGED
@@ -221,6 +221,18 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
221
  <label><input type="radio" name="enable_bootstrap" value="0" <?php echo ($data['enable_bootstrap'] == 0)? 'checked': '' ?> /> <?php esc_html_e('No', 'woo-discount-rules'); ?></label>
222
  </div>
223
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
224
  <div class="row form-group">
225
  <div class="col-md-2">
226
  <label>
221
  <label><input type="radio" name="enable_bootstrap" value="0" <?php echo ($data['enable_bootstrap'] == 0)? 'checked': '' ?> /> <?php esc_html_e('No', 'woo-discount-rules'); ?></label>
222
  </div>
223
  </div>
224
+ <div class="row form-group">
225
+ <div class="col-md-2">
226
+ <label>
227
+ <?php esc_html_e('Disable the rules while have coupon(Third party) in cart', 'woo-discount-rules'); ?>
228
+ </label>
229
+ </div>
230
+ <?php $data['do_not_run_while_have_third_party_coupon'] = (isset($data['do_not_run_while_have_third_party_coupon']) ? $data['do_not_run_while_have_third_party_coupon'] : 0); ?>
231
+ <div class="col-md-6">
232
+ <label><input type="radio" name="do_not_run_while_have_third_party_coupon" value="1" <?php echo ($data['do_not_run_while_have_third_party_coupon'] == 1)? 'checked': '' ?>/> <?php esc_html_e('Yes', 'woo-discount-rules'); ?></label>
233
+ <label><input type="radio" name="do_not_run_while_have_third_party_coupon" value="0" <?php echo ($data['do_not_run_while_have_third_party_coupon'] == 0)? 'checked': '' ?> /> <?php esc_html_e('No', 'woo-discount-rules'); ?></label>
234
+ </div>
235
+ </div>
236
  <div class="row form-group">
237
  <div class="col-md-2">
238
  <label>
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.4.44
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1
@@ -17,4 +17,4 @@ if (!defined('ABSPATH')) exit; // Exit if accessed directly
17
 
18
  include_once('helper/activation-helper.php');
19
 
20
- include_once('loader.php');
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 1.4.45
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1
17
 
18
  include_once('helper/activation-helper.php');
19
 
20
+ include_once('loader.php');