Discount Rules for WooCommerce - Version 1.4.41

Version Description

  • 30/01/18 =
  • Fix - Apply coupon discount in percent if there is no rule based on category for better detail in order
  • Feature - Option: More than one cheapest product as free option in BOGO for pro version
Download this release

Release Info

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

Code changes from version 1.4.40 to 1.4.41

assets/css/style.css CHANGED
@@ -42,6 +42,13 @@
42
  font-style: italic;
43
  color: #999;
44
  }
45
- .discount_product_option_list_con{
46
  display: inline-block;
 
 
 
 
 
 
 
47
  }
42
  font-style: italic;
43
  color: #999;
44
  }
45
+ .discount_product_option_list_con, .discount_product_option_more_cheapest_con{
46
  display: inline-block;
47
+ }
48
+ .rule_buttons_con{
49
+ margin-top: 15px;
50
+ }
51
+ .discount_rule_list {
52
+ border-bottom: 1px solid #ddd;
53
+ margin-bottom: 20px;
54
  }
assets/js/app.js CHANGED
@@ -142,8 +142,12 @@ function validateFields(){
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
  '</select>';
 
 
 
 
147
  form += '<div class="discount_product_option_list_con">';
148
  if($('#flycart_wdr_woocommerce_version').val() == 2){
149
  form += '<input type="hidden" class="wc-product-search" style="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=""/>';
@@ -152,7 +156,7 @@ function validateFields(){
152
  }
153
  form += '</div>';
154
  form += '</div>';
155
- form += '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
156
  } else {
157
  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>' +
158
  '<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]"> ' +
@@ -161,7 +165,7 @@ function validateFields(){
161
  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][]">';
162
  form += '<option>none</option>';
163
  form += '</select></div>';
164
- form += '</label> <label>Action <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a></label> </div> </div>';
165
  }
166
  $('#discount_rule_list').append(form);
167
  $('.product_list,.selectpicker').selectpicker('refresh');
@@ -323,7 +327,7 @@ function validateFields(){
323
  '<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>' +
324
  '<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>' +
325
  '<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>' +
326
- '</div><div class="col-md-1"> <label> Action <a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a> </label> </div>' +
327
  '</label></div>';
328
  } else {
329
  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>' +
@@ -343,7 +347,7 @@ function validateFields(){
343
  '<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>' +
344
  '<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>' +
345
  '<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>' +
346
- '</div><div class="col-md-1"> <label> Action <a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a> </label> </div>' +
347
  '</label></div>';
348
  }
349
 
@@ -403,11 +407,17 @@ function validateFields(){
403
  //on change discount_product_option in product discount
404
  $(document).on('change', 'select.discount_product_option', function () {
405
  var discount_product = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_list_con');
 
406
  if($(this).val() == 'any_cheapest_from_all'){
407
  discount_product.addClass('hide');
408
  } else {
409
  discount_product.removeClass('hide');
410
  }
 
 
 
 
 
411
  });
412
  $('select.discount_product_option').trigger('change');
413
 
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><option value="more_than_one_cheapest">More than one cheapest from selected</option>' +
146
  '</select>';
147
+ form += '<div class="discount_product_option_more_cheapest_con hide">';
148
+ form += '<label>Item count<input type="text" name="discount_range['+count+'][discount_product_items]" class="form-control" value="" placeholder="ex. 1" /></label>';
149
+ form += '<label>Item quantity<input type="text" name="discount_range['+count+'][discount_product_qty]" class="form-control" value="" placeholder="ex. 1" /></label>';
150
+ form += '</div>';
151
  form += '<div class="discount_product_option_list_con">';
152
  if($('#flycart_wdr_woocommerce_version').val() == 2){
153
  form += '<input type="hidden" class="wc-product-search" style="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=""/>';
156
  }
157
  form += '</div>';
158
  form += '</div>';
159
+ form += '</label> <label>Action</label><br> <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </div> </div>';
160
  } else {
161
  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>' +
162
  '<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]"> ' +
165
  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][]">';
166
  form += '<option>none</option>';
167
  form += '</select></div>';
168
+ form += '</label> <label>Action</label><br> <a href=javascript:void(0) class="button button-secondary form-control remove_discount_range">Remove</a> </div> </div>';
169
  }
170
  $('#discount_rule_list').append(form);
171
  $('.product_list,.selectpicker').selectpicker('refresh');
327
  '<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>' +
328
  '<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>' +
329
  '<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>' +
330
+ '</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>' +
331
  '</label></div>';
332
  } else {
333
  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>' +
347
  '<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>' +
348
  '<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>' +
349
  '<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>' +
350
+ '</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>' +
351
  '</label></div>';
352
  }
353
 
407
  //on change discount_product_option in product discount
408
  $(document).on('change', 'select.discount_product_option', function () {
409
  var discount_product = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_list_con');
410
+ var discount_product_more_cheapest = $(this).closest('.price_discount_product_list_con').find('.discount_product_option_more_cheapest_con');
411
  if($(this).val() == 'any_cheapest_from_all'){
412
  discount_product.addClass('hide');
413
  } else {
414
  discount_product.removeClass('hide');
415
  }
416
+ if($(this).val() == 'more_than_one_cheapest'){
417
+ discount_product_more_cheapest.removeClass('hide');
418
+ } else {
419
+ discount_product_more_cheapest.addClass('hide');
420
+ }
421
  });
422
  $('select.discount_product_option').trigger('change');
423
 
includes/cart-rules.php CHANGED
@@ -49,6 +49,8 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
49
  */
50
  public $discount_total = 0;
51
 
 
 
