Discount Rules for WooCommerce - Version 1.4.19

Version Description

  • 04/10/17 =
  • Feature Buy one/more and get one/more free product for pro version
Download this release

Release Info

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

Code changes from version 1.4.18 to 1.4.19

assets/js/app.js CHANGED
@@ -158,16 +158,28 @@ function validateFields(){
158
  var count = $('.discount_rule_list').length + 1;
159
  if (is_pro) {
160
  var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
161
- '<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control" name="discount_range[' + count + '][discount_type]"> ' +
162
- '<option value="percentage_discount"> Percentage Discount </option> <option value="price_discount">Price Discount </option> </select></label> <label>Value <input type="text" name="discount_range[' + count + '][to_discount]" class="form-control" value="" placeholder="ex. 50"> ' +
163
- '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
 
 
 
 
 
 
 
164
  } else {
165
  var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
166
- '<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control" name="discount_range[' + count + '][discount_type]"> ' +
167
- '<option value="percentage_discount"> Percentage Discount </option> <option disabled>Price Discount <b>' + pro_suffix + '</b> </option> </select></label> <label>Value <input type="text" name="discount_range[' + count + '][to_discount]" class="form-control" value="" placeholder="ex. 50"> ' +
168
- '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
 
 
 
 
169
  }
170
  $('#discount_rule_list').append(form);
 
171
  });
172
 
173
  // Removing Discount Rule.
@@ -368,6 +380,20 @@ function validateFields(){
368
 
369
  });
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
 
372
  // Saving Cart Rule.
373
  $('#saveCartRule').on('click', function (event) {
158
  var count = $('.discount_rule_list').length + 1;
159
  if (is_pro) {
160
  var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
161
+ '<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control price_discount_type" name="discount_range[' + count + '][discount_type]"> ' +
162
+ '<option value="percentage_discount"> Percentage Discount </option> <option value="price_discount">Price Discount </option> <option value="product_discount">Product Discount </option> </select></label> <label>Value ' +
163
+ '<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
164
+ form += '<div class="price_discount_product_list_con hide"><select class="product_list selectpicker price_discount_product_list" multiple name="discount_range[' + count + '][discount_product][]">';
165
+ $("#product_list select.product_list option").each(function()
166
+ {
167
+ form += '<option value="'+$(this).val()+'">'+$(this).html()+'</option>';
168
+ });
169
+ form += '</select></div>';
170
+ form += '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
171
  } else {
172
  var form = '<div class="discount_rule_list"> <div class="form-group"><label>Min Quantity <input type="text" name="discount_range[' + count + '][min_qty]" class="form-control" value="" placeholder="ex. 1"></label>' +
173
+ '<label>Max Quantity <input type="text" name="discount_range[' + count + '][max_qty]" class="form-control" value="" placeholder="ex. 50"> </label> <label>Adjustment Type<select class="form-control price_discount_type" name="discount_range[' + count + '][discount_type]"> ' +
174
+ '<option value="percentage_discount"> Percentage Discount </option> <option disabled>Price Discount <b>' + pro_suffix + '</b> </option> <option disabled>Product Discount <b>\' + pro_suffix + \'</b> </option> </select></label> <label>Value ' +
175
+ '<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
176
+ form += '<div class="price_discount_product_list_con hide"><select class="product_list selectpicker price_discount_product_list" multiple name="discount_range[' + count + '][discount_product][]">';
177
+ form += '<option>none</option>';
178
+ form += '</select></div>';
179
+ form += '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
180
  }
181
  $('#discount_rule_list').append(form);
182
+ $('.product_list').selectpicker('refresh');
183
  });
184
 
185
  // Removing Discount Rule.
380
 
381
  });
382
 
383
+ //on change discount type in price discount
384
+ $(document).on('change', '.price_discount_type', function () {
385
+ var discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_amount');
386
+ var price_discount_amount = $(this).closest('.discount_rule_list').find('.price_discount_product_list_con');
387
+ if($(this).val() == 'product_discount'){
388
+ discount_amount.hide();
389
+ price_discount_amount.removeClass('hide').show();
390
+ } else {
391
+ discount_amount.show();
392
+ price_discount_amount.hide();
393
+ }
394
+ });
395
+ $('.price_discount_type').trigger('change');
396
+
397
 
398
  // Saving Cart Rule.
