Discount Rules for WooCommerce - Version 1.7.4

Version Description

  • 09/01/19 =
  • Improvement - Save the rule based on language while having WPML
  • Fix - Fatal error for the product type changed from variant to simple
  • Fix - Warning while some plugin returns the price in string
  • Fix - Wrong fixed discount applies for the cart rule while having both the price rules and cart rules
  • Fix - Hide zero value in coupon
  • Fix - Error on choose variant product as free in cart rules
Download this release

Release Info

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

Code changes from version 1.7.3 to 1.7.4

helper/general-helper.php CHANGED
@@ -722,7 +722,11 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
722
  $is_ajax = is_ajax();
723
  $wc_ajax = isset($_REQUEST['wc-ajax'])? $_REQUEST['wc-ajax']: false;
724
  if(!$is_ajax){
 
 
725
  //echo "<style>".$styles."</style>";
 
 
726
  add_action('wp_head', 'FlycartWooDiscountRulesGeneralHelper::woo_discount_rules_custom_styles', 100);
727
  } else if(in_array($wc_ajax, array('apply_coupon'))){
728
  echo "<style>".$styles."</style>";
@@ -736,5 +740,21 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
736
  global $styles_woo_discount;
737
  echo "<style>".$styles_woo_discount."</style>";
738
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
739
  }
740
  }
722
  $is_ajax = is_ajax();
723
  $wc_ajax = isset($_REQUEST['wc-ajax'])? $_REQUEST['wc-ajax']: false;
724
  if(!$is_ajax){
725
+ global $flycart_woo_discount_rules_hide_zero_coupon;
726
+ $flycart_woo_discount_rules_hide_zero_coupon = "<style>".$styles."</style>";
727
  //echo "<style>".$styles."</style>";
728
+ add_action('woocommerce_before_checkout_form', 'FlycartWooDiscountRulesGeneralHelper::woo_discount_rules_custom_styles');
729
+ add_action('woocommerce_before_cart', 'FlycartWooDiscountRulesGeneralHelper::woo_discount_rules_custom_styles');
730
  add_action('wp_head', 'FlycartWooDiscountRulesGeneralHelper::woo_discount_rules_custom_styles', 100);
731
  } else if(in_array($wc_ajax, array('apply_coupon'))){
732
  echo "<style>".$styles."</style>";
740
  global $styles_woo_discount;
741
  echo "<style>".$styles_woo_discount."</style>";
742
  }
743
+
744
+ /**
745
+ * Get WPML Language
746
+ * */
747
+ public static function getWPMLLanguage(){
748
+ $wpml_language = '';
749
+ if(defined('WOO_DISCOUNT_AVAILABLE_WPML')){
750
+ if(WOO_DISCOUNT_AVAILABLE_WPML){
751
+ if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
752
+ $wpml_language = ICL_LANGUAGE_CODE;
753
+ }
754
+ }
755
+ }
756
+
757
+ return $wpml_language;
758
+ }
759
  }
760
  }
