Discount Rules for WooCommerce - Version 1.5.11

Version Description

  • 02/05/18 =
  • Improvement - Multiple strikeout price of an item in cart based on quantity for BOGO price rule
  • Improvement - UI improvement
  • Fix - Cheapest product discount not worked for variants
Download this release

Release Info

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

Code changes from version 1.5.10 to 1.5.11

assets/css/style.css CHANGED
@@ -56,8 +56,9 @@
56
  .product_based_condition_get_product_discount{
57
  margin: 15px 0;
58
  }
59
- #product_list span.select2-container{
60
- min-width: 250px;
 
61
  width: auto !important;
62
  }
63
  .coupons_to_apply_price_rule_con{
@@ -69,4 +70,16 @@
69
  }
70
  .coupons_to_apply{
71
  max-width: 250px;
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
56
  .product_based_condition_get_product_discount{
57
  margin: 15px 0;
58
  }
59
+ #product_list span.select2-container,
60
+ #product_exclude_list span.select2-container{
61
+ min-width: 250px ;
62
  width: auto !important;
63
  }
64
  .coupons_to_apply_price_rule_con{
70
  }
71
  .coupons_to_apply{
72
  max-width: 250px;
73
+ }
74
+ .discount_product_option {
75
+ min-width: 350px;
76
+ }
77
+ .discount_rule_list input{
78
+ width: 95px;
79
+ }
80
+ .bootstrap-select > select.discount_product_option{
81
+ z-index: -1;
82
+ }
83
+ .discount_product_percent_con, .price_discount_product_list_con{
84
+ margin: 10px 0;
85
  }
assets/js/app.js CHANGED
@@ -18,8 +18,20 @@ function validateFields(){
18
  })(jQuery);
19
  return returnValue;
20
  }
 
 
 
 
 
 
 
 
 