52
  /**
53
  * @var array
54
  */
@@ -278,10 +280,17 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
278
  if ($old_coupon_code == $coupon_code) {
279
  if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
280
  $this->makeLog();
 
 
 
 
 
 
 
281
  $coupon = array(
282
  'id' => 321123 . rand(2, 9),
283
- 'type' => 'fixed_cart',
284
- 'amount' => $this->discount_total,
285
  'individual_use' => false,
286
  'product_ids' => array(),
287
  'exclude_product_ids' => array(),
@@ -528,6 +537,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
528
  } else {
529
  //we will have to re-calculate the sub-total if it has category selected
530
  if($this->is_category_specific($rule)) {
 
531
  //re-calculate the sub-total
532
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
533
  }else {
@@ -555,6 +565,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
555
  } else {
556
  //we will have to re-calculate the sub-total if it has category selected
557
  if($this->is_category_specific($rule)) {
 
558
  //re-calculate the sub-total
559
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
560
  }else {
@@ -581,6 +592,7 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
581
  } else {
582
  //we will have to re-calculate the sub-total if it has category selected
583
  if($this->is_category_specific($rule)) {
 
584
  //re-calculate the sub-total
585
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
586
  }else {
49
  */
50
  public $discount_total = 0;
51
 
52
+ public $has_category_in_rule = 0;
53
+
54
  /**
55
  * @var array
56
  */
280
  if ($old_coupon_code == $coupon_code) {
281
  if ($this->postData->get('remove_coupon', false) == $coupon_code) return false;
282
  $this->makeLog();
283
+ $discount_type = 'fixed_cart';
284
+ $amount = $this->discount_total;
285
+ if(!$this->has_category_in_rule){
286
+ $discount_type = 'percent';
287
+ //To calculate the percent from total
288
+ $amount = ((100 * $this->discount_total) / $this->sub_total);
289
+ }
290
  $coupon = array(
291
  'id' => 321123 . rand(2, 9),
292
+ 'discount_type' => $discount_type,
293
+ 'amount' => $amount,
294
  'individual_use' => false,
295
  'product_ids' => array(),
296
  'exclude_product_ids' => array(),
537
  } else {
538
  //we will have to re-calculate the sub-total if it has category selected
539
  if($this->is_category_specific($rule)) {
540
+ $this->has_category_in_rule = 1;
541
  //re-calculate the sub-total
542
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
543
  }else {
565
  } else {
566
  //we will have to re-calculate the sub-total if it has category selected
567
  if($this->is_category_specific($rule)) {
568
+ $this->has_category_in_rule = 1;
569
  //re-calculate the sub-total
570
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
571
  }else {
592
  } else {
593
  //we will have to re-calculate the sub-total if it has category selected
594
  if($this->is_category_specific($rule)) {
595
+ $this->has_category_in_rule = 1;
596
  //re-calculate the sub-total
597
  $subtotal = $this->calculate_conditional_subtotal($this->get_discounted_categories_from_json($rule));
598
  }else {
includes/discount-base.php CHANGED
@@ -600,6 +600,11 @@ if (!class_exists('FlycartWooDiscountBase')) {
600
  }
601
 
602
  if ($status) {
 
 
 
 
 
603
  wp_register_style('woo_discount_style', WOO_DISCOUNT_URI . '/assets/css/style.css', array(), WOO_DISCOUNT_VERSION);
604
  wp_enqueue_style('woo_discount_style');
605
 
@@ -618,8 +623,10 @@ if (!class_exists('FlycartWooDiscountBase')) {
618
  wp_register_style('woo_discount_bootstrap', WOO_DISCOUNT_URI . '/assets/css/bootstrap.min.css', array(), WOO_DISCOUNT_VERSION);
619
  wp_enqueue_style('woo_discount_bootstrap');
620
 
621
- wp_register_script('woo_discount_jquery_ui_js_2', WOO_DISCOUNT_URI . '/assets/js/bootstrap.min.js', array(), WOO_DISCOUNT_VERSION);
622
- wp_enqueue_script('woo_discount_jquery_ui_js_2');
 
 
623
 
624
  wp_register_style('woo_discount_jquery_ui_css', WOO_DISCOUNT_URI . '/assets/css/jquery-ui.css', array(), WOO_DISCOUNT_VERSION);
625
  wp_enqueue_style('woo_discount_jquery_ui_css');
600
  }
601
 
602
  if ($status) {
603
+
604
+ $config = $this->getBaseConfig();
605
+ if (is_string($config)) $config = json_decode($config, true);
606
+ $enable_bootstrap = isset($config['enable_bootstrap'])? $config['enable_bootstrap']: 1;
607
+
608
  wp_register_style('woo_discount_style', WOO_DISCOUNT_URI . '/assets/css/style.css', array(), WOO_DISCOUNT_VERSION);
609
  wp_enqueue_style('woo_discount_style');
610
 
623
  wp_register_style('woo_discount_bootstrap', WOO_DISCOUNT_URI . '/assets/css/bootstrap.min.css', array(), WOO_DISCOUNT_VERSION);
624
  wp_enqueue_style('woo_discount_bootstrap');
625
 
626
+ if($enable_bootstrap){
627
+ wp_register_script('woo_discount_jquery_ui_js_2', WOO_DISCOUNT_URI . '/assets/js/bootstrap.min.js', array(), WOO_DISCOUNT_VERSION);
628
+ wp_enqueue_script('woo_discount_jquery_ui_js_2');
629
+ }
630
 
631
  wp_register_style('woo_discount_jquery_ui_css', WOO_DISCOUNT_URI . '/assets/css/jquery-ui.css', array(), WOO_DISCOUNT_VERSION);
632
  wp_enqueue_style('woo_discount_jquery_ui_css');
includes/pricing-rules.php CHANGED
@@ -995,6 +995,15 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
995
  if(!empty($productCheapest)){
996
  $adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
997
  }
 
 
 
 
 
 
 
 
 
998
  } else {
999
  //to handle product discount
1000
  $free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
@@ -1019,10 +1028,35 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1019
  return $adjustment;
1020
  }
1021
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1022
  /**
1023
  * Get cheapest product
1024
  * */
1025
- public function getCheapestProductFromCart($products, $all = 0){
1026
  if(!$all){
1027
  if(empty($products)) return array();
1028
  }
@@ -1045,7 +1079,10 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1045
  }
1046
  if($cheapestProductValue > 0){
1047
  //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
1048
- $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-1));
 
 
 
1049
  return array('product' => $cheapestProduct, 'percent' => $discount_price);
1050
  }
1051
  return array();
@@ -1428,7 +1465,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1428
  }
1429
  if(!is_array($productToExclude)){
1430
  $productToExclude = array();
1431
- }
1432
  return $productToExclude;
1433
  }
1434
 
@@ -1543,6 +1580,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1543
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
1544
  $product_discount = isset($value->discount_product) ? $value->discount_product : array();
1545
  $discount_product_option = isset($value->discount_product_option) ? $value->discount_product_option : 'all';
 
 
1546
  $product_discount = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_discount);
1547
  if (isset($base_config['show_discount_title_table'])) {
1548
  }
@@ -1555,10 +1594,20 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1555
  if($discount_product_option == 'any_cheapest'){
1556
  $htmlProduct .= esc_html__('Any cheapest one of ', 'woo-discount-rules');
1557
  }
 
 
 
 
 
 
 
 
1558
  if(count($product_discount)){
1559
  foreach ($product_discount as $product_id){
1560
  $product = FlycartWoocommerceProduct::wc_get_product($product_id);
 
1561
  $htmlProduct .= FlycartWoocommerceProduct::get_title($product);
 
1562
  $htmlProduct .= ' ('.FlycartWoocommerceProduct::get_price_html($product).')<br>';
1563
  }
1564
  }
@@ -1625,11 +1674,15 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1625
  // If Product having the rule sets then,
1626
  if (!isset($this->matched_sets[$cart_item_key])) return false;
1627
  if (empty($this->matched_sets[$cart_item_key])) return false;
1628
-
1629
  $adjustment_set = $this->matched_sets[$cart_item_key];
1630
  $product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
 
1631
  $price = FlycartWoocommerceProduct::get_price($product);
1632
 
 
 
 
1633
  if ($type == 'first') {
1634
  // For Apply the First Rule.
1635
  $discount = $this->getAmount($adjustment_set, $price, 'first');
@@ -1651,6 +1704,22 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1651
  }
1652
  }
1653
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1654
  /**
1655
  * To Get Amount based on the Setting that specified.
1656
  *
@@ -1831,7 +1900,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1831
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
1832
  if($discountPrice > 0){
1833
  $price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
1834
- $price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display);
 
1835
  $item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
1836
  $item_price = '<span class="cart_price"><del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix() . '</ins></span>';
1837
  }
@@ -1952,7 +2022,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1952
  }
1953
  }
1954
  }
1955
-
1956
  $amount = 0;
1957
  $discount = 0;
1958
  if ($type == 'first') {
995
  if(!empty($productCheapest)){
996
  $adjustment = array ( 'price_discount' => $productCheapest['percent'], 'product_ids' => array($productCheapest['product']) ) ;
997
  }
998
+ } else if($discount_product_option == 'more_than_one_cheapest'){
999
+ $discount_product_items = (isset($range->discount_product_items) ? $range->discount_product_items : 1);
1000
+ if($discount_product_items < 1) $discount_product_items = 1;
1001
+ $discount_product_qty = (isset($range->discount_product_qty) ? $range->discount_product_qty : 1);
1002
+ if($discount_product_qty < 1) $discount_product_qty = 1;
1003
+ $productCheapest = $this->getMoreThanOneCheapestProductFromCart($productIds, $discount_product_qty, $discount_product_items);
1004
+ if(!empty($productCheapest)){
1005
+ $adjustment = $productCheapest ;
1006
+ }
1007
  } else {
1008
  //to handle product discount
1009
  $free_product = WC()->session->get('woo_discount_rules_get_free_product', array());
1028
  return $adjustment;
1029
  }
1030
 
1031
+ /**
1032
+ * Get More than one cheapest item
1033
+ * */
1034
+ public function getMoreThanOneCheapestProductFromCart($productIds, $discount_quantity = 1, $discount_item = 1){
1035
+ $adjustment = array();
1036
+ $adjustmentValues = array();
1037
+ for ($i = 1; $i <= $discount_item; $i++){
1038
+ $productCheapest = $this->getCheapestProductFromCart($productIds, 0, $discount_quantity);
1039
+ if(!empty($productCheapest)){
1040
+ $index = array_search($productCheapest['product'], $productIds);
1041
+ if ( $index !== false ) {
1042
+ unset( $productIds[$index] );
1043
+ }
1044
+ $adjustment['price_discount'] = $productCheapest['percent'];
1045
+ $adjustment['product_ids'][] = $productCheapest['product'];
1046
+ $adjustmentValues[$productCheapest['product']] = $productCheapest['percent'];
1047
+ $adjustment['product_discount_adjustment'] = $adjustmentValues;
1048
+ } else {
1049
+ break;
1050
+ }
1051
+ }
1052
+
1053
+ return $adjustment;
1054
+ }
1055
+
1056
  /**
1057
  * Get cheapest product
1058
  * */
1059
+ public function getCheapestProductFromCart($products, $all = 0, $discount_quantity = 1){
1060
  if(!$all){
1061
  if(empty($products)) return array();
1062
  }
1079
  }
1080
  if($cheapestProductValue > 0){
1081
  //discount_price = (original_price - ((original_price / (buy_qty + free_qty))*buy_qty))
1082
+ if($discount_quantity > $quantity)
1083
+ $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$quantity));
1084
+ else
1085
+ $discount_price = $cheapestProductValue - (($cheapestProductValue/($quantity)) * ($quantity-$discount_quantity));
1086
  return array('product' => $cheapestProduct, 'percent' => $discount_price);
1087
  }
1088
  return array();
1465
  }
1466
  if(!is_array($productToExclude)){
1467
  $productToExclude = array();
1468
+ }
1469
  return $productToExclude;
1470
  }
1471
 
1580
  $to_discount = isset($value->to_discount) ? $value->to_discount : 0;
1581
  $product_discount = isset($value->discount_product) ? $value->discount_product : array();
1582
  $discount_product_option = isset($value->discount_product_option) ? $value->discount_product_option : 'all';
1583
+ $discount_product_items = isset($value->discount_product_items) ? $value->discount_product_items : 1;
1584
+ $discount_product_qty = isset($value->discount_product_qty) ? $value->discount_product_qty : 1;
1585
  $product_discount = FlycartWoocommerceVersion::backwardCompatibilityStringToArray($product_discount);
1586
  if (isset($base_config['show_discount_title_table'])) {
1587
  }
1594
  if($discount_product_option == 'any_cheapest'){
1595
  $htmlProduct .= esc_html__('Any cheapest one of ', 'woo-discount-rules');
1596
  }
1597
+ if($discount_product_option == 'more_than_one_cheapest'){
1598
+ $htmlProduct .= esc_html__('Get ', 'woo-discount-rules');
1599
+ $htmlProduct .= $discount_product_qty;
1600
+ $htmlProduct .= esc_html__(' quantity of any ', 'woo-discount-rules');
1601
+ $htmlProduct .= $discount_product_items;
1602
+ $htmlProduct .= esc_html__(' cheapest item ', 'woo-discount-rules');
1603
+
1604
+ }
1605
  if(count($product_discount)){
1606
  foreach ($product_discount as $product_id){
1607
  $product = FlycartWoocommerceProduct::wc_get_product($product_id);
1608
+ $htmlProduct .= "<a href='".FlycartWoocommerceProduct::get_permalink($product)."'>";
1609
  $htmlProduct .= FlycartWoocommerceProduct::get_title($product);
1610
+ $htmlProduct .= "</a>";
1611
  $htmlProduct .= ' ('.FlycartWoocommerceProduct::get_price_html($product).')<br>';
1612
  }
1613
  }
1674
  // If Product having the rule sets then,
1675
  if (!isset($this->matched_sets[$cart_item_key])) return false;
1676
  if (empty($this->matched_sets[$cart_item_key])) return false;
1677
+
1678
  $adjustment_set = $this->matched_sets[$cart_item_key];
1679
  $product = $woocommerce->cart->cart_contents[$cart_item_key]['data'];
1680
+ $product_id = FlycartWoocommerceProduct::get_id($product);
1681
  $price = FlycartWoocommerceProduct::get_price($product);
1682
 
1683
+ //To reset the adjustment set if the Product discount adjustment exists
1684
+ $adjustment_set = $this->resetTheDiscountIfProductDiscountAdjustmentExists($adjustment_set, $product_id);
1685
+
1686
  if ($type == 'first') {
1687
  // For Apply the First Rule.
1688
  $discount = $this->getAmount($adjustment_set, $price, 'first');
1704
  }
1705
  }