399
  $('#saveCartRule').on('click', function (event) {
includes/pricing-rules-3.php CHANGED
@@ -401,9 +401,76 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
401
  // Sort cart by price ascending
402
 
403
  $cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  foreach ($cart_contents as $index => $item) {
405
  $this->matchRules($index, $item);
406
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  $this->makeLog();
408
  }
409
 
@@ -518,6 +585,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
518
  $applied_rules = array();
519
  $quantity = (isset($item['quantity']) ? $item['quantity'] : 0);
520
  $i = 0;
 
521
  foreach ($this->rule_sets as $id => $rule) {
522
 
523
  if (isset($rule['type']) && isset($rule['apply_to'])) {
@@ -564,6 +632,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
564
  }
565
  $i++;
566
  }
 
567
  $this->matched_sets[$index] = $applied_rules;
568
  }
569
 
@@ -629,7 +698,25 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
629
  if ($max == false) continue;
630
 
631
  if ((int)$min <= (int)$quantity && (int)$max >= (int)$quantity) {
632
- $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  }
634
 
635
  }
@@ -900,7 +987,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
900
 
901
  if ($rule->product_to_apply != null) {
902
  $status = false;
903
- if (array_intersect($products_to_apply, array($id)) > 0) {
904
  $status = true;
905
  }
906
  }
@@ -989,6 +1076,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
989
  $max = isset($value->max_qty) ? $value->max_qty : 0;
990
  $discount_type = isset($value->discount_type) ? $value->discount_type : 0;
991
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
 
992
  $html .= '<tr>';
993
  if (isset($base_config['show_discount_title_table'])) {
994
  if ($base_config['show_discount_title_table'] == 'show') {
@@ -996,7 +1084,19 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
996
  }
997
  }
998
  $html .= '<td>'.$min .' - ' . $max.'</td>';
999
- if ($discount_type == 'percentage_discount') {
 
 
 
 
 
 
 
 
 
 
 
 
1000
  $html .= '<td>'.$to_discount . ' %'.'</td>';
1001
  } else {
1002
  $html .= '<td>'.wc_price($to_discount) . ' %'.'</td>';
401
  // Sort cart by price ascending
402
 
403
  $cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
404
+
405
+ //to handle buy one get one
406
+ $free_products = WC()->session->get('woo_discount_rules_get_free_product', array());
407
+
408
+ // Handling Tight update with wooCommerce Changes.
409
+ $postData = \FlycartInput\FInput::getInstance();
410
+ $empty_apply_coupon = $postData->get('apply_coupon');
411
+ $empty_update_cart = $postData->get('update_cart');
412
+ $empty_proceed = $postData->get('proceed');
413
+ $runFreeProduct = (!empty($empty_apply_coupon) || !empty($empty_update_cart) || !empty($empty_proceed)) ? false : true;
414
+
415
+ $quantity_exists = array();
416
+ if(!empty($free_products) && $runFreeProduct){
417
+ //check if product already in cart
418
+ if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
419
+ foreach ($free_products as $productId => $free_product_detail) {
420
+ $found = false;
421
+ foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
422
+ $_product = $values['data'];
423
+ if ($_product->id == $productId){
424
+ $_quantity = $values['quantity'];
425
+ $_cart_item_key = $cart_item_key;
426
+ $found = true;
427
+ }
428
+ }
429
+ // if product found, add it
430
+ if ($found) {
431
+ WC()->cart->remove_cart_item( $_cart_item_key );
432
+ $quantity_exists[$productId] = $_quantity-$free_product_detail['count'];
433
+ if($quantity_exists[$productId] > 0){
434
+ WC()->cart->add_to_cart($productId, $quantity_exists[$productId]);
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+ WC()->session->set('woo_discount_rules_get_free_product', array());
441
+
442
  foreach ($cart_contents as $index => $item) {
443
  $this->matchRules($index, $item);
444
  }
445
+
446
+ //to handle buy one get one
447
+ $free_products = WC()->session->get('woo_discount_rules_get_free_product', array());
448
+ if(!empty($free_products) && $runFreeProduct){
449
+ //check if product already in cart
450
+ if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
451
+ foreach ($free_products as $productId => $free_product_detail) {
452
+ WC()->cart->add_to_cart($productId, $free_product_detail['count']);
453
+ $found = false;
454
+ foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
455
+ $_product = $values['data'];
456
+ if ($_product->id == $productId){
457
+ $freeProductRule[0]['amount'] = array('price_discount' => $_product->get_price());
458
+ $freeProductRule[0]['name'] = $free_product_detail['rule_name'];
459
+ $freeProductRule[0]['item'] = $cart_item_key;
460
+ $freeProductRule[0]['id'] = $_product->id;
461
+ if(isset($quantity_exists[$productId]) && $quantity_exists[$productId] > 0){
462
+ //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
463
+ $discount_price = $_product->get_price() - (($_product->get_price()/($quantity_exists[$productId]+$free_product_detail['count'])) * $quantity_exists[$productId]);
464
+ $freeProductRule[0]['amount'] = array('price_discount' => $discount_price);
465
+ }
466
+ $this->matched_sets[$cart_item_key] = $freeProductRule;
467
+ }
468
+ }
469
+ }
470
+
471
+ }
472
+ }
473
+
474
  $this->makeLog();
475
  }
476
 
585
  $applied_rules = array();
586
  $quantity = (isset($item['quantity']) ? $item['quantity'] : 0);
587
  $i = 0;
588
+
589
  foreach ($this->rule_sets as $id => $rule) {
590
 
591
  if (isset($rule['type']) && isset($rule['apply_to'])) {
632
  }
633
  $i++;
634
  }
635
+
636
  $this->matched_sets[$index] = $applied_rules;
637
  }