21
  (function ($) {
22
  jQuery(document).ready(function () {
 
 
 
23
  var ajax_url = $('#ajax_path').val();
24
  var admin_url = $('#admin_path').val();
25
  var pro_suffix = $('#pro_suffix').val();
@@ -49,12 +61,9 @@ function validateFields(){
49
  var current = $(this);
50
  var rule_id = $('#rule_id').val();
51
  event.preventDefault();
52
- console.log($('#rule_name').val());
53
  if ($('#rule_name').val() == '') {
54
  alert('Please Enter the Rule Name to Create / Save.');
55
  } else {
56
- current.removeClass('button-primary');
57
- current.addClass('button-secondary');
58
  current.val('Saving...');
59
  $.ajax({
60
  url: ajax_url,
@@ -62,10 +71,7 @@ function validateFields(){
62
  data: {action: 'savePriceRule', data: form},
63
  success: function () {
64
  // After Status Changed.
65
-
66
  resizeChart = setTimeout(function () {
67
- current.addClass('button-primary');
68
- current.removeClass('button-secondary');
69
  current.val('Save Rule');
70
  }, 300);
71
  console.log(rule_id);
@@ -139,28 +145,28 @@ function validateFields(){
139
  if (is_pro) {
140
  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>' +
141
  '<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]"> ' +
142
- '<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 ' +
143
  '<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
144
  form += '<div class="price_discount_product_list_con hide">' +
145
  ' Apply for <select class="selectpicker discount_product_option" name="discount_range['+count+'][discount_product_option]"><option value="all">All selected</option><option value="any_cheapest">Any one cheapest from selected</option><option value="any_cheapest_from_all">Any one cheapest from all products</option>' +
146
  '<option value="more_than_one_cheapest_from_cat">More than one cheapest from selected category</option><option value="more_than_one_cheapest">More than one cheapest from selected</option><option value="more_than_one_cheapest_from_all">More than one cheapest from all</option>' +
147
  '</select>';
148
  form += '<div class="discount_product_option_bogo_con">';
149
- form += '<label>Free quantity<input type="text" name="discount_range['+count+'][discount_bogo_qty]" class="form-control" value="" placeholder="ex. 1" /></label>';
150
  form += '</div>';
151
  form += '<div class="discount_product_option_more_cheapest_con hide">';
152
- form += '<label>Item count<input type="text" name="discount_range['+count+'][discount_product_items]" class="form-control" value="" placeholder="ex. 1" /></label>';
153
- form += '<label>Item quantity<input type="text" name="discount_range['+count+'][discount_product_qty]" class="form-control" value="" placeholder="ex. 1" /></label>';
154
  form += '</div>';
155
  form += '<div class="discount_product_option_list_con">';
156
  if($('#flycart_wdr_woocommerce_version').val() == 2){
157
- form += '<input type="hidden" class="wc-product-search" style="min-width: 250px" data-multiple="true" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product&hellip;" data-action="woocommerce_json_search_products_and_variations" data-selected=""/>';
158
  } else {
159
- form += '<select class="wc-product-search" multiple="multiple" style="min-width: 250px" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product&hellip;" data-action="woocommerce_json_search_products_and_variations"></select>'
160
  }
161
  form += '</div>';
162
  form += '<div class="discount_category_option_list_con hide">';
163
- form += '<select class="category_list selectpicker" multiple name="discount_range[' + count + '][discount_category][]">';
164
  $("#category_list select.category_list option").each(function()
165
  {
166
  form += '<option value="'+$(this).val()+'">'+$(this).html()+'</option>';
@@ -169,10 +175,10 @@ function validateFields(){
169
  form += '</div>';
170
  form += '<div class="discount_product_percent_con">';
171
  form += ' and <select class="selectpicker discount_product_discount_type" name="discount_range['+ count +'][discount_product_discount_type]"><option value="">100% percent</option><option value="limited_percent">Limited percent</option></select>';
172
- form += '<label class="discount_product_percent_field"> Percent <input type="text" name="discount_range['+count+'][discount_product_percent]" class="form-control discount_product_percent_field" value="" placeholder="ex. 10" /></label>';
173
  form += '</div>';
174
  form += '</div>';
175
- form += '</label> <label>Action<a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </label></div> </div>';
176
  } else {
177
  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>' +
178
  '<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]"> ' +
@@ -181,12 +187,14 @@ function validateFields(){
181
  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][]">';
182
  form += '<option>none</option>';
183
  form += '</select></div>';
184
- form += '</label> <label>Action<a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </label></div> </div>';
185
  }
186
  $('#discount_rule_list').append(form);
187
  $('.product_list,.selectpicker').selectpicker('refresh');
188
  $('.wc-product-search').trigger( 'wc-enhanced-select-init' );
189
  $('select.discount_product_discount_type').trigger('change');
 
 
190
  });
191
 
192
  // Removing Discount Rule.
@@ -313,7 +321,6 @@ function validateFields(){
313
  $('#rule_label_' + id).html(value);
314
  });
315
 
316
-
317
  //--------------------------------------------------------------------------------------------------------------
318
  //-----------------------------------------------CART RULES-----------------------------------------------------
319
  //--------------------------------------------------------------------------------------------------------------
@@ -356,7 +363,7 @@ function validateFields(){
356
  '<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
357
  '<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
358
  '<div id="purchase_history_div_' + count + '">Total purchased amount at least <input name="discount_rule[' + count + '][purchased_history_amount]" value="" type="text"/> In Order status <select id="order_status_list_' + count + '" class="order_status_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][purchase_history_order_status][]"></select></div>' +
359
- '</div><div class="col-md-1"> <label> Action</label> <br> <a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a> </div>' +
360
  '</label></div>';
361
  } else {
362
  var form = '<div class="cart_rules_list row"> <div class="col-md-3 form-group"> <label>Type <select class="form-control cart_rule_type" id="cart_condition_type_' + count + '" name="discount_rule[' + count + '][type]"> <optgroup label="Cart Subtotal"><option value="subtotal_least" selected="selected">Subtotal at least</option><option value="subtotal_less">Subtotal less than</option></optgroup>' +
@@ -379,7 +386,7 @@ function validateFields(){
379
  '<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
380
  '<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
381
  '<div id="purchase_history_div_' + count + '"><select id="order_status_list_' + count + '" class="order_status_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][purchase_history_order_status][]"></select></div>' +
382
- '</div><div class="col-md-1"> <label> Action </label><br><a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a> </div>' +
383
  '</label></div>';
384
  }
385
 
@@ -439,12 +446,12 @@ function validateFields(){
439
  discount_amount.hide();
440
  price_discount_amount.removeClass('hide').show();
441
  discount_product_percent_con.removeClass('hide').show();
442
- $('.hide-for-product-discount').hide();
443
  } else {
444
  discount_amount.show();
445
  price_discount_amount.hide();
446
  discount_product_percent_con.hide();
447
- $('.hide-for-product-discount').show();
448
  }
449
  });
450
  $('.price_discount_type').trigger('change');
@@ -500,8 +507,6 @@ function validateFields(){
500
  if ($('#rule_name').val() == '') {
501
  alert('Please Enter the Rule Name to Create / Save.');
502
  } else {
503
- current.removeClass('button-primary');
504
- current.addClass('button-secondary');
505
  current.val('Saving...');
506
  $.ajax({
507
  url: ajax_url,
@@ -511,8 +516,6 @@ function validateFields(){
511
  // After Status Changed.
512
 
513
  resizeChart = setTimeout(function () {
514
- current.addClass('button-primary');
515
- current.removeClass('button-secondary');
516
  current.val('Save Rule');
517
  }, 300);
518
 
18
  })(jQuery);
19
  return returnValue;
20
  }
21
+
22
+ function trigger_woocommerce_tooltip(){
23
+ jQuery( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( {
24
+ 'attribute': 'data-tip',
25
+ 'fadeIn': 50,
26
+ 'fadeOut': 50,
27
+ 'delay': 200
28
+ } );
29
+ }
30
  (function ($) {
31
  jQuery(document).ready(function () {
32
+ // Tooltips
33
+ trigger_woocommerce_tooltip();
34
+
35
  var ajax_url = $('#ajax_path').val();
36
  var admin_url = $('#admin_path').val();
37
  var pro_suffix = $('#pro_suffix').val();
61
  var current = $(this);
62
  var rule_id = $('#rule_id').val();
63
  event.preventDefault();
 
64
  if ($('#rule_name').val() == '') {
65
  alert('Please Enter the Rule Name to Create / Save.');
66
  } else {
 
 
67
  current.val('Saving...');
68
  $.ajax({
69
  url: ajax_url,
71
  data: {action: 'savePriceRule', data: form},
72
  success: function () {
73
  // After Status Changed.
 
74
  resizeChart = setTimeout(function () {
 
 
75
  current.val('Save Rule');
76
  }, 300);
77
  console.log(rule_id);
145
  if (is_pro) {
146
  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>' +
147
  '<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]"> ' +
148
+ '<option value="percentage_discount"> Percentage Discount </option> <option value="price_discount">Price Discount </option> <option value="product_discount">Product Discount </option> </select></label> <label><span class="hide-for-product-discount">Value</span>' +
149
  '<input type="text" name="discount_range[' + count + '][to_discount]" class="form-control price_discount_amount" value="" placeholder="ex. 50"> ';
150
  form += '<div class="price_discount_product_list_con hide">' +
151
  ' Apply for <select class="selectpicker discount_product_option" name="discount_range['+count+'][discount_product_option]"><option value="all">All selected</option><option value="any_cheapest">Any one cheapest from selected</option><option value="any_cheapest_from_all">Any one cheapest from all products</option>' +
152
  '<option value="more_than_one_cheapest_from_cat">More than one cheapest from selected category</option><option value="more_than_one_cheapest">More than one cheapest from selected</option><option value="more_than_one_cheapest_from_all">More than one cheapest from all</option>' +
153
  '</select>';
154
  form += '<div class="discount_product_option_bogo_con">';
155
+ form += ' <label> Free quantity <span class="woocommerce-help-tip" data-tip="Number of quantity(ies) in each selected product(s)"></span> <input type="text" name="discount_range['+count+'][discount_bogo_qty]" class="form-control" value="" placeholder="ex. 1" /></label>';
156
  form += '</div>';
157
  form += '<div class="discount_product_option_more_cheapest_con hide">';
158
+ form += ' <label> Item count <span class="woocommerce-help-tip" data-tip="Discount for number of item(s) in cart"></span><input type="text" name="discount_range['+count+'][discount_product_items]" class="form-control" value="" placeholder="ex. 1" /></label>';
159
+ form += ' <label> Item quantity <span class="woocommerce-help-tip" data-tip="Discount for number of quantity(ies) in each item"></span><input type="text" name="discount_range['+count+'][discount_product_qty]" class="form-control" value="" placeholder="ex. 1" /></label>';
160
  form += '</div>';
161
  form += '<div class="discount_product_option_list_con">';
162
  if($('#flycart_wdr_woocommerce_version').val() == 2){
163
+ form += ' <input type="hidden" class="wc-product-search" style="min-width: 250px" data-multiple="true" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product&hellip;" data-action="woocommerce_json_search_products_and_variations" data-selected=""/>';
164
  } else {
165
+ form += ' <select class="wc-product-search" multiple="multiple" style="min-width: 250px" name="discount_range[' + count + '][discount_product][]" data-placeholder="Search for a product&hellip;" data-action="woocommerce_json_search_products_and_variations"></select>'
166
  }
167
  form += '</div>';
168
  form += '<div class="discount_category_option_list_con hide">';
169
+ form += ' <select class="category_list selectpicker" multiple name="discount_range[' + count + '][discount_category][]">';
170
  $("#category_list select.category_list option").each(function()
171
  {
172
  form += '<option value="'+$(this).val()+'">'+$(this).html()+'</option>';
175
  form += '</div>';
176
  form += '<div class="discount_product_percent_con">';
177
  form += ' and <select class="selectpicker discount_product_discount_type" name="discount_range['+ count +'][discount_product_discount_type]"><option value="">100% percent</option><option value="limited_percent">Limited percent</option></select>';
178
+ form += '<span class="discount_product_percent_field"> <input type="text" name="discount_range['+count+'][discount_product_percent]" class="discount_product_percent_field" value="" placeholder="ex. 10" /><span class="woocommerce-help-tip" data-tip="Percentage"></span></span> as discount';
179
  form += '</div>';
180
  form += '</div>';
181
+ form += '</label> <label><a href=javascript:void(0) class="btn btn-danger form-control remove_discount_range">Remove</a></label> </div> </div>';
182
  } else {
183
  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>' +
184
  '<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]"> ' +
187
  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][]">';
188
  form += '<option>none</option>';
189
  form += '</select></div>';
190
+ form += '</label> <label><a href=javascript:void(0) class="btn btn-danger form-control remove_discount_range">Remove</a> </label></div> </div>';
191
  }
192
  $('#discount_rule_list').append(form);
193
  $('.product_list,.selectpicker').selectpicker('refresh');
194
  $('.wc-product-search').trigger( 'wc-enhanced-select-init' );
195
  $('select.discount_product_discount_type').trigger('change');
196
+ // Tooltips
197
+ trigger_woocommerce_tooltip();
198
  });
199
 
200
  // Removing Discount Rule.
321
  $('#rule_label_' + id).html(value);
322
  });
323
 
 
324
  //--------------------------------------------------------------------------------------------------------------
325
  //-----------------------------------------------CART RULES-----------------------------------------------------
326
  //--------------------------------------------------------------------------------------------------------------
363
  '<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
364
  '<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
365
  '<div id="purchase_history_div_' + count + '">Total purchased amount at least <input name="discount_rule[' + count + '][purchased_history_amount]" value="" type="text"/> In Order status <select id="order_status_list_' + count + '" class="order_status_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][purchase_history_order_status][]"></select></div>' +
366
+ '</div><div class="col-md-1"> <label> Action</label> <br> <a href=javascript:void(0) class="btn btn-danger remove_cart_rule">Remove</a> </div>' +
367
  '</label></div>';
368
  } else {
369
  var form = '<div class="cart_rules_list row"> <div class="col-md-3 form-group"> <label>Type <select class="form-control cart_rule_type" id="cart_condition_type_' + count + '" name="discount_rule[' + count + '][type]"> <optgroup label="Cart Subtotal"><option value="subtotal_least" selected="selected">Subtotal at least</option><option value="subtotal_less">Subtotal less than</option></optgroup>' +
386
  '<div id="roles_div_' + count + '"><select id="cart_roles_list_' + count + '" class="roles_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][user_roles_to_apply][]"></select></div>' +
387
  '<div id="countries_div_' + count + '"><select id="cart_countries_list_' + count + '" class="country_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][countries_to_apply][]"></select></div>' +
388
  '<div id="purchase_history_div_' + count + '"><select id="order_status_list_' + count + '" class="order_status_list selectpicker" data-live-search="true" multiple name="discount_rule[' + count + '][purchase_history_order_status][]"></select></div>' +
389
+ '</div><div class="col-md-1"> <label> Action </label><br><a href=javascript:void(0) class="btn btn-danger remove_cart_rule">Remove</a> </div>' +
390
  '</label></div>';
391
  }
392
 
446
  discount_amount.hide();
447
  price_discount_amount.removeClass('hide').show();
448
  discount_product_percent_con.removeClass('hide').show();
449
+ $(this).closest('.discount_rule_list').find('.hide-for-product-discount').hide();
450
  } else {
451
  discount_amount.show();
452
  price_discount_amount.hide();
453
  discount_product_percent_con.hide();
454
+ $(this).closest('.discount_rule_list').find('.hide-for-product-discount').show();
455
  }
456
  });
457
  $('.price_discount_type').trigger('change');
507
  if ($('#rule_name').val() == '') {
508
  alert('Please Enter the Rule Name to Create / Save.');
509
  } else {
 
 
510
  current.val('Saving...');
511
  $.ajax({
512
  url: ajax_url,
516
  // After Status Changed.
517
 
518
  resizeChart = setTimeout(function () {
 
 
519
  current.val('Save Rule');
520
  }, 300);
521
 
includes/discount-base.php CHANGED
@@ -672,6 +672,7 @@ if (!class_exists('FlycartWooDiscountBase')) {
672
  wp_enqueue_script('jquery');
673
  wp_enqueue_script('jquery-ui-core');
674
  wp_enqueue_script('jquery-ui-datepicker');
 
675
 
676
  wp_enqueue_script('woo_discount_script', WOO_DISCOUNT_URI . '/assets/js/app.js', array(), WOO_DISCOUNT_VERSION);
677
 
672
  wp_enqueue_script('jquery');
673
  wp_enqueue_script('jquery-ui-core');
674
  wp_enqueue_script('jquery-ui-datepicker');
675
+ wp_enqueue_script( 'woocommerce_admin' );
676
 
677
  wp_enqueue_script('woo_discount_script', WOO_DISCOUNT_URI . '/assets/js/app.js', array(), WOO_DISCOUNT_VERSION);
678
 
includes/pricing-rules.php CHANGED
@@ -945,7 +945,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
945
 
946
  case 'specific_products':
947
  if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
948
- $discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
949
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
950
  }
951
  break;
@@ -977,7 +977,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
977
  }
978
  }
979
  if(!$alreadyExists){
980
- $discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
981
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
982
  }
983
  }
@@ -990,7 +990,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
990
  $totalQuantityFromAllProducts = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
991
  $quantity = $totalQuantityFromAllProducts;
992
  }
993
- $discount_amount = $this->getAdjustmentAmount($quantity, $this->array_first($rule['discount']), $product_page, $bogo);
994
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
995
  }
996
 
@@ -1018,7 +1018,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1018
  $checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
1019
  if(!empty($checkRuleMatches)){
1020
  if(class_exists('FlycartWooDiscountRulesPriceProductDependent'))
1021
- $discountInEachProducts = FlycartWooDiscountRulesPriceProductDependent::getDiscountInEachProducts($rule, $checkRuleMatches, $product_page, $index);
1022
  foreach ($checkRuleMatches['apply_to']['products'] as $key => $productId) {
1023
  if($product_page && $productId == $index){
1024
  $additionalKeys = array('apply_from' => $item['product_id']);
@@ -1212,7 +1212,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1212
  * @param $product_page
1213
  * @return array|bool
1214
  */
1215
- public function getAdjustmentAmount($quantity, $discount_ranges, $product_page, $bogo)
1216
  {
1217
  $adjustment = array();
1218
  foreach($discount_ranges as $discount_range) {
@@ -1279,6 +1279,19 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1279
  }
1280
  } else {
1281
  $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
1282
  }
1283
  }
1284
  }
@@ -1307,11 +1320,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1307
  $adjustment['product_ids'][] = $productCheapest['product'];
1308
  $adjustmentValues[$productCheapest['product']] = $productCheapest['percent'];
1309
  $adjustment['product_discount_adjustment'] = $adjustmentValues;
 
1310
  } else {
1311
  break;
1312
  }
1313
  }
1314
-
1315
  return $adjustment;
1316
  }
1317
 
@@ -1322,7 +1335,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1322
  $products = array();
1323
  $cart = FlycartWoocommerceCart::get_cart();
1324
  foreach ( $cart as $cart_item ) {
1325
- $products[] = $cart_item['product_id'];
 
 
 
1326
  }
1327
  return $products;
1328
  }
@@ -1373,10 +1389,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1373
  $quantity = $values['quantity'];
1374
  }
1375
  }
 
 
 
 
 
1376
  if($cheapestProductValue > 0){
1377
  if(isset($range->discount_product_discount_type) && $range->discount_product_discount_type == "limited_percent"){
1378
- if(isset($range->discount_product_percent) && $range->discount_product_percent > 0)
1379
  $cheapestProductValue = $cheapestProductValue * ($range->discount_product_percent / 100);
 
 
1380
  }
1381
 
1382
  //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
@@ -1384,7 +1407,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1384
  $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$quantity));
1385
  else
1386
  $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$discount_quantity));
1387
- return array('product' => $cheapestProduct, 'percent' => $discount_price);
1388
  }
1389
  return array();
1390
  }
@@ -2006,7 +2029,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2006
  // If Product having the rule sets then,
2007
  if (!isset($this->matched_sets[$cart_item_key])) return false;
2008
  if (empty($this->matched_sets[$cart_item_key])) return false;
2009
-
2010
  $adjustment_set = $this->matched_sets[$cart_item_key];
2011
  $product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
2012
  $product_id = FlycartWoocommerceProduct::get_id($product);
@@ -2014,25 +2037,37 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2014
 
2015
  //To reset the adjustment set if the Product discount adjustment exists
2016
  $adjustment_set = $this->resetTheDiscountIfProductDiscountAdjustmentExists($adjustment_set, $product_id);
2017
-
2018
  if ($type == 'first') {
2019
  // For Apply the First Rule.
2020
  $discount = $this->getAmount($adjustment_set, $price, 'first');
 
 
 
 
2021
  $amount = $price - $discount;
2022
  $log = 'Discount | ' . $discount;
2023
- $this->applyDiscount($cart_item_key, $amount, $log);
2024
  } else if ($type == 'biggest') {
2025
  // For Apply the Biggest Discount.
2026
  $discount = $this->getAmount($adjustment_set, $price, 'biggest');
 
 
 
 
2027
  $amount = $price - $discount;
2028
  $log = 'Discount | ' . $discount;
2029
- $this->applyDiscount($cart_item_key, $amount, $log);
2030
  } else {
2031
  // For Apply All Rules.
2032
  $discount = $this->getAmount($adjustment_set, $price);
 
 
 
 
2033
  $amount = $price - $discount;
2034
  $log = 'Discount | ' . $discount;
2035
- $this->applyDiscount($cart_item_key, $amount, $log);
2036
  }
2037
  }
2038
 
@@ -2047,6 +2082,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2047
  $adjustment_sets[$key]['amount']['product_ids'] = array($product_id);
2048
  }