1706
 
1707
+ /**
1708
+ * To reset the adjustment set if the Product discount adjustment exists
1709
+ * */
1710
+ protected function resetTheDiscountIfProductDiscountAdjustmentExists($adjustment_sets, $product_id){
1711
+ foreach ($adjustment_sets as $key => $adjustment_set){
1712
+ if(isset($adjustment_set['amount']['product_discount_adjustment']) && !empty($adjustment_set['amount']['product_discount_adjustment'])){
1713
+ if(isset($adjustment_set['amount']['product_discount_adjustment'][$product_id])){
1714
+ $adjustment_sets[$key]['amount']['price_discount'] = $adjustment_set['amount']['product_discount_adjustment'][$product_id];
1715
+ $adjustment_sets[$key]['amount']['product_ids'] = array($product_id);
1716
+ }
1717
+ }
1718
+ }
1719
+
1720
+ return $adjustment_sets;
1721
+ }
1722
+
1723
  /**
1724
  * To Get Amount based on the Setting that specified.
1725
  *
1900
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
1901
  if($discountPrice > 0){
1902
  $price_to_display = FlycartWoocommerceProduct::wc_price($discountPrice);
1903
+ if(FlycartWoocommerceVersion::wcVersion('3.0'))
1904
+ $price_to_display = $this->checkForHighestVariantIfExists($product, $price_to_display);
1905
  $item_price = preg_replace('/<del>.*<\/del>/', '', $item_price);
1906
  $item_price = '<span class="cart_price"><del>' . $item_price . '</del> <ins>' . ($price_to_display).$product->get_price_suffix() . '</ins></span>';
1907
  }
2022
  }
2023
  }
2024
  }
2025
+
2026
  $amount = 0;
2027
  $discount = 0;
2028
  if ($type == 'first') {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.9
7
- Stable tag: 1.4.40
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -67,6 +67,9 @@ Display the pricing discount table beautifully on the product page. Start sellin
67
  * Buy one and get one free of the same product
68
  * Buy X get Y product free Eg: Buy 3 product and get a pendrive free
69
  * Buy Any 2 items from Category X, and get a Product free from Category B
 
 
 
70
 
71
  = Cart Discount Rules: =
72
 
@@ -238,6 +241,10 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
238
 
239
  == Changelog ==
240
 
 
 
 
 
241
  = 1.4.40 - 22/01/18 =
242
  * Feature - Option: Exclude product for all products and specific categories option in Pricing Rules
243
  * Fix - Strike and display price of least and highest amount for variable products
4
  Tags: woocommerce, discounts, dynamic pricing, Buy One Get One Free, pricing deals, price rules, bulk discounts, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.9
7
+ Stable tag: 1.4.41
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
67
  * Buy one and get one free of the same product
68
  * Buy X get Y product free Eg: Buy 3 product and get a pendrive free
69
  * Buy Any 2 items from Category X, and get a Product free from Category B
70
+ * Buy X products and get X number of products free
71
+ * Buy 3 products from any category, get 1 free. Buy 6 products, get 2 products free....
72
+ * Buy 12 products (any or category specific), get X number of cheapest among them free
73
 
74
  = Cart Discount Rules: =
75
 
241
 
242
  == Changelog ==
243
 
244
+ = 1.4.41 - 30/01/18 =
245
+ * Fix - Apply coupon discount in percent if there is no rule based on category for better detail in order
246
+ * Feature - Option: More than one cheapest product as free option in BOGO for pro version
247
+
248
  = 1.4.40 - 22/01/18 =
249
  * Feature - Option: Exclude product for all products and specific categories option in Pricing Rules
250
  * Fix - Strike and display price of least and highest amount for variable products
view/cart-rules.php CHANGED
@@ -10,120 +10,126 @@ $config = (isset($config)) ? $config : '{}';
10
  $data = array();
11
  $rule_list = $config;
12
  global $woocommerce;
 
 
13
  ?>
14
- <div class="" id="cart_rule">
15
  <div class="row-fluid">
16
- <div class="col-md-8">
17
- <h4>Cart Rules</h4>
18
- <hr>
19
- <form method="post" action="?page=woo_discount_rules">
20
- <div class="row">
21
- <div class="col-md-4" id="add_new_rule_div">
22
- <?php if (isset($rule_list)) {
23
- if (count($rule_list) >= 3 && !$pro) { ?>
24
- <a href=javascript:void(0)
25
- class="button button-secondary">You Reach Max. Rule Limit
26
- </a>
27
- <?php } else {
28
- ?>
29
- <a href="?page=woo_discount_rules&tab=cart-rules&type=new"
30
- id="add_new_rule"
31
- class="button button-primary">Add New Rule
32
- </a>
33
- <?php
 
 
34
  }
35
- }
36
 
37
- ?>
38
 
 
 
 
 
 
39
  </div>
40
- <div class="col-md-12">
41
- <code>NOTE: Order Should not be empty ('-').If it's empty('-'), then it won't be
42
- implemented.</code>
43
- </div>
44
- </div>
45
- <div class="row">
46
- <div class="">
47
- <div class=""></div>
48
  <div class="">
49
- <table class="wp-list-table widefat fixed striped posts">
50
- <thead>
51
- <tr>
52
- <td>Name</td>
53
- <td>Start Date</td>
54
- <td>Expired On</td>
55
- <td>Order</td>
56
- <td>Action</td>
57
- </tr>
58
- </thead>
59
- <tbody id="cart_rule">
60
- <?php
61
- $i = 1;
62
- if (is_array($rule_list)) {
63
- if (count($rule_list) > 0) {
64
- foreach ($rule_list as $index => $rule) {
65
- if (!$pro && $i > 3) continue;
66
- $meta = $rule->meta;
67
- $status = isset($meta['status'][0]) ? $meta['status'][0] : 'disable';
68
- $class = 'button button-secondary';
69
-
70
- if ($status == 'publish') {
71
- $class = 'button button-primary';
72
- $value = 'Disable';
73
- } else {
74
  $class = 'button button-secondary';
75
- $value = 'Enable';
76
- }
77
- ?>
78
 
79
- <tr>
80
- <td><?php echo(isset($meta['rule_name'][0]) ? $meta['rule_name'][0] : '-') ?></td>
81
- <td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
82
- <td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
83
- <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
84
- <td>
85
- <a class="button button-primary"
86
- href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
87
- Edit
88
- </a>
89
- <a class="<?php echo $class; ?> cart_manage_status"
90
- id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
91
- </a>
92
- <a class="button button-secondary cart_delete_rule"
93
- id="delete_<?php echo $rule->ID ?>">Delete
94
- </a>
95
- </td>
96
- </tr>
97
- <?php
98
- $i++;
 
 
 
 
 
 
 
 
 
 
99
  }
100
  }
101
- }
102
- ?>
103
- </tbody>
104
- <tfoot>
105
- <tr>
106
- <td>Name</td>
107
- <td>Start Date</td>
108
- <td>Expired On</td>
109
- <td>Order</td>
110
- <td>Action</td>
111
- </tr>
112
- </tfoot>
113
- </table>
114
  </div>
115
  </div>
116
- </div>
117
- <hr>
118
 
119
- <input type="hidden" name="form" value="cart_rules">
120
- <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php') ?>">
121
- </form>
 
122
  </div>
123
- <div class="col-md-1"></div>
124
- <!-- Sidebar -->
125
- <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
126
- <!-- Sidebar END -->
 
 
127
  </div>
128
  </div>
129
  <div class="clear"></div>
10
  $data = array();
11
  $rule_list = $config;
12
  global $woocommerce;
13
+
14
+ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
15
  ?>
16
+ <div class="container-fluid" id="cart_rule">
17
  <div class="row-fluid">
18
+ <div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
19
+ <div class="row">
20
+ <h4>Cart Rules</h4>
21
+ <hr>
22
+ <form method="post" action="?page=woo_discount_rules">
23
+ <div class="row">
24
+ <div class="col-md-4" id="add_new_rule_div">
25
+ <?php if (isset($rule_list)) {
26
+ if (count($rule_list) >= 3 && !$pro) { ?>
27
+ <a href=javascript:void(0)
28
+ class="button button-secondary">You Reach Max. Rule Limit
29
+ </a>
30
+ <?php } else {
31
+ ?>
32
+ <a href="?page=woo_discount_rules&tab=cart-rules&type=new"
33
+ id="add_new_rule"
34
+ class="button button-primary">Add New Rule
35
+ </a>
36
+ <?php
37
+ }
38
  }
 
39
 
40
+ ?>
41
 
42
+ </div>
43
+ <div class="col-md-12">
44
+ <code>NOTE: Order Should not be empty ('-').If it's empty('-'), then it won't be
45
+ implemented.</code>
46
+ </div>
47
  </div>
48
+ <div class="row">
 
 
 
 
 
 
 
49
  <div class="">
50
+ <div class=""></div>
51
+ <div class="">
52
+ <table class="wp-list-table widefat fixed striped posts">
53
+ <thead>
54
+ <tr>
55
+ <td>Name</td>
56
+ <td>Start Date</td>
57
+ <td>Expired On</td>
58
+ <td>Order</td>
59
+ <td>Action</td>
60
+ </tr>
61
+ </thead>
62
+ <tbody id="cart_rule">
63
+ <?php
64
+ $i = 1;
65
+ if (is_array($rule_list)) {
66
+ if (count($rule_list) > 0) {
67
+ foreach ($rule_list as $index => $rule) {
68
+ if (!$pro && $i > 3) continue;
69
+ $meta = $rule->meta;
70
+ $status = isset($meta['status'][0]) ? $meta['status'][0] : 'disable';
 
 
 
 
71
  $class = 'button button-secondary';
 
 
 
72
 
73
+ if ($status == 'publish') {
74
+ $class = 'button button-primary';
75
+ $value = 'Disable';
76
+ } else {
77
+ $class = 'button button-secondary';
78
+ $value = 'Enable';
79
+ }
80
+ ?>
81
+
82
+ <tr>
83
+ <td><?php echo(isset($meta['rule_name'][0]) ? $meta['rule_name'][0] : '-') ?></td>
84
+ <td><?php echo(isset($rule->date_from) ? $rule->date_from : '-') ?></td>
85
+ <td><?php echo(isset($rule->date_to) ? $rule->date_to : '-') ?></td>
86
+ <td><?php echo((isset($rule->rule_order) && ($rule->rule_order != '')) ? $rule->rule_order : ' - ') ?></td>
87
+ <td>
88
+ <a class="button button-primary"
89
+ href="?page=woo_discount_rules&tab=cart-rules&view=<?php echo $rule->ID ?>">
90
+ Edit
91
+ </a>
92
+ <a class="<?php echo $class; ?> cart_manage_status"
93
+ id="state_<?php echo $rule->ID ?>"><?php echo $value; ?>
94
+ </a>
95
+ <a class="button button-secondary cart_delete_rule"
96
+ id="delete_<?php echo $rule->ID ?>">Delete
97
+ </a>
98
+ </td>
99
+ </tr>
100
+ <?php
101
+ $i++;
102
+ }
103
  }
104
  }
105
+ ?>
106
+ </tbody>
107
+ <tfoot>
108
+ <tr>
109
+ <td>Name</td>
110
+ <td>Start Date</td>
111
+ <td>Expired On</td>
112
+ <td>Order</td>
113
+ <td>Action</td>
114
+ </tr>
115
+ </tfoot>
116
+ </table>
117
+ </div>
118
  </div>
119
  </div>
120
+ <hr>
 
121
 
122
+ <input type="hidden" name="form" value="cart_rules">
123
+ <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php') ?>">
124
+ </form>
125
+ </div>
126
  </div>
127
+ <?php if(!$isPro){ ?>
128
+ <div class="col-md-1"></div>
129
+ <!-- Sidebar -->
130
+ <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
131
+ <!-- Sidebar END -->
132
+ <?php } ?>
133
  </div>
134
  </div>
135
  <div class="clear"></div>
view/pricing-rules.php CHANGED
@@ -9,6 +9,7 @@ $config = (isset($config)) ? $config : '{}';
9
 
10
  $data = array();
11
  $rule_list = $config;
 
12
  ?>
13
 
14
  <style>
@@ -46,7 +47,7 @@ $rule_list = $config;
46
 
47
  <div class="container-fluid" id="pricing_rule">
48
  <div class="row-fluid">
49
- <div class="col-md-8">
50
  <div class="">
51
  <div class="">
52
  <h4>Price Rules</h4>
@@ -155,10 +156,12 @@ $rule_list = $config;
155
  </div>
156
  </div>
157
  </div>
158
- <div class="col-md-1"></div>
159
- <!-- Sidebar -->
160
- <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
161
- <!-- Sidebar END -->
 
 
162
  </div>
163
  </div>
164
  <div class="clear"></div>
9
 
10
  $data = array();
11
  $rule_list = $config;
12
+ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
13
  ?>
14
 
15
  <style>
47
 
48
  <div class="container-fluid" id="pricing_rule">
49
  <div class="row-fluid">
50
+ <div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
51
  <div class="">
52
  <div class="">
53
  <h4>Price Rules</h4>
156
  </div>
157
  </div>
158
  </div>
159
+ <?php if(!$isPro){ ?>
160
+ <div class="col-md-1"></div>
161
+ <!-- Sidebar -->
162
+ <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
163
+ <!-- Sidebar END -->
164
+ <?php } ?>
165
  </div>
166
  </div>
167
  <div class="clear"></div>
view/settings.php CHANGED
@@ -8,11 +8,12 @@ include_once(WOO_DISCOUNT_DIR . '/view/includes/menu.php');
8
  $data = $config;
9
 
10
  if (is_string($data)) $data = json_decode($data, true);
 
11
  ?>
12
 
13
  <div class="container-fluid">
14
  <div class="row-fluid">
15
- <div class="col-md-8">
16
  <form method="post" id="discount_config">
17
  <div class="col-md-12" align="right">
18
  <input type="submit" id="saveConfig" value="Save" class="button button-primary">
@@ -208,6 +209,18 @@ if (is_string($data)) $data = json_decode($data, true);
208
  </select>
209
  </div>
210
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
211
  <div class="row form-group">
212
  <div class="col-md-2">
213
  <label>
@@ -228,10 +241,12 @@ if (is_string($data)) $data = json_decode($data, true);
228
  </div>
229
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php') ?>">
230
  </div>
231
- <div class="col-md-1"></div>
232
- <!-- Sidebar -->
233
- <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
234
- <!-- Sidebar END -->
 
 
235
  </form>
236
  </div>
237
  </div>
8
  $data = $config;
9
 
10
  if (is_string($data)) $data = json_decode($data, true);
11
+ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
12
  ?>
13
 
14
  <div class="container-fluid">
15
  <div class="row-fluid">
16
+ <div class="<?php echo $isPro? 'col-md-12': 'col-md-8'; ?>">
17
  <form method="post" id="discount_config">
18
  <div class="col-md-12" align="right">
19
  <input type="submit" id="saveConfig" value="Save" class="button button-primary">
209
  </select>
210
  </div>
211
  </div>
212
+ <div class="row form-group">
213
+ <div class="col-md-2">
214
+ <label>
215
+ <?php esc_html_e('Enable Bootstrap', 'woo-discount-rules'); ?>
216
+ </label>
217
+ </div>
218
+ <?php $data['enable_bootstrap'] = (isset($data['enable_bootstrap']) ? $data['enable_bootstrap'] : 1); ?>
219
+ <div class="col-md-6">
220
+ <label><input type="radio" name="enable_bootstrap" value="1" <?php echo ($data['enable_bootstrap'] == 1)? 'checked': '' ?>/> <?php esc_html_e('Yes', 'woo-discount-rules'); ?></label>
221
+ <label><input type="radio" name="enable_bootstrap" value="0" <?php echo ($data['enable_bootstrap'] == 0)? 'checked': '' ?> /> <?php esc_html_e('No', 'woo-discount-rules'); ?></label>
222
+ </div>
223
+ </div>
224
  <div class="row form-group">
225
  <div class="col-md-2">
226
  <label>
241
  </div>
242
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php') ?>">
243
  </div>
244
+ <?php if(!$isPro){ ?>
245
+ <div class="col-md-1"></div>
246
+ <!-- Sidebar -->
247
+ <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
248
+ <!-- Sidebar END -->
249
+ <?php } ?>
250
  </form>
251
  </div>
252
  </div>
view/view-cart-rules.php CHANGED
@@ -40,15 +40,15 @@ if (empty($discount_rules)) {
40
  $discount_rules = array(0 => '');
41
  $type = 'subtotal_least';
42
  }
43
-
44
  ?>
45
  <div class="container-fluid">
46
  <form id="form_cart_rule">
47
  <div class="row-fluid">
48
- <div class="col-md-9">
49
- <div class="col-md-12" 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">Cancel</a>
52
  </div>
53
  <?php if ($rule_id == 0) { ?>
54
  <div class="col-md-12"><h2>New Cart Rule</h2></div>
@@ -419,9 +419,9 @@ if (empty($discount_rules)) {
419
  </div>
420
  </label>
421
  </div>
422
- <div class="col-md-1"><label> Action <a href=javascript:void(0)
423
- class="button button-secondary remove_cart_rule">Remove</a>
424
- </label></div>
425
  </div>
426
  <?php
427
  $i++;
@@ -487,9 +487,11 @@ if (empty($discount_rules)) {
487
  </div>
488
  </div>
489
  </div>
490
- <!-- Sidebar -->
491
- <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
492
- <!-- Sidebar END -->
 
 
493
  <input type="hidden" name="rule_id" id="rule_id" value="<?php echo $rule_id; ?>">
494
  <input type="hidden" name="form" value="<?php echo $form; ?>">
495
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php'); ?>">
40
  $discount_rules = array(0 => '');
41
  $type = 'subtotal_least';
42
  }
43
+ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
44
  ?>
45
  <div class="container-fluid">
46
  <form id="form_cart_rule">
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>
419
  </div>
420
  </label>
421
  </div>
422
+ <div class="col-md-1"><label> Action </label><br>
423
+ <a href=javascript:void(0) class="button button-secondary remove_cart_rule">Remove</a>
424
+ </div>
425
  </div>
426
  <?php
427
  $i++;
487
  </div>
488
  </div>
489
  </div>
490
+ <?php if(!$isPro){ ?>
491
+ <!-- Sidebar -->
492
+ <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
493
+ <!-- Sidebar END -->
494
+ <?php } ?>
495
  <input type="hidden" name="rule_id" id="rule_id" value="<?php echo $rule_id; ?>">
496
  <input type="hidden" name="form" value="<?php echo $form; ?>">
497
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php'); ?>">
view/view-pricing-rules.php CHANGED
@@ -20,14 +20,15 @@ if (is_string($config)) {
20
  $data = $config;
21
  $rule_id = (isset($data->ID)) ? $data->ID : 0;
22
 
 
23
  ?>
24
  <div class="container-fluid">
25
  <form id="form_price_rule">
26
  <div class="row-fluid">
27
- <div class="col-md-8">
28
- <div class="col-md-12" align="right">
29
  <input type="submit" id="savePriceRule" value="Save Rule" class="button button-primary">
30
- <a href="?page=woo_discount_rules" class="button button-secondary">Cancel</a>
31
  </div>
32
  <?php if ($rule_id == 0) { ?>
33
  <div class="col-md-12"><h2>New Price Rule</h2></div>
@@ -419,7 +420,24 @@ $rule_id = (isset($data->ID)) ? $data->ID : 0;
419
  <option value="all"<?php echo ($discount_product_option == 'all')? ' selected="selected"': '' ?>><?php esc_html_e('All selected', 'woo-discount-rules') ?></option>
420
  <option value="any_cheapest"<?php echo ($discount_product_option == 'any_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from selected', 'woo-discount-rules') ?></option>
421
  <option value="any_cheapest_from_all"<?php echo ($discount_product_option == 'any_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from all products', 'woo-discount-rules') ?></option>
 
422
  </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  <div class="discount_product_option_list_con hide">
424
  <?php
425
  echo FlycartWoocommerceProduct::getProductAjaxSelectBox($products_list, "discount_range[".$fieldIndex."][discount_product]");
@@ -455,10 +473,12 @@ $rule_id = (isset($data->ID)) ? $data->ID : 0;
455
  </div>
456
  </div>
457
  </div>
458
- <div class="col-md-1"></div>
459
- <!-- Sidebar -->
460
- <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
461
- <!-- Sidebar END -->
 
 
462
  <input type="hidden" name="rule_id" id="rule_id" value="<?php echo $rule_id; ?>">
463
  <input type="hidden" name="form" value="<?php echo $form; ?>">
464
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php'); ?>">
20
  $data = $config;
21
  $rule_id = (isset($data->ID)) ? $data->ID : 0;
22
 
23
+ $isPro = (new FlycartWooDiscountRulesPurchase())->isPro();
24
  ?>
25
  <div class="container-fluid">
26
  <form id="form_price_rule">
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>
420
  <option value="all"<?php echo ($discount_product_option == 'all')? ' selected="selected"': '' ?>><?php esc_html_e('All selected', 'woo-discount-rules') ?></option>
421
  <option value="any_cheapest"<?php echo ($discount_product_option == 'any_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from selected', 'woo-discount-rules') ?></option>
422
  <option value="any_cheapest_from_all"<?php echo ($discount_product_option == 'any_cheapest_from_all')? ' selected="selected"': '' ?>><?php esc_html_e('Any one cheapest from all products', 'woo-discount-rules') ?></option>
423
+ <option value="more_than_one_cheapest"<?php echo ($discount_product_option == 'more_than_one_cheapest')? ' selected="selected"': '' ?>><?php esc_html_e('More than one cheapest from selected', 'woo-discount-rules') ?></option>
424
  </select>
425
+ <div class="discount_product_option_more_cheapest_con hide">
426
+ <label>Item count
427
+ <input type="text"
428
+ name="discount_range[<?php echo $fieldIndex; ?>][discount_product_items]"
429
+ class="form-control"
430
+ value="<?php echo(isset($discount->discount_product_items) ? $discount->discount_product_items : ''); ?>"
431
+ placeholder="ex. 1" />
432
+ </label>
433
+ <label>Item quantity
434
+ <input type="text"
435
+ name="discount_range[<?php echo $fieldIndex; ?>][discount_product_qty]"
436
+ class="form-control"
437
+ value="<?php echo(isset($discount->discount_product_qty) ? $discount->discount_product_qty : ''); ?>"
438
+ placeholder="ex. 1" />
439
+ </label>
440
+ </div>
441
  <div class="discount_product_option_list_con hide">
442
  <?php
443
  echo FlycartWoocommerceProduct::getProductAjaxSelectBox($products_list, "discount_range[".$fieldIndex."][discount_product]");
473
  </div>
474
  </div>
475
  </div>
476
+ <?php if(!$isPro){ ?>
477
+ <div class="col-md-1"></div>
478
+ <!-- Sidebar -->
479
+ <?php include_once(__DIR__ . '/template/sidebar.php'); ?>
480
+ <!-- Sidebar END -->
481
+ <?php } ?>
482
  <input type="hidden" name="rule_id" id="rule_id" value="<?php echo $rule_id; ?>">
483
  <input type="hidden" name="form" value="<?php echo $form; ?>">
484
  <input type="hidden" id="ajax_path" value="<?php echo admin_url('admin-ajax.php'); ?>">
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.40
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.41
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1