helper/woo-function.php CHANGED
@@ -171,7 +171,10 @@ if(!class_exists('FlycartWoocommerceProduct')){
171
  * @return int/float
172
  */
173
  public static function get_price($product){
174
- return FlycartWoocommerceVersion::wcVersion('3.0') ? $product->get_price() : $product->price;
 
 
 
175
  }
176
 
177
  /**
@@ -315,8 +318,10 @@ if(!class_exists('FlycartWoocommerceProduct')){
315
  */
316
  public static function get_category_ids($product)
317
  {
318
- $parent = self::get_parent_id($product);
319
- if($parent) $product = self::wc_get_product($parent);
 
 
320
  $cat_id = array();
321
  if(FlycartWoocommerceVersion::wcVersion('3.0') || method_exists($product, 'get_category_ids')){
322
  $cat_id = $product->get_category_ids();
171
  * @return int/float
172
  */
173
  public static function get_price($product){
174
+ $price = FlycartWoocommerceVersion::wcVersion('3.0') ? $product->get_price() : $product->price;
175
+ $price = floatval($price);
176
+
177
+ return $price;
178
  }
179
 
180
  /**
318
  */
319
  public static function get_category_ids($product)
320
  {
321
+ if(!$product->is_type( 'simple' )) {
322
+ $parent = self::get_parent_id($product);
323
+ if($parent) $product = self::wc_get_product($parent);
324
+ }
325
  $cat_id = array();
326
  if(FlycartWoocommerceVersion::wcVersion('3.0') || method_exists($product, 'get_category_ids')){
327
  $cat_id = $product->get_category_ids();
includes/cart-rules.php CHANGED
@@ -137,7 +137,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
137
  'to_discount',
138
  'discount_rule',
139
  'rule_order',
140
- 'status'
 
141
  );
142
 
143
  if ($id) {
@@ -171,6 +172,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
171
 
172
  if (is_null($id) || !isset($id)) return false;
173
 
 
 
174
  foreach ($request as $index => $value) {
175
  if (in_array($index, $form)) {
176
  if (get_post_meta($id, $index)) {
@@ -237,8 +240,16 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
237
 
238
  if ($onlyCount) return count($posts);
239
  if (isset($posts) && count($posts) > 0) {
 
240
  foreach ($posts as $index => $item) {
241
  $posts[$index]->meta = get_post_meta($posts[$index]->ID);
 
 
 
 
 
 
 
242
  }
243
 
244
  $this->rules = $posts;
@@ -447,14 +458,36 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
447
 
448
  // Add coupon
449
  $woocommerce->cart->applied_coupons[] = $coupon_code;
450
- remove_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
451
- do_action('woocommerce_applied_coupon', $coupon_code);
452
- add_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
 
 
 
 
 
 
453
 
454
  return true;
455
  }
456
  }
457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  public function applyFakeCouponsForBOGO()
459
  {
460
  global $woocommerce;
@@ -479,7 +512,15 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
479
 
480
  // Add coupon
481
  $woocommerce->cart->applied_coupons[] = $coupon_code;
482
- do_action('woocommerce_applied_coupon', $coupon_code);
 
 
 
 
 
 
 
 
483
  }
484
  }
485
  }
@@ -666,7 +707,11 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
666
  } else {
667
  //we will have to re-calculate the sub-total if it has category selected
668
  if($this->is_category_specific($rule)) {
669
- do_action('woocommerce_before_calculate_totals');
 
 
 
 
670
  $this->has_category_in_rule = 1;
671
  //re-calculate the sub-total
672
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
@@ -1456,6 +1501,12 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1456
  */
1457
  public function calculateCartSubtotal()
1458
  {
 
 
 
 
 
 
1459
  $cart_subtotal = 0;
1460
  // Iterate over all cart items and
1461
  foreach ($this->cart_items as $cart_item_key => $cart_item) {
@@ -1555,9 +1606,11 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1555
  if (empty($cart_item['data'])) {
1556
  continue;
1557
  }
1558
- $added_products[$cart_item['product_id']] = array('item_name'=> FlycartWoocommerceProduct::get_name($cart_item['data']), 'item_quantity' => $cart_item['quantity'], 'item' => $cart_item_key, 'item_price' => FlycartWoocommerceProduct::get_price($cart_item['data']));
 
1559
  }
1560
  foreach ($product_ids as $discounted_product_id) {
 
1561
  //Check the discounted product already found in cart
1562
  if (array_key_exists($discounted_product_id, $added_products)) {
1563
  $old_quantity = isset($added_products[$discounted_product_id]['item_quantity']) ? $added_products[$discounted_product_id]['item_quantity'] : 0;
137
  'to_discount',
138
  'discount_rule',
139
  'rule_order',
140
+ 'status',
141
+ 'wpml_language',
142
  );
143
 
144
  if ($id) {
172
 
173
  if (is_null($id) || !isset($id)) return false;
174
 
175
+ $request['wpml_language'] = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
176
+
177
  foreach ($request as $index => $value) {
178
  if (in_array($index, $form)) {
179
  if (get_post_meta($id, $index)) {
240
 
241
  if ($onlyCount) return count($posts);
242
  if (isset($posts) && count($posts) > 0) {
243
+ $wpml_language = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
244
  foreach ($posts as $index => $item) {
245
  $posts[$index]->meta = get_post_meta($posts[$index]->ID);
246
+ if(!empty($wpml_language) && $wpml_language != 'all'){
247
+ if(isset($posts[$index]->meta['wpml_language'])){
248
+ if(isset($posts[$index]->meta['wpml_language']['0'])){
249
+ if($posts[$index]->meta['wpml_language']['0'] != $wpml_language && $posts[$index]->meta['wpml_language']['0'] != '' && $posts[$index]->meta['wpml_language']['0'] != 'all') unset($posts[$index]);
250
+ }
251
+ }
252
+ }
253
  }
254
 
255
  $this->rules = $posts;
458
 
459
  // Add coupon
460
  $woocommerce->cart->applied_coupons[] = $coupon_code;
461
+ $trigger_applied_coupon_before_load_cart = apply_filters('woo_discount_rules_trigger_applied_coupon_before_load_cart', false);
462
+ if($trigger_applied_coupon_before_load_cart){
463
+ add_action('woocommerce_before_cart', array($this, 'trigger_event_woocommerce_applied_coupon'));
464
+ add_action('woocommerce_review_order_before_cart_contents', array($this, 'trigger_event_woocommerce_applied_coupon'));
465
+ } else {
466
+ remove_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
467
+ do_action('woocommerce_applied_coupon', $coupon_code);
468
+ add_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCoupons'));
469
+ }
470
 
471
  return true;
472
  }
473
  }
474
 
475
+ public function trigger_event_woocommerce_applied_coupon(){
476
+ global $woocommerce;
477
+ $coupon_code = apply_filters('woocommerce_coupon_code', $this->coupon_code);
478
+ if(in_array($coupon_code, $woocommerce->cart->applied_coupons)){
479
+ do_action('woocommerce_applied_coupon', $coupon_code);
480
+ }
481
+ if(!empty($this->bogo_coupon_codes)) {
482
+ foreach ($this->bogo_coupon_codes as $coupon_code => $coupon_data) {
483
+ $coupon_code = apply_filters('woocommerce_coupon_code', $coupon_code);
484
+ if(in_array($coupon_code, $woocommerce->cart->applied_coupons)){
485
+ do_action('woocommerce_applied_coupon', $coupon_code);
486
+ }
487
+ }
488
+ }
489
+ }
490
+
491
  public function applyFakeCouponsForBOGO()
492
  {
493
  global $woocommerce;
512
 
513
  // Add coupon
514
  $woocommerce->cart->applied_coupons[] = $coupon_code;
515
+ $trigger_applied_coupon_before_load_cart = apply_filters('woo_discount_rules_trigger_applied_coupon_before_load_cart', false);
516
+ if($trigger_applied_coupon_before_load_cart){
517
+ add_action('woocommerce_before_cart', array($this, 'trigger_event_woocommerce_applied_coupon'));
518
+ add_action('woocommerce_review_order_before_cart_contents', array($this, 'trigger_event_woocommerce_applied_coupon'));
519
+ } else {
520
+ remove_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCouponsForBOGO'));
521
+ do_action('woocommerce_applied_coupon', $coupon_code);
522
+ add_action('woocommerce_after_calculate_totals', array($this, 'applyFakeCouponsForBOGO'));
523
+ }
524
  }
525
  }
526
  }
707
  } else {
708
  //we will have to re-calculate the sub-total if it has category selected
709
  if($this->is_category_specific($rule)) {
710
+ if(!empty($this->cart_items)){
711
+ if(!did_action('woocommerce_before_calculate_totals')){
712
+ do_action('woocommerce_before_calculate_totals');
713
+ }
714
+ }
715
  $this->has_category_in_rule = 1;
716
  //re-calculate the sub-total
717
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
1501
  */
1502
  public function calculateCartSubtotal()
1503
  {
1504
+ if(!empty($this->cart_items)){
1505
+ if(!did_action('woocommerce_before_calculate_totals')){
1506
+ do_action('woocommerce_before_calculate_totals');
1507
+ }
1508
+ }
1509
+
1510
  $cart_subtotal = 0;
1511
  // Iterate over all cart items and
1512
  foreach ($this->cart_items as $cart_item_key => $cart_item) {
1606
  if (empty($cart_item['data'])) {
1607
  continue;
1608
  }
1609
+ $product_id = (isset($cart_item['variation_id']) && $cart_item['variation_id'] > 0) ? $cart_item['variation_id'] : $cart_item['product_id'];
1610
+ $added_products[$product_id] = array('item_name'=> FlycartWoocommerceProduct::get_name($cart_item['data']), 'item_quantity' => $cart_item['quantity'], 'item' => $cart_item_key, 'item_price' => FlycartWoocommerceProduct::get_price($cart_item['data']));
1611
  }
1612
  foreach ($product_ids as $discounted_product_id) {
1613
+ $discounted_price=0;
1614
  //Check the discounted product already found in cart
1615
  if (array_key_exists($discounted_product_id, $added_products)) {
1616
  $old_quantity = isset($added_products[$discounted_product_id]['item_quantity']) ? $added_products[$discounted_product_id]['item_quantity'] : 0;
includes/discount-base.php CHANGED
@@ -924,14 +924,14 @@ if (!class_exists('FlycartWooDiscountBase')) {
924
  'customer_shipping_zip_code' => esc_html__('Shipping zip code', 'woo-discount-rules'),
925
  'purchase_history' => esc_html__('Purchase History', 'woo-discount-rules'),
926
  'purchased_amount' => esc_html__('Purchased amount', 'woo-discount-rules'),
927
- 'number_of_order_purchased' => esc_html__('Number of order purchased', 'woo-discount-rules'),
928
- 'number_of_order_purchased_in_product' => esc_html__('Number of order purchased in products', 'woo-discount-rules'),
929
  'coupon_applied' => esc_html__('Coupon applied', 'woo-discount-rules'),
930
  'atleast_any_one' => esc_html__('Atleast any one', 'woo-discount-rules'),
931
  'all_selected_coupon' => esc_html__('All selected', 'woo-discount-rules'),
932
  'greater_than_or_equal_to' => esc_html__('Greater than or equal to', 'woo-discount-rules'),
933
  'less_than_or_equal_to' => esc_html__('Less than or equal to', 'woo-discount-rules'),
934
- 'in_order_status' => esc_html__('In Order status', 'woo-discount-rules'),
935
  'action_text' => esc_html__('Action', 'woo-discount-rules'),
936
  'save_text' => esc_html__('Save', 'woo-discount-rules'),
937
  'saved_successfully' => esc_html__('Saved Successfully!', 'woo-discount-rules'),
924
  'customer_shipping_zip_code' => esc_html__('Shipping zip code', 'woo-discount-rules'),
925
  'purchase_history' => esc_html__('Purchase History', 'woo-discount-rules'),
926
  'purchased_amount' => esc_html__('Purchased amount', 'woo-discount-rules'),
927
+ 'number_of_order_purchased' => esc_html__('Number of previous orders made', 'woo-discount-rules'),
928
+ 'number_of_order_purchased_in_product' => esc_html__('Number of previous orders made with following products', 'woo-discount-rules'),
929
  'coupon_applied' => esc_html__('Coupon applied', 'woo-discount-rules'),
930
  'atleast_any_one' => esc_html__('Atleast any one', 'woo-discount-rules'),
931
  'all_selected_coupon' => esc_html__('All selected', 'woo-discount-rules'),
932
  'greater_than_or_equal_to' => esc_html__('Greater than or equal to', 'woo-discount-rules'),
933
  'less_than_or_equal_to' => esc_html__('Less than or equal to', 'woo-discount-rules'),
934
+ 'in_order_status' => esc_html__('and the order status should be', 'woo-discount-rules'),
935
  'action_text' => esc_html__('Action', 'woo-discount-rules'),
936
  'save_text' => esc_html__('Save', 'woo-discount-rules'),
937
  'saved_successfully' => esc_html__('Saved Successfully!', 'woo-discount-rules'),
includes/pricing-rules.php CHANGED
@@ -168,7 +168,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
168
  'coupons_to_apply',
169
  'subtotal_to_apply_option',
170
  'subtotal_to_apply',
171
- 'exclude_sale_items'
 
172
  );
173
 
174
  //----------------------------------------------------------------------------------------------------------
@@ -284,6 +285,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
284
  }
285
 
286
  $request['status'] = 'publish';
 
287
 
288
  if (is_null($id) || !isset($id)) return false;
289
  foreach ($request as $index => $value) {
@@ -399,8 +401,16 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
399
 
400
  if ($onlyCount) return count($posts);
401
  if (isset($posts) && count($posts) > 0) {
 
402
  foreach ($posts as $index => $item) {
403
  $posts[$index]->meta = get_post_meta($posts[$index]->ID);
 
 
 
 
 
 
 
404
  }
405
  $this->rules = $posts;
406
  }
@@ -1810,6 +1820,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1810
  }
1811
  $_product = $values['data'];
1812
  $productId = FlycartWoocommerceProduct::get_id($_product);
 
 
 
 
1813
  if(!empty($product_to_exclude) && is_array($product_to_exclude)){
1814
  if(in_array($productId, $product_to_exclude)) continue;
1815
  }
@@ -3243,9 +3257,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3243
  $run_variation_strike_out_with_ajax = apply_filters('woo_discount_rules_run_variation_strike_out_with_ajax', true, $product);
3244
  if($run_variation_strike_out_with_ajax) {
3245
  if (!(defined('WOO_DISCOUNT_DOING_AJAX'))) {
3246
- $parent_id = FlycartWoocommerceProduct::get_parent_id($product);
3247
- if ($parent_id) {
3248
- return $item_price;
 
 
3249
  }
3250
  }
3251
  }
@@ -3295,9 +3311,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3295
  $run_variation_strike_out_with_ajax = apply_filters('woo_discount_rules_run_variation_strike_out_with_ajax', true, $product);
3296
  if($run_variation_strike_out_with_ajax){
3297
  if (!(defined('WOO_DISCOUNT_DOING_AJAX'))) {
3298
- $parent_id = FlycartWoocommerceProduct::get_parent_id($product);
3299
- if($parent_id){
3300
- return $item_price;
 
 
3301
  }
3302
  }
3303
  }
168
  'coupons_to_apply',
169
  'subtotal_to_apply_option',
170
  'subtotal_to_apply',
171
+ 'exclude_sale_items',
172
+ 'wpml_language',
173
  );
174
 
175
  //----------------------------------------------------------------------------------------------------------
285
  }
286
 
287
  $request['status'] = 'publish';
288
+ $request['wpml_language'] = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
289
 
290
  if (is_null($id) || !isset($id)) return false;
291
  foreach ($request as $index => $value) {
401
 
402
  if ($onlyCount) return count($posts);
403
  if (isset($posts) && count($posts) > 0) {
404
+ $wpml_language = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
405
  foreach ($posts as $index => $item) {
406
  $posts[$index]->meta = get_post_meta($posts[$index]->ID);
407
+ if(!empty($wpml_language) && $wpml_language != 'all'){
408
+ if(isset($posts[$index]->meta['wpml_language'])){
409
+ if(isset($posts[$index]->meta['wpml_language']['0'])){
410
+ if($posts[$index]->meta['wpml_language']['0'] != $wpml_language && $posts[$index]->meta['wpml_language']['0'] != '' && $posts[$index]->meta['wpml_language']['0'] != 'all') unset($posts[$index]);
411
+ }
412
+ }
413
+ }
414
  }
415
  $this->rules = $posts;
416
  }
1820
  }
1821
  $_product = $values['data'];
1822
  $productId = FlycartWoocommerceProduct::get_id($_product);
1823
+ $loadOriginalPrice = apply_filters('woo_discount_rules_load_original_price_on_get_cheapest_product', false);
1824
+ if($loadOriginalPrice){
1825
+ $_product = FlycartWoocommerceProduct::wc_get_product($productId);
1826
+ }
1827
  if(!empty($product_to_exclude) && is_array($product_to_exclude)){
1828
  if(in_array($productId, $product_to_exclude)) continue;
1829
  }
3257
  $run_variation_strike_out_with_ajax = apply_filters('woo_discount_rules_run_variation_strike_out_with_ajax', true, $product);
3258
  if($run_variation_strike_out_with_ajax) {
3259
  if (!(defined('WOO_DISCOUNT_DOING_AJAX'))) {
3260
+ if(!$product->is_type( 'simple' )) {
3261
+ $parent_id = FlycartWoocommerceProduct::get_parent_id($product);
3262
+ if ($parent_id) {
3263
+ return $item_price;
3264
+ }
3265
  }
3266
  }
3267
  }
3311
  $run_variation_strike_out_with_ajax = apply_filters('woo_discount_rules_run_variation_strike_out_with_ajax', true, $product);
3312
  if($run_variation_strike_out_with_ajax){
3313
  if (!(defined('WOO_DISCOUNT_DOING_AJAX'))) {
3314
+ if(!$product->is_type( 'simple' )) {
3315
+ $parent_id = FlycartWoocommerceProduct::get_parent_id($product);
3316
+ if($parent_id){
3317
+ return $item_price;
3318
+ }
3319
  }
3320
  }
3321
  }
loader.php CHANGED
@@ -48,6 +48,7 @@ if(!class_exists('FlycartWooDiscountRules')){
48
  * FlycartWooDiscountRules constructor
49
  * */
50
  public function __construct() {
 
51
  $this->includeFiles();
52
  $this->discountBase = new FlycartWooDiscountBase();
53
  $this->runUpdater();
@@ -61,6 +62,17 @@ if(!class_exists('FlycartWooDiscountRules')){
61
  $this->loadCommonScripts();
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
64
  /**
65
  * To include Files
66
  * */
48
  * FlycartWooDiscountRules constructor
49
  * */
50
  public function __construct() {
51
+ $this->hasWPML();
52
  $this->includeFiles();
53
  $this->discountBase = new FlycartWooDiscountBase();
54
  $this->runUpdater();
62
  $this->loadCommonScripts();
63
  }
64
 
65
+ /**
66
+ * To check for WPML
67
+ * */
68
+ protected function hasWPML(){
69
+ if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
70
+ define('WOO_DISCOUNT_AVAILABLE_WPML', true);
71
+ } else {
72
+ define('WOO_DISCOUNT_AVAILABLE_WPML', false);
73
+ }
74
+ }
75
+
76
  /**
77
  * To include Files
78
  * */
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.3
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -308,6 +308,14 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
308
 
309
  == Changelog ==
310
 
 
 
 
 
 
 
 
 
311
  = 1.7.3 - 12/12/18 =
312
  * Fix - Fatal error on discount table when config is not yet save
313
  * Fix - Warning while the price is in string format
@@ -651,4 +659,8 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
651
  = 1.4.0 - 26/10/16 =
652
  * PHP 5.3 compatibility added
653
 
 
 
 
 
654
  == Upgrade notice ==
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.4
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
308
 
309
  == Changelog ==
310
 
311
+ = 1.7.4 - 09/01/19 =
312
+ * Improvement - Save the rule based on language while having WPML
313
+ * Fix - Fatal error for the product type changed from variant to simple
314
+ * Fix - Warning while some plugin returns the price in string
315
+ * Fix - Wrong fixed discount applies for the cart rule while having both the price rules and cart rules
316
+ * Fix - Hide zero value in coupon
317
+ * Fix - Error on choose variant product as free in cart rules
318
+
319
  = 1.7.3 - 12/12/18 =
320
  * Fix - Fatal error on discount table when config is not yet save
321
  * Fix - Warning while the price is in string format
659
  = 1.4.0 - 26/10/16 =
660
  * PHP 5.3 compatibility added
661
 
662
+ == Credits ==
663
+
664
+ * Dutch Translation - [@mvdburg1971](https://profiles.wordpress.org/mvdburg1971) - Michael van der Burg
665
+
666
  == Upgrade notice ==
view/cart-rules.php CHANGED
@@ -37,6 +37,7 @@ if ( $current_orderby === $orderby ) {
37
  $class[] = 'sortable';
38
  $class[] = $desc_first ? 'asc' : 'desc';
39
  }
 
40
  ?>
41
  <div class="container-fluid woo_discount_loader_outer" id="cart_rule">
42
  <div class="row-fluid">
@@ -98,6 +99,11 @@ if ( $current_orderby === $orderby ) {
98
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
99
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
100
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
 
 
 
 
 
101
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
102
  <?php
103
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
@@ -149,6 +155,11 @@ if ( $current_orderby === $orderby ) {
149
  echo $validate_date_string;
150
  }
151
  ?></td>
 
 
 
 
 
152
  <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
153
  <td>
154
  <a class="btn btn-primary" href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
@@ -183,6 +194,11 @@ if ( $current_orderby === $orderby ) {
183
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
184
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
185
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
 
 
 
 
 
186
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
187
  <?php
188
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
37
  $class[] = 'sortable';
38
  $class[] = $desc_first ? 'asc' : 'desc';
39
  }
40
+ $current_language = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
41
  ?>
42
  <div class="container-fluid woo_discount_loader_outer" id="cart_rule">
43
  <div class="row-fluid">
99
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
100
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
101
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
102
+ <?php if(!empty($current_language)){
103
+ ?>
104
+ <th><?php esc_html_e('Language', 'woo-discount-rules'); ?></th>
105
+ <?php
106
+ } ?>
107
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
108
  <?php
109
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
155
  echo $validate_date_string;
156
  }
157
  ?></td>
158
+ <?php if(!empty($current_language)){
159
+ ?>
160
+ <td><?php echo((isset($rule->wpml_language) && ($rule->wpml_language != '')) ? $rule->wpml_language : ' - ') ?></td>
161
+ <?php
162
+ } ?>
163
  <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
164
  <td>
165
  <a class="btn btn-primary" href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
194
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
195
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
196
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
197
+ <?php if(!empty($current_language)){
198
+ ?>
199
+ <th><?php esc_html_e('Language', 'woo-discount-rules'); ?></th>
200
+ <?php
201
+ } ?>
202
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
203
  <?php
204
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
view/pricing-rules.php CHANGED
@@ -35,6 +35,7 @@ if ( $current_orderby === $orderby ) {
35
  $class[] = 'sortable';
36
  $class[] = $desc_first ? 'asc' : 'desc';
37
  }
 
38
  ?>
39
 
40
  <style>
@@ -128,6 +129,11 @@ if ( $current_orderby === $orderby ) {
128
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
129
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
130
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
 
 
 
 
 
131
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
132
  <?php
133
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
@@ -179,6 +185,11 @@ if ( $current_orderby === $orderby ) {
179
  echo $validate_date_string;
180
  }
181
  ?></td>
 
 
 
 
 
182
  <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
183
  <td>
184
  <a class="btn btn-primary" href="?page=woo_discount_rules&view=<?php echo $rule->ID ?>">
@@ -213,6 +224,11 @@ if ( $current_orderby === $orderby ) {
213
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
214
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
215
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
 
 
 
 
 
216
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
217
  <?php
218
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
35
  $class[] = 'sortable';
36
  $class[] = $desc_first ? 'asc' : 'desc';
37
  }
38
+ $current_language = FlycartWooDiscountRulesGeneralHelper::getWPMLLanguage();
39
  ?>
40
 
41
  <style>
129
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
130
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
131
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
132
+ <?php if(!empty($current_language)){
133
+ ?>
134
+ <th><?php esc_html_e('Language', 'woo-discount-rules'); ?></th>
135
+ <?php
136
+ } ?>
137
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
138
  <?php
139
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
185
  echo $validate_date_string;
186
  }
187
  ?></td>
188
+ <?php if(!empty($current_language)){
189
+ ?>
190
+ <td><?php echo((isset($rule->wpml_language) && ($rule->wpml_language != '')) ? $rule->wpml_language : ' - ') ?></td>
191
+ <?php
192
+ } ?>
193
  <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
194
  <td>
195
  <a class="btn btn-primary" href="?page=woo_discount_rules&view=<?php echo $rule->ID ?>">
224
  <th><?php esc_html_e('Start Date', 'woo-discount-rules'); ?></th>
225
  <th><?php esc_html_e('Expired On', 'woo-discount-rules'); ?></th>
226
  <th><?php esc_html_e('Status', 'woo-discount-rules'); ?></th>
227
+ <?php if(!empty($current_language)){
228
+ ?>
229
+ <th><?php esc_html_e('Language', 'woo-discount-rules'); ?></th>
230
+ <?php
231
+ } ?>
232
  <th class="manage-column column-title column-primary sorted <?php echo $current_order; ?>" scope="col">
233
  <?php
234
  $column_display_name = esc_html__('Order', 'woo-discount-rules');
view/view-cart-rules.php CHANGED
@@ -351,9 +351,9 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
351
  }
352
  if ($type == 'customer_based_on_purchase_history_order_count') { ?> selected=selected <?php } ?>>
353
  <?php if (!$pro) { ?>
354
- <?php esc_html_e('Number of order purchased', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
355
  <?php } else { ?>
356
- <?php esc_html_e('Number of order purchased', 'woo-discount-rules'); ?>
357
  <?php } ?>
358
  </option>
359
  <option
@@ -361,9 +361,9 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
361
  }
362
  if ($type == 'customer_based_on_purchase_history_product_order_count') { ?> selected=selected <?php } ?>>
363
  <?php if (!$pro) { ?>
364
- <?php esc_html_e('Number of order purchased in products', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
365
  <?php } else { ?>
366
- <?php esc_html_e('Number of order purchased in products', 'woo-discount-rules'); ?>
367
  <?php } ?>
368
  </option>
369
  </optgroup>
@@ -534,7 +534,7 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
534
  <option value="atleast"<?php echo ($purchased_history_type == 'atleast')? ' selected="selected"': ''; ?>><?php esc_html_e('Greater than or equal to', 'woo-discount-rules'); ?></option>
535
  <option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
536
  </select>
537
- <input name="discount_rule[<?php echo $i; ?>][purchased_history_amount]" value="<?php echo $purchased_history_amount; ?>" type="text"/> <?php esc_html_e('In Order status', 'woo-discount-rules'); ?>
538
  <select class="order_status_list selectpicker"
539
  data-live-search="true"
540
  id="order_status_list_<?php echo $i; ?>"
351
  }
352
  if ($type == 'customer_based_on_purchase_history_order_count') { ?> selected=selected <?php } ?>>
353
  <?php if (!$pro) { ?>
354
+ <?php esc_html_e('Number of previous orders made', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
355
  <?php } else { ?>
356
+ <?php esc_html_e('Number of previous orders made', 'woo-discount-rules'); ?>
357
  <?php } ?>
358
  </option>
359
  <option
361
  }
362
  if ($type == 'customer_based_on_purchase_history_product_order_count') { ?> selected=selected <?php } ?>>
363
  <?php if (!$pro) { ?>
364
+ <?php esc_html_e('Number of previous orders made with following products', 'woo-discount-rules'); ?> <b><?php echo $suffix; ?></b>
365
  <?php } else { ?>
366
+ <?php esc_html_e('Number of previous orders made with following products', 'woo-discount-rules'); ?>
367
  <?php } ?>
368
  </option>
369
  </optgroup>
534
  <option value="atleast"<?php echo ($purchased_history_type == 'atleast')? ' selected="selected"': ''; ?>><?php esc_html_e('Greater than or equal to', 'woo-discount-rules'); ?></option>
535
  <option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
536
  </select>
537
+ <input name="discount_rule[<?php echo $i; ?>][purchased_history_amount]" value="<?php echo $purchased_history_amount; ?>" type="text"/> <?php esc_html_e('and the order status should be', 'woo-discount-rules'); ?>
538
  <select class="order_status_list selectpicker"
539
  data-live-search="true"
540
  id="order_status_list_<?php echo $i; ?>"
view/view-pricing-rules.php CHANGED
@@ -485,8 +485,8 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
485
  <select class="selectpicker" id="based_on_purchase_history" name="based_on_purchase_history">
486
  <option value="0"<?php if ($based_on_purchase_history == '0') { ?> selected=selected <?php } ?>><?php esc_html_e('Do not use', 'woo-discount-rules'); ?></option>
487
  <option value="1"<?php if ($based_on_purchase_history == '1') { ?> selected=selected <?php } ?>><?php esc_html_e('Purchased amount', 'woo-discount-rules'); ?></option>
488
- <option value="2"<?php if ($based_on_purchase_history == '2') { ?> selected=selected <?php } ?>><?php esc_html_e('Number of orders', 'woo-discount-rules'); ?></option>
489
- <option value="3"<?php if ($based_on_purchase_history == '3') { ?> selected=selected <?php } ?>><?php esc_html_e('Purchased product', 'woo-discount-rules'); ?></option>
490
  </select>
491
  <?php echo FlycartWooDiscountRulesGeneralHelper::docsURLHTML('purchase-history-based-discounts/purchase-history-based-discount', 'purchase_history'); ?>
492
  <?php
@@ -525,7 +525,7 @@ $current_date_and_time = FlycartWooDiscountRulesGeneralHelper::getCurrentDateAnd
525
  <option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
526
  </select>
527
  <input type="text" value="<?php echo $purchased_history_amount; ?>" name="purchased_history_amount"/>
528
- <label><?php esc_html_e('In Order status', 'woo-discount-rules'); ?></label>
529
  <?php
530
  $woocommerce_order_status = wc_get_order_statuses();
531
  $purchase_history_status_list = json_decode((isset($data->purchase_history_status_list) ? $data->purchase_history_status_list : '{}'), true);
485
  <select class="selectpicker" id="based_on_purchase_history" name="based_on_purchase_history">
486
  <option value="0"<?php if ($based_on_purchase_history == '0') { ?> selected=selected <?php } ?>><?php esc_html_e('Do not use', 'woo-discount-rules'); ?></option>
487
  <option value="1"<?php if ($based_on_purchase_history == '1') { ?> selected=selected <?php } ?>><?php esc_html_e('Purchased amount', 'woo-discount-rules'); ?></option>
488
+ <option value="2"<?php if ($based_on_purchase_history == '2') { ?> selected=selected <?php } ?>><?php esc_html_e('Number of previous orders made', 'woo-discount-rules'); ?></option>
489
+ <option value="3"<?php if ($based_on_purchase_history == '3') { ?> selected=selected <?php } ?>><?php esc_html_e('Number of previous orders made with following products', 'woo-discount-rules'); ?></option>
490
  </select>
491
  <?php echo FlycartWooDiscountRulesGeneralHelper::docsURLHTML('purchase-history-based-discounts/purchase-history-based-discount', 'purchase_history'); ?>
492
  <?php
525
  <option value="less_than_or_equal"<?php echo ($purchased_history_type == 'less_than_or_equal')? ' selected="selected"': ''; ?>><?php esc_html_e('Less than or equal to', 'woo-discount-rules'); ?></option>
526
  </select>
527
  <input type="text" value="<?php echo $purchased_history_amount; ?>" name="purchased_history_amount"/>
528
+ <label><?php esc_html_e('and the order status should be', 'woo-discount-rules'); ?></label>
529
  <?php
530
  $woocommerce_order_status = wc_get_order_statuses();
531
  $purchase_history_status_list = json_decode((isset($data->purchase_history_status_list) ? $data->purchase_history_status_list : '{}'), true);
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.3
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.4
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/