2049
  }
 
 
 
 
 
2050
  }
2051
 
2052
  return $adjustment_sets;
@@ -2074,7 +2114,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2074
  $discount = $this->getBiggestDiscount($sets, $price, $product_page, $product);
2075
  return $discount;
2076
  }
2077
-
2078
  foreach ($sets as $id => $set) {
2079
  // For the First price, it will return the amount after get hit.
2080
  if ($by == 'first') {
@@ -2090,7 +2130,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2090
  }
2091
  }
2092
  }
2093
- return $discount;
 
2094
  } else {
2095
  // For All, All rules going to apply.
2096
  if (isset($set['amount']['percentage_discount'])) {
@@ -2109,9 +2150,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2109
  // Append all Discounts.
2110
  $overall_discount = $overall_discount + $discount;
2111
  }
 
2112
  }
2113
  }
2114
- return $overall_discount;
 
2115
  }
2116
 
2117
  /**
@@ -2124,6 +2167,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2124
  public function getBiggestDiscount($discount_list, $price, $product_page = 0, $product = array())
2125
  {
2126
  $big = $amount = 0;
 
2127
  foreach ($discount_list as $id => $discount_item) {
2128
  $amount_type = (isset($discount_item['amount']['percentage_discount']) ? 'percentage_discount' : 'price_discount');
2129
  if ($amount_type == 'percentage_discount') {
@@ -2145,9 +2189,12 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2145
 
2146
  if ($big < $amount) {
2147
  $big = $amount;
 
2148
  }
2149
  }
2150
- return $big;
 
 
2151
  }
2152
 
2153
  /**
@@ -2157,7 +2204,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2157
  * @param $amount
2158
  * @param $log
2159
  */