638
 
698
  if ($max == false) continue;
699
 
700
  if ((int)$min <= (int)$quantity && (int)$max >= (int)$quantity) {
701
+ if($type == 'product_discount'){
702
+ //to handle product discount
703
+ $free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
704
+ $productIds = (isset($range->discount_product) ? $range->discount_product : array());
705
+ if(!empty($productIds)){
706
+ foreach ($productIds as $productId){
707
+ if(isset($free_product[$productId])){
708
+ $free_product[$productId]['count'] = $free_product[$productId]['count']+1;
709
+ } else {
710
+ $free_product[$productId]['count'] = 1;
711
+ $free_product[$productId]['rule_name'] = $range->title;
712
+ }
713
+ }
714
+ WC()->session->set('woo_discount_rules_get_free_product', $free_product);
715
+ }
716
+ $adjustment[$type] = (isset($range->discount_product) ? $range->discount_product : array());
717
+ } else {
718
+ $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
719
+ }
720
  }
721
 
722
  }
987
 
988
  if ($rule->product_to_apply != null) {
989
  $status = false;
990
+ if (in_array($id, $products_to_apply)) {
991
  $status = true;
992
  }
993
  }
1076
  $max = isset($value->max_qty) ? $value->max_qty : 0;
1077
  $discount_type = isset($value->discount_type) ? $value->discount_type : 0;
1078
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
1079
+ $product_discount = isset($value->discount_product) ? $value->discount_product : array();
1080
  $html .= '<tr>';
1081
  if (isset($base_config['show_discount_title_table'])) {
1082
  if ($base_config['show_discount_title_table'] == 'show') {
1084
  }
1085
  }
1086
  $html .= '<td>'.$min .' - ' . $max.'</td>';
1087
+ if ($discount_type == 'product_discount') {
1088
+ $html .= '<td>';
1089
+ if(count($product_discount)){
1090
+ $htmlProduct = '';
1091
+ foreach ($product_discount as $product_id){
1092
+ $product = wc_get_product( $product_id );
1093
+ $htmlProduct .= $product->get_title();
1094
+ $htmlProduct .= ' ('.$product->get_price_html().')<br>';
1095
+ }
1096
+ $html .= trim($htmlProduct, '<br>');
1097
+ }
1098
+ $html .= '</td>';
1099
+ } else if ($discount_type == 'percentage_discount') {
1100
  $html .= '<td>'.$to_discount . ' %'.'</td>';
1101
  } else {
1102
  $html .= '<td>'.wc_price($to_discount) . ' %'.'</td>';
includes/pricing-rules.php CHANGED
@@ -401,9 +401,76 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
401
  // Sort cart by price ascending
402
 
403
  $cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  foreach ($cart_contents as $index => $item) {
405
  $this->matchRules($index, $item);
406
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  $this->makeLog();
408
  }
409
 
@@ -629,7 +696,25 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
629
  if ($max == false) continue;
630
 
631
  if ((int)$min <= (int)$quantity && (int)$max >= (int)$quantity) {
632
- $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  }
634
 
635
  }