2160
- public function applyDiscount($item, $amount, $log)
2161
  {
2162
  global $woocommerce;
2163
  // Make sure item exists in cart
@@ -2169,6 +2216,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2169
  $woocommerce->cart->cart_contents[$item]['woo_discount'] = array(
2170
  'original_price' => get_option('woocommerce_tax_display_cart') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product) : FlycartWoocommerceProduct::get_price_including_tax($product),
2171
  'log' => $log,
 
2172
  );
2173
 
2174
  // To handle Woocommerce currency switcher
@@ -2185,6 +2233,17 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2185
  FlycartWoocommerceProduct::set_price($product, $amount);
2186
  }
2187
 
 
 
 
 
 
 
 
 
 
 
 
2188
  /**
2189
  * For Show the Actual Discount of a product.
2190
  *
@@ -2208,8 +2267,60 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2208
  $price_to_display = FlycartWoocommerceProduct::wc_price($price);
2209
  $original_price_to_display = FlycartWoocommerceProduct::wc_price($cart_item['woo_discount']['original_price']);
2210
 
2211
- if ($cart_item['woo_discount']['original_price'] != $price) {
2212
- $item_price = '<span class="cart_price"><del>' . $original_price_to_display . '</del> <ins>' . $price_to_display . '</ins></span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2213
  } else {
2214
  $item_price = $price_to_display;
2215
  }
@@ -2395,13 +2506,25 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
2395
  if ($type == 'first') {
2396
  // For Apply the First Rule.
2397
  $discount = $this->getAmount($adjustment_set, $price, 'first', 1, $cart_item);
 
 
 
 
2398
 
2399
  } else if ($type == 'biggest') {
2400
  // For Apply the Biggest Discount.
2401
  $discount = $this->getAmount($adjustment_set, $price, 'biggest', 1, $cart_item);
 
 
 
 
2402
  } else {
2403
  // For Apply All Rules.
2404
  $discount = $this->getAmount($adjustment_set, $price, 'all', 1, $cart_item);
 
 
 
 
2405
  }
2406
  if($discount > 0){
2407
  $amount = $price - $discount;
945
 
946
  case 'specific_products':
947
  if ($this->isItemInProductList($rule['type']['specific_products'], $item)) {
948
+ $discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
949
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
950
  }
951
  break;
977
  }
978
  }
979
  if(!$alreadyExists){
980
+ $discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
981
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
982
  }
983
  }
990
  $totalQuantityFromAllProducts = $this->getProductQuantityForCumulativeProducts($item, $product_page, $rule);
991
  $quantity = $totalQuantityFromAllProducts;
992
  }
993
+ $discount_amount = $this->getAdjustmentAmount($item, $quantity, $this->array_first($rule['discount']), $product_page, $bogo);
994
  $applied_rules[$i] = $this->formatRulesToApply($discount_amount, $rule['name'], $index, $item['product_id'], $id);
995
  }
996
 
1018
  $checkRuleMatches = $this->checkProductBasedRuleMatches($rule, $item, $quantity);
1019
  if(!empty($checkRuleMatches)){
1020
  if(class_exists('FlycartWooDiscountRulesPriceProductDependent'))
1021
+ $discountInEachProducts = FlycartWooDiscountRulesPriceProductDependent::getDiscountInEachProducts($item, $rule, $checkRuleMatches, $product_page, $index);
1022
  foreach ($checkRuleMatches['apply_to']['products'] as $key => $productId) {
1023
  if($product_page && $productId == $index){
1024
  $additionalKeys = array('apply_from' => $item['product_id']);
1212
  * @param $product_page
1213
  * @return array|bool
1214
  */
1215
+ public function getAdjustmentAmount($item, $quantity, $discount_ranges, $product_page, $bogo)
1216
  {
1217
  $adjustment = array();
1218
  foreach($discount_ranges as $discount_range) {
1279
  }
1280
  } else {
1281
  $adjustment[$type] = (isset($range->to_discount) ? $range->to_discount : 0);
1282
+ $product_discount_details = array();
1283
+ if($type == 'percentage_discount'){
1284
+ $product_discount_details['discount_type'] = 'percent';
1285
+ $productPrice = FlycartWoocommerceProduct::get_price($item['data']);
1286
+ $discount_price = $productPrice * ($range->to_discount / 100);
1287
+ } else {
1288
+ $product_discount_details['discount_type'] = 'price_discount';
1289
+ $discount_price = $range->to_discount;
1290
+ }
1291
+ $product_discount_details['discount_value'] = $range->to_discount;
1292
+ $product_discount_details['discount_quantity'] = $quantity;
1293
+ $product_discount_details['discount_price'] = $discount_price;
1294
+ $adjustment['product_discount_details'] = $product_discount_details;
1295
  }
1296
  }
1297
  }
1320
  $adjustment['product_ids'][] = $productCheapest['product'];
1321
  $adjustmentValues[$productCheapest['product']] = $productCheapest['percent'];
1322
  $adjustment['product_discount_adjustment'] = $adjustmentValues;
1323
+ $adjustment['product_discount_details'][$productCheapest['product']] = $productCheapest['discount_details'];
1324
  } else {
1325
  break;
1326
  }
1327
  }
 
1328
  return $adjustment;
1329
  }
1330
 
1335
  $products = array();
1336
  $cart = FlycartWoocommerceCart::get_cart();
1337
  foreach ( $cart as $cart_item ) {
1338
+ if($cart_item['variation_id'] && $cart_item['variation_id'])
1339
+ $products[] = $cart_item['variation_id'];
1340
+ else
1341
+ $products[] = $cart_item['product_id'];
1342
  }
1343
  return $products;
1344
  }
1389
  $quantity = $values['quantity'];
1390
  }
1391
  }
1392
+ $product_discount_details = array();
1393
+ $product_discount_details['discount_type'] = 'percent';
1394
+ $product_discount_details['discount_value'] = 100;
1395
+ $product_discount_details['discount_quantity'] = $discount_quantity;
1396
+ $product_discount_details['discount_price'] = $cheapestProductValue;
1397
  if($cheapestProductValue > 0){
1398
  if(isset($range->discount_product_discount_type) && $range->discount_product_discount_type == "limited_percent"){
1399
+ if(isset($range->discount_product_percent) && $range->discount_product_percent > 0){
1400
  $cheapestProductValue = $cheapestProductValue * ($range->discount_product_percent / 100);
1401
+ }
1402
+ $product_discount_details['discount_price'] = $cheapestProductValue;
1403
  }
1404
 
1405
  //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
1407
  $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$quantity));
1408
  else
1409
  $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$discount_quantity));
1410
+ return array('product' => $cheapestProduct, 'percent' => $discount_price, 'discount_details' => $product_discount_details);
1411
  }
1412
  return array();
1413
  }
2029
  // If Product having the rule sets then,
2030
  if (!isset($this->matched_sets[$cart_item_key])) return false;
2031
  if (empty($this->matched_sets[$cart_item_key])) return false;
2032
+
2033
  $adjustment_set = $this->matched_sets[$cart_item_key];
2034
  $product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
2035
  $product_id = FlycartWoocommerceProduct::get_id($product);
2037
 
2038
  //To reset the adjustment set if the Product discount adjustment exists
2039
  $adjustment_set = $this->resetTheDiscountIfProductDiscountAdjustmentExists($adjustment_set, $product_id);