@@ -900,7 +985,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
900
 
901
  if ($rule->product_to_apply != null) {
902
  $status = false;
903
- if (array_intersect($products_to_apply, array($id)) > 0) {
904
  $status = true;
905
  }
906
  }
@@ -989,6 +1074,7 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
989
  $max = isset($value->max_qty) ? $value->max_qty : 0;
990
  $discount_type = isset($value->discount_type) ? $value->discount_type : 0;
991
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
 
992
  $html .= '<tr>';
993
  if (isset($base_config['show_discount_title_table'])) {
994
  if ($base_config['show_discount_title_table'] == 'show') {
@@ -996,7 +1082,17 @@ if (!class_exists('woo_dicount_rules_pricingRules')) {
996
  }
997
  }
998
  $html .= '<td>'.$min .' - ' . $max.'</td>';
999
- if ($discount_type == 'percentage_discount') {
 
 
 
 
 
 
 
 
 
 
1000
  $html .= '<td>'.$to_discount . ' %'.'</td>';
1001
  } else {
1002
  $html .= '<td>'.wc_price($to_discount) . ' %'.'</td>';
401
  // Sort cart by price ascending
402
 
403
  $cart_contents = $this->sortCartPrice($woocommerce->cart->cart_contents, 'asc');
404
+
405
+ //to handle buy one get one
406
+ $free_products = WC()->session->get('woo_discount_rules_get_free_product', array());
407
+
408
+ // Handling Tight update with wooCommerce Changes.
409
+ $postData = \FlycartInput\FInput::getInstance();
410
+ $empty_apply_coupon = $postData->get('apply_coupon');
411
+ $empty_update_cart = $postData->get('update_cart');
412
+ $empty_proceed = $postData->get('proceed');
413
+ $runFreeProduct = (!empty($empty_apply_coupon) || !empty($empty_update_cart) || !empty($empty_proceed)) ? false : true;
414
+
415
+ $quantity_exists = array();
416
+ if(!empty($free_products) && $runFreeProduct){
417
+ //check if product already in cart
418
+ if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
419
+ foreach ($free_products as $productId => $free_product_detail) {
420
+ $found = false;
421
+ foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
422
+ $_product = $values['data'];
423
+ if ($_product->id == $productId){
424
+ $_quantity = $values['quantity'];
425
+ $_cart_item_key = $cart_item_key;
426
+ $found = true;
427
+ }
428
+ }
429
+ // if product found, add it
430
+ if ($found) {
431
+ WC()->cart->remove_cart_item( $_cart_item_key );
432
+ $quantity_exists[$productId] = $_quantity-$free_product_detail['count'];
433
+ if($quantity_exists[$productId] > 0){
434
+ WC()->cart->add_to_cart($productId, $quantity_exists[$productId]);
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+ WC()->session->set('woo_discount_rules_get_free_product', array());
441
+
442
  foreach ($cart_contents as $index => $item) {
443
  $this->matchRules($index, $item);
444
  }
445
+
446
+ //to handle buy one get one
447
+ $free_products = WC()->session->get('woo_discount_rules_get_free_product', array());
448
+ if(!empty($free_products) && $runFreeProduct){
449
+ //check if product already in cart
450
+ if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
451
+ foreach ($free_products as $productId => $free_product_detail) {
452
+ WC()->cart->add_to_cart($productId, $free_product_detail['count']);
453
+ $found = false;
454
+ foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
455
+ $_product = $values['data'];
456
+ if ($_product->id == $productId){
457
+ $freeProductRule[0]['amount'] = array('price_discount' => $_product->get_price());
458
+ $freeProductRule[0]['name'] = $free_product_detail['rule_name'];
459
+ $freeProductRule[0]['item'] = $cart_item_key;
460
+ $freeProductRule[0]['id'] = $_product->id;
461
+ if(isset($quantity_exists[$productId]) && $quantity_exists[$productId] > 0){
462
+ //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
463
+ $discount_price = $_product->get_price() - (($_product->get_price()/($quantity_exists[$productId]+$free_product_detail['count'])) * $quantity_exists[$productId]);
464
+ $freeProductRule[0]['amount'] = array('price_discount' => $discount_price);
465
+ }
466
+ $this->matched_sets[$cart_item_key] = $freeProductRule;
467
+ }
468
+ }
469
+ }
470
+
471
+ }
472
+ }
473
+
474
  $this->makeLog();
475
  }
476
 
696
  if ($max == false) continue;
697
 
698
  if ((int)$min <= (int)$quantity && (int)$max >= (int)$quantity) {
699
+ if($type == 'product_discount'){
700
+ //to handle product discount
701
+ $free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
702
+ $productIds = (isset($range->discount_product) ? $range->discount_product : array());
703
+ if(!empty($productIds)){
704
+ foreach ($productIds as $productId){
705
+ if(isset($free_product[$productId])){
706
+ $free_product[$productId]['count'] = $free_product[$productId]['count']+1;
707
+ } else {
708
+ $free_product[$productId]['count'] = 1;
709
+ $free_product[$productId]['rule_name'] = $range->title;
710
+ }
711
+ }
712
+ WC()->session->set('woo_discount_rules_get_free_product', $free_product);
713
+ }
714
+ $adjustment[$type] = (isset($range->discount_product) ? $range->discount_product : array());
715
+ } else {
716
+ $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
717
+ }
718
  }
719
 
720
  }
985
 
986
  if ($rule->product_to_apply != null) {
987
  $status = false;
988
+ if (in_array($id, $products_to_apply)) {
989
  $status = true;
990
  }
991
  }
1074
  $max = isset($value->max_qty) ? $value->max_qty : 0;
1075
  $discount_type = isset($value->discount_type) ? $value->discount_type : 0;
1076
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
1077
+ $product_discount = isset($value->discount_product) ? $value->discount_product : array();
1078
  $html .= '<tr>';
1079
  if (isset($base_config['show_discount_title_table'])) {
1080
  if ($base_config['show_discount_title_table'] == 'show') {
1082
  }
1083
  }
1084
  $html .= '<td>'.$min .' - ' . $max.'</td>';
1085
+ if ($discount_type == 'product_discount') {
1086
+ $html .= '<td>';
1087
+ if(count($product_discount)){
1088
+ foreach ($product_discount as $product_id){
1089
+ $product = wc_get_product( $product_id );
1090
+ $html .= $product->get_title();
1091
+ $html .= ' ('.$product->get_price_html().')';
1092
+ }
1093
+ }
1094
+ $html .= '</td>';
1095
+ } else if ($discount_type == 'percentage_discount') {
1096
  $html .= '<td>'.$to_discount . ' %'.'</td>';
1097
  } else {
1098
  $html .= '<td>'.wc_price($to_discount) . ' %'.'</td>';
readme.txt CHANGED
@@ -4,14 +4,14 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.8.1
7
- Stable tag: 1.4.18
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, promotions for your WooCommerce online store.
12
  == Description ==
13
 
14
- WooCommerce discount rules helps you to create any type of discount and pricing rules in your WooCommerce store. Increase your sales multifold by offering flexible, customised discounts to your customers. Encourage your customers to purchase more by providing bulk discounts.
15
 
16
  [View Demo](http://demo.flycart.org/woo-discount-rules) | [Documentation with real examples](https://www.flycart.org/docs/wordpress/woo-discount-rules) | [Ask Questions](https://www.flycart.org/support/6-wordpress-plugins)
17
 
@@ -19,6 +19,8 @@ WooCommerce discount rules helps you to create any type of discount and pricing
19
 
20
  * Buy 5 items and get 10 % discount
21
  * Buy T-shirts from Winter Collections and save 10 %
 
 
22
  * 20 % discount on all items in the store till December 25
23
  * Buy 10 mugs are more and get 5% off
24
  * All orders above $500 will get 15% discount
@@ -107,6 +109,9 @@ More information could be found in the documentation
107
 
108
  == Changelog ==
109
 
 
 
 
110
  = 1.4.18 - 12/09/17 =
111
  * Fix – OWl Carousel compatibility issue
112
 
4
  Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.8.1
7
+ Stable tag: 1.4.19
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, promotions for your WooCommerce online store.
12
  == Description ==
13
 
14
+ WooCommerce discount rules helps you to create any type of discount and pricing rules in your WooCommerce store. Increase your sales multifold by offering flexible, customised discounts and free products to your customers. Encourage your customers to purchase more by providing bulk discounts.
15
 
16
  [View Demo](http://demo.flycart.org/woo-discount-rules) | [Documentation with real examples](https://www.flycart.org/docs/wordpress/woo-discount-rules) | [Ask Questions](https://www.flycart.org/support/6-wordpress-plugins)
17
 
19
 
20
  * Buy 5 items and get 10 % discount
21
  * Buy T-shirts from Winter Collections and save 10 %
22
+ * Buy 2 products get 1 free of the same product
23
+ * Buy 3 products get another product free
24
  * 20 % discount on all items in the store till December 25
25
  * Buy 10 mugs are more and get 5% off
26
  * All orders above $500 will get 15% discount
109
 
110
  == Changelog ==
111
 
112
+ = 1.4.19 - 04/10/17 =
113
+ * Feature – Buy one/more and get one/more free product for pro version
114
+
115
  = 1.4.18 - 12/09/17 =
116
  * Fix – OWl Carousel compatibility issue
117
 
view/view-pricing-rules.php CHANGED
@@ -264,7 +264,7 @@ $rule_id = (isset($data->ID)) ? $data->ID : 0;
264
  value="<?php echo(isset($discount->max_qty) ? $discount->max_qty : ''); ?>"
265
  placeholder="ex. 50"> </label>
266
  <label>Adjustment Type
267
- <select class="form-control"
268
  name="discount_range[<?php echo $fieldIndex; ?>][discount_type]">
269
  <?php $opt = (isset($discount->discount_type) ? $discount->discount_type : ''); ?>
270
  <option
@@ -282,13 +282,35 @@ $rule_id = (isset($data->ID)) ? $data->ID : 0;
282
  Price Discount
283
  <?php } ?>
284
  </option>
 
 
 
 
 
 
 
 
 
 
285
  </select></label>
286
  <label>Value
287
  <input type="text"
288
  name="discount_range[<?php echo $fieldIndex; ?>][to_discount]"
289
- class="form-control"
290
  value="<?php echo(isset($discount->to_discount) ? $discount->to_discount : ''); ?>"
291
- placeholder="ex. 50"> </label>
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
  <label>Action <a href=javascript:void(0)
294
  class="button button-secondary form-control remove_discount_range">Remove</a></label>
264
  value="<?php echo(isset($discount->max_qty) ? $discount->max_qty : ''); ?>"
265
  placeholder="ex. 50"> </label>
266
  <label>Adjustment Type
267
+ <select class="form-control price_discount_type"
268
  name="discount_range[<?php echo $fieldIndex; ?>][discount_type]">
269
  <?php $opt = (isset($discount->discount_type) ? $discount->discount_type : ''); ?>
270
  <option
282
  Price Discount
283
  <?php } ?>
284
  </option>
285
+ <option
286
+ <?php if (!$pro) { ?> disabled <?php } else { ?> value="product_discount" <?php
287
+ }
288
+ if ($opt == 'product_discount') { ?> selected=selected <?php } ?>>
289
+ <?php if (!$pro) { ?>
290
+ Product Discount <b><?php echo $suffix; ?></b>
291
+ <?php } else { ?>
292
+ Product Discount
293
+ <?php } ?>
294
+ </option>
295
  </select></label>
296
  <label>Value
297
  <input type="text"
298
  name="discount_range[<?php echo $fieldIndex; ?>][to_discount]"
299
+ class="form-control price_discount_amount"
300
  value="<?php echo(isset($discount->to_discount) ? $discount->to_discount : ''); ?>"
301
+ placeholder="ex. 50">
302
+ <?php
303
+ $products_list = (isset($discount->discount_product) ? $discount->discount_product : array()); ?>
304
+ <div class="price_discount_product_list_con hide">
305
+ <select class="product_list selectpicker price_discount_product_list" multiple
306
+ name="discount_range[<?php echo $fieldIndex; ?>][discount_product][]">
307
+ <?php foreach ($products as $index => $value) { ?>
308
+ <option
309
+ value="<?php echo $index; ?>" <?php if (in_array($index, $products_list)) { ?> selected=selected <?php } ?>><?php echo $value; ?></option>
310
+ <?php } ?>
311
+ </select>
312
+ </div>
313
+ </label>
314
 
315
  <label>Action <a href=javascript:void(0)
316
  class="button button-secondary form-control remove_discount_range">Remove</a></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.18
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 1.4.19
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1