2040
+ $additionalDetails = array();
2041
  if ($type == 'first') {
2042
  // For Apply the First Rule.
2043
  $discount = $this->getAmount($adjustment_set, $price, 'first');
2044
+ if(is_array($discount)){
2045
+ $additionalDetails = $discount['details'];
2046
+ $discount = $discount['amount'];
2047
+ }
2048
  $amount = $price - $discount;
2049
  $log = 'Discount | ' . $discount;
2050
+ $this->applyDiscount($cart_item_key, $amount, $log, $additionalDetails);
2051
  } else if ($type == 'biggest') {
2052
  // For Apply the Biggest Discount.
2053
  $discount = $this->getAmount($adjustment_set, $price, 'biggest');
2054
+ if(is_array($discount)){
2055
+ $additionalDetails = $discount['details'];
2056
+ $discount = $discount['amount'];
2057
+ }
2058
  $amount = $price - $discount;
2059
  $log = 'Discount | ' . $discount;
2060
+ $this->applyDiscount($cart_item_key, $amount, $log, $additionalDetails);
2061
  } else {
2062
  // For Apply All Rules.
2063
  $discount = $this->getAmount($adjustment_set, $price);
2064
+ if(is_array($discount)){
2065
+ $additionalDetails = $discount['details'];
2066
+ $discount = $discount['amount'];
2067
+ }
2068
  $amount = $price - $discount;
2069
  $log = 'Discount | ' . $discount;
2070
+ $this->applyDiscount($cart_item_key, $amount, $log, $additionalDetails);
2071
  }
2072
  }
2073
 
2082
  $adjustment_sets[$key]['amount']['product_ids'] = array($product_id);
2083
  }
2084
  }
2085
+ if(isset($adjustment_set['amount']['product_discount_details']) && !empty($adjustment_set['amount']['product_discount_details'])){
2086
+ if(isset($adjustment_set['amount']['product_discount_details'][$product_id])){
2087
+ $adjustment_sets[$key]['amount']['product_discount_details'] = $adjustment_set['amount']['product_discount_details'][$product_id];
2088
+ }
2089
+ }
2090
  }
2091
 
2092
  return $adjustment_sets;
2114
  $discount = $this->getBiggestDiscount($sets, $price, $product_page, $product);
2115
  return $discount;
2116
  }
2117
+ $details = array();
2118
  foreach ($sets as $id => $set) {
2119
  // For the First price, it will return the amount after get hit.
2120
  if ($by == 'first') {
2130
  }
2131
  }
2132
  }
2133
+ $details[] = isset($set['amount']['product_discount_details'])? $set['amount']['product_discount_details'] : array();
2134
+ return array('amount' => $discount, 'details' => $details);
2135
  } else {
2136
  // For All, All rules going to apply.
2137
  if (isset($set['amount']['percentage_discount'])) {
2150
  // Append all Discounts.
2151
  $overall_discount = $overall_discount + $discount;
2152
  }
2153
+ $details[] = isset($set['amount']['product_discount_details'])? $set['amount']['product_discount_details'] : array();
2154
  }
2155
  }
2156
+
2157
+ return array('amount' => $overall_discount, 'details' => $details);
2158
  }
2159
 
2160
  /**
2167
  public function getBiggestDiscount($discount_list, $price, $product_page = 0, $product = array())
2168
  {
2169
  $big = $amount = 0;
2170
+ $details = array();
2171
  foreach ($discount_list as $id => $discount_item) {
2172
  $amount_type = (isset($discount_item['amount']['percentage_discount']) ? 'percentage_discount' : 'price_discount');
2173
  if ($amount_type == 'percentage_discount') {
2189
 
2190
  if ($big < $amount) {
2191
  $big = $amount;
2192
+ $details = isset($discount_item['amount']['product_discount_details'])? $discount_item['amount']['product_discount_details'] : array();
2193
  }
2194
  }
2195
+ if(!empty($details)) $details = array($details);
2196
+
2197
+ return array('amount' => $big,'details' => $details);
2198
  }
2199
 
2200
  /**
2204
  * @param $amount
2205
  * @param $log
2206
  */
2207
+ public function applyDiscount($item, $amount, $log, $additionalDetails = array())
2208
  {
2209
  global $woocommerce;
2210
  // Make sure item exists in cart
2216
  $woocommerce->cart->cart_contents[$item]['woo_discount'] = array(
2217
  'original_price' => get_option('woocommerce_tax_display_cart') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product) : FlycartWoocommerceProduct::get_price_including_tax($product),
2218
  'log' => $log,
2219
+ 'additional_details' => $additionalDetails,
2220
  );
2221
 
2222
  // To handle Woocommerce currency switcher
2233
  FlycartWoocommerceProduct::set_price($product, $amount);
2234
  }
2235
 
2236
+ protected function hasToSplitTheStrikeOutInCart($cart_item, $additional_details){
2237
+ $run_multiple_strikeout = true;
2238
+ $quantity = $cart_item['quantity'];
2239
+ foreach ($additional_details as $detail){
2240
+ if($detail['discount_quantity'] >= $quantity){
2241
+ $run_multiple_strikeout = false;
2242
+ }
2243
+ }
2244
+ return $run_multiple_strikeout;
2245
+ }
2246
+
2247
  /**
2248
  * For Show the Actual Discount of a product.
2249
  *
2267
  $price_to_display = FlycartWoocommerceProduct::wc_price($price);
2268
  $original_price_to_display = FlycartWoocommerceProduct::wc_price($cart_item['woo_discount']['original_price']);
2269
 
2270
+ if ($cart_item['woo_discount']['original_price'] > $price) {
2271
+ $quantity = $cart_item['quantity'];
2272
+ if(!empty($cart_item['woo_discount']['additional_details']) && count($cart_item['woo_discount']['additional_details'])){
2273
+ $additional_details = $cart_item['woo_discount']['additional_details'];
2274
+ $hasToRunMultipleStrikeOut = true;
2275
+ if(count($additional_details) > 1){
2276
+ $hasToRunMultipleStrikeOut = $this->hasToSplitTheStrikeOutInCart($cart_item, $additional_details);
2277
+ }
2278
+ if($hasToRunMultipleStrikeOut){
2279
+ $item_price_first = '<div style="float: left;"><span class="cart_price">' . $original_price_to_display . '</span></div>';
2280
+ $item_price = '';
2281
+ $haslimitedDiscount = 0;
2282
+ foreach ($additional_details as $key => $additional_detail){
2283
+ if(!empty($additional_detail) && isset($additional_detail['discount_price'])){
2284
+ $haslimitedDiscount = 1;
2285
+ if(get_option('woocommerce_prices_include_tax', 'no') == 'no'){
2286
+ if(get_option('woocommerce_tax_display_cart', 'incl') == 'incl'){
2287
+ $additional_detail['discount_price'] = FlycartWoocommerceProduct::get_price_including_tax($cart_item['data'], 1, $additional_detail['discount_price']);
2288
+ }
2289
+ }
2290
+ $new_price_to_display = $cart_item['woo_discount']['original_price'] - $additional_detail['discount_price'];
2291
+ $new_price_to_display = FlycartWoocommerceProduct::wc_price($new_price_to_display);
2292
+ $quantity -= $additional_detail['discount_quantity'];
2293
+ $item_price .= '<div style="float: left;">';
2294
+ $item_price .= '<span class="cart_price"><del>' . $original_price_to_display . '</del> <ins>' . $new_price_to_display . '</ins></span>';
2295
+ $item_price .= '</div>';
2296
+ $item_price .= '<div style="float: right; padding-left: 1em;">';
2297
+ $item_price .= 'x '.$additional_detail['discount_quantity'];
2298
+ $item_price .= '</div>';
2299
+ $item_price .= '<div style="clear: both;"></div>';
2300
+ }
2301
+ }
2302
+ if($haslimitedDiscount){
2303
+ $item_price_first .= '<div style="float: right; padding-left: 1em;">';
2304
+ $item_price_first .= 'x '.$quantity;
2305
+ $item_price_first .= '</div>';
2306
+ $item_price_first .= '<div style="clear: both;"></div>';
2307
+ }
2308
+
2309
+ if($quantity <= 0 || !$haslimitedDiscount){
2310
+ $item_price = '<span class="cart_price"><del>' . $original_price_to_display . '</del> <ins>' . $price_to_display . '</ins></span>';
2311
+ } else {
2312
+ $item_price = $item_price_first.$item_price;
2313
+ }
2314
+ } else {
2315
+ $item_price = '<span class="cart_price"><del>' . $original_price_to_display . '</del> <ins>' . $price_to_display . '</ins></span>';
2316
+ }
2317
+ } else {
2318
+ $item_price = '<span class="cart_price"><del>' . $original_price_to_display . '</del> <ins>' . $price_to_display . '</ins></span>';
2319
+ }
2320
+ $item_price_cont = '<div style="display: inline-block;" class="woo-discount-rules-cart-strikeout-con">';
2321
+ $item_price_cont .= $item_price;
2322
+ $item_price_cont .= '</div>';
2323
+ $item_price = $item_price_cont;
2324
  } else {
2325
  $item_price = $price_to_display;
2326
  }
2506
  if ($type == 'first') {
2507
  // For Apply the First Rule.
2508
  $discount = $this->getAmount($adjustment_set, $price, 'first', 1, $cart_item);
2509
+ if(is_array($discount)){
2510
+ $additionalDetails = $discount['details'];
2511
+ $discount = $discount['amount'];
2512
+ }
2513
 
2514
  } else if ($type == 'biggest') {
2515
  // For Apply the Biggest Discount.
2516
  $discount = $this->getAmount($adjustment_set, $price, 'biggest', 1, $cart_item);
2517
+ if(is_array($discount)){
2518
+ $additionalDetails = $discount['details'];
2519
+ $discount = $discount['amount'];
2520
+ }
2521
  } else {
2522
  // For Apply All Rules.
2523
  $discount = $this->getAmount($adjustment_set, $price, 'all', 1, $cart_item);
2524
+ if(is_array($discount)){
2525
+ $additionalDetails = $discount['details'];
2526
+ $discount = $discount['amount'];
2527
+ }
2528
  }
2529
  if($discount > 0){
2530
  $amount = $price - $discount;
loader.php CHANGED
@@ -160,7 +160,7 @@ if(!class_exists('FlycartWooDiscountRules')){
160
  remove_filter('woocommerce_cart_item_name', 'filter_woocommerce_cart_item_name', 10, 3);
161
 
162
  // Alter the Display Price HTML.
163
- add_filter('woocommerce_cart_item_price', array($this->pricingRules, 'replaceVisiblePricesCart'), 100, 3);
164
 
165
  //replace visible price in product page
166
  add_filter('woocommerce_get_price_html', array($this->pricingRules, 'replaceVisiblePrices'), 100, 3);
@@ -169,7 +169,7 @@ if(!class_exists('FlycartWooDiscountRules')){
169
 
170
 
171
  // Older Version support this hook.
172
- add_filter('woocommerce_cart_item_price_html', array($this->pricingRules, 'replaceVisiblePricesCart'), 100, 3);
173
 
174
  // Pricing Table of Individual Product.
175
  add_filter('woocommerce_before_add_to_cart_form', array($this->pricingRules, 'priceTable'));
160
  remove_filter('woocommerce_cart_item_name', 'filter_woocommerce_cart_item_name', 10, 3);
161
 
162
  // Alter the Display Price HTML.
163
+ add_filter('woocommerce_cart_item_price', array($this->pricingRules, 'replaceVisiblePricesCart'), 1000, 3);
164
 
165
  //replace visible price in product page
166
  add_filter('woocommerce_get_price_html', array($this->pricingRules, 'replaceVisiblePrices'), 100, 3);
169
 
170
 
171
  // Older Version support this hook.
172
+ add_filter('woocommerce_cart_item_price_html', array($this->pricingRules, 'replaceVisiblePricesCart'), 1000, 3);
173
 
174
  // Pricing Table of Individual Product.
175
  add_filter('woocommerce_before_add_to_cart_form', array($this->pricingRules, 'priceTable'));
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.5.10
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -243,6 +243,11 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
243
 
244
  == Changelog ==
245
 
 
 
 
 
 
246
  = 1.5.10 - 23/04/18 =
247
  * Fix - Category subtotal in cart rule while have multiple categories to a product.
248
  * Fix - Discount lowest to highest price in product page for variants, while having large number of variants
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.5.11
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
243
 
244
  == Changelog ==
245
 
246
+ = 1.5.11 - 02/05/18 =
247
+ * Improvement - Multiple strikeout price of an item in cart based on quantity for BOGO price rule
248
+ * Improvement - UI improvement
249
+ * Fix - Cheapest product discount not worked for variants
250
+
251
  = 1.5.10 - 23/04/18 =
252
  * Fix - Category subtotal in cart rule while have multiple categories to a product.
253
  * Fix - Discount lowest to highest price in product page for variants, while having large number of variants
view/view-cart-rules.php CHANGED
@@ -47,8 +47,8 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
47
  <div class="row-fluid">
48
  <div class="<?php echo $isPro? 'col-md-12': 'col-md-9'; ?>">
49
  <div class="col-md-12 rule_buttons_con" align="right">
50
- <input type="submit" id="saveCartRule" value="Save Rule" class="button button-primary">
51
- <a href="?page=woo_discount_rules&tab=cart-rules" class="button button-secondary">Close</a>
52
  </div>
53
  <?php if ($rule_id == 0) { ?>
54
  <div class="col-md-12"><h2>New Cart Rule</h2></div>
@@ -464,7 +464,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
464
  </label>
465
  </div>
466
  <div class="col-md-1"><label> Action </label><br>
467
- <a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a>
468
  </div>
469
  </div>
470
  <?php
47
  <div class="row-fluid">
48
  <div class="<?php echo $isPro? 'col-md-12': 'col-md-9'; ?>">
49
  <div class="col-md-12 rule_buttons_con" align="right">
50
+ <input type="submit" id="saveCartRule" value="Save Rule" class="btn btn-primary">
51
+ <a href="?page=woo_discount_rules&tab=cart-rules" class="btn btn-warning">Close</a>
52
  </div>
53
  <?php if ($rule_id == 0) { ?>
54
  <div class="col-md-12"><h2>New Cart Rule</h2></div>
464
  </label>
465
  </div>
466
  <div class="col-md-1"><label> Action </label><br>
467
+ <a href=javascript:void(0) class="btn btn-danger remove_cart_rule">Remove</a>
468
  </div>
469
  </div>
470
  <?php
view/view-pricing-rules.php CHANGED
@@ -27,8 +27,8 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
27
  <div class="row-fluid">
28
  <div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
29
  <div class="col-md-12 rule_buttons_con" align="right">
30
- <input type="submit" id="savePriceRule" value="Save Rule" class="button button-primary">
31
- <a href="?page=woo_discount_rules" class="button button-secondary">Close</a>
32
  </div>
33
  <?php if ($rule_id == 0) { ?>
34
  <div class="col-md-12"><h2>New Price Rule</h2></div>
@@ -484,7 +484,7 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
484
  <option value="more_than_one_cheapest_from_all"<?php echo ($discount_product_option == 'more_than_one_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from all', 'woo-discount-rules') ?></option>
485
  </select>
486
  <div class="discount_product_option_bogo_con hide">
487
- <label>Free quantity
488
  <input type="text"
489
  name="discount_range[<?php echo $fieldIndex; ?>][discount_bogo_qty]"
490
  class="form-control"
@@ -493,14 +493,14 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
493
  </label>
494
  </div>
495
  <div class="discount_product_option_more_cheapest_con hide">
496
- <label>Item count
497
  <input type="text"
498
  name="discount_range[<?php echo $fieldIndex; ?>][discount_product_items]"
499
  class="form-control"
500
  value="<?php echo(isset($discount->discount_product_items) ? $discount->discount_product_items : ''); ?>"
501
  placeholder="ex. 1" />
502
  </label>
503
- <label>Item quantity
504
  <input type="text"
505
  name="discount_range[<?php echo $fieldIndex; ?>][discount_product_qty]"
506
  class="form-control"
@@ -532,20 +532,19 @@ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
532
  <option value=""<?php echo ($discount_product_discount_type == '')? ' selected="selected"': '' ?>><?php esc_html_e('100% percent', 'woo-discount-rules') ?></option>
533
  <option value="limited_percent"<?php echo ($discount_product_discount_type == 'limited_percent')? ' selected="selected"': '' ?>><?php esc_html_e('Limited percent', 'woo-discount-rules') ?></option>
534
  </select>
535
- <label class="discount_product_percent_field">Percent
536
- <input type="text"
537
- name="discount_range[<?php echo $fieldIndex; ?>][discount_product_percent]"
538
- class="form-control discount_product_percent_field"
539
- value="<?php echo(isset($discount->discount_product_percent) ? $discount->discount_product_percent : ''); ?>"
540
- placeholder="ex. 10" />
541
- </label>
542
  as discount
543
  </div>
544
  </div>
545
  </label>
546
-
547
- <label>Action <a href=javascript:void(0)
548
- class="button button-secondary form-control remove_discount_range">Remove</a></label>
549
 
550
  </div>
551
  </div>
27
  <div class="row-fluid">
28
  <div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
29
  <div class="col-md-12 rule_buttons_con" align="right">
30
+ <input type="submit" id="savePriceRule" value="Save Rule" class="btn btn-primary">
31
+ <a href="?page=woo_discount_rules" class="btn btn-warning">Close</a>
32
  </div>
33
  <?php if ($rule_id == 0) { ?>
34
  <div class="col-md-12"><h2>New Price Rule</h2></div>
484
  <option value="more_than_one_cheapest_from_all"<?php echo ($discount_product_option == 'more_than_one_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from all', 'woo-discount-rules') ?></option>
485
  </select>
486
  <div class="discount_product_option_bogo_con hide">
487
+ <label>Free quantity <span class="woocommerce-help-tip" data-tip="Number of quantity(ies) in each selected product(s)"></span>
488
  <input type="text"
489
  name="discount_range[<?php echo $fieldIndex; ?>][discount_bogo_qty]"
490
  class="form-control"
493
  </label>
494
  </div>
495
  <div class="discount_product_option_more_cheapest_con hide">
496
+ <label>Item count <span class="woocommerce-help-tip" data-tip="Discount for number of item(s) in cart"></span>
497
  <input type="text"
498
  name="discount_range[<?php echo $fieldIndex; ?>][discount_product_items]"
499
  class="form-control"
500
  value="<?php echo(isset($discount->discount_product_items) ? $discount->discount_product_items : ''); ?>"
501
  placeholder="ex. 1" />
502
  </label>
503
+ <label>Item quantity <span class="woocommerce-help-tip" data-tip="Discount for number of quantity(ies) in each item"></span>
504
  <input type="text"
505
  name="discount_range[<?php echo $fieldIndex; ?>][discount_product_qty]"
506
  class="form-control"
532
  <option value=""<?php echo ($discount_product_discount_type == '')? ' selected="selected"': '' ?>><?php esc_html_e('100% percent', 'woo-discount-rules') ?></option>
533
  <option value="limited_percent"<?php echo ($discount_product_discount_type == 'limited_percent')? ' selected="selected"': '' ?>><?php esc_html_e('Limited percent', 'woo-discount-rules') ?></option>
534
  </select>
535
+ <span class="discount_product_percent_field">
536
+ <input type="text"
537
+ name="discount_range[<?php echo $fieldIndex; ?>][discount_product_percent]"
538
+ class="discount_product_percent_field"
539
+ value="<?php echo(isset($discount->discount_product_percent) ? $discount->discount_product_percent : ''); ?>"
540
+ placeholder="ex. 10" /><span class="woocommerce-help-tip" data-tip="Percentage"></span>
541
+ </span>
542
  as discount
543
  </div>
544
  </div>
545
  </label>
546
+ <label><a href=javascript:void(0)
547
+ class="btn btn-danger form-control remove_discount_range">Remove</a></label>
 
548
 
549
  </div>
550
  </div>
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.5.10
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.5.11
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1