Discount Rules for WooCommerce - Version 1.4.17

Version Description

  • 07/09/17 =
  • Fix Cart rule based on billing city for pro version
Download this release

Release Info

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

Code changes from version 1.4.16 to 1.4.17

assets/js/app.js CHANGED
@@ -304,6 +304,7 @@ function validateFields(){
304
  //'<optgroup label="Categories In Cart"><!-- At least one of these should present in the cart to apply. --><option value="categories_atleast_one">At least one category in cart</option><!-- These Category should not present in the cart to apply. --><!--<option value="categories_not_in">None of selected categories in cart</option>--></optgroup>' +
305
  '<optgroup label="Customer Details (must be logged in)"><option value="users_in">User in list</option><option value="roles_in">User role in list</option><option value="shipping_countries_in">Shipping country in list</option></optgroup>' +
306
  '<optgroup label="Customer Email Domain (Eg: edu)"><option value="customer_email_tld">Email ends with</option></optgroup></select></label></div>' +
 
307
  '<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
308
  '<div id="user_div_' + count + '"><select id="cart_user_list_' + count + '" class="user_list selectpicker" multiple name="discount_rule[' + count + '][users_to_apply][]"></select></div>' +
309
  '<div id="product_div_' + count + '"><select id="cart_product_list_' + count + '" class="product_list selectpicker" multiple name="discount_rule[' + count + '][product_to_apply][]"></select></div>' +
@@ -320,6 +321,7 @@ function validateFields(){
320
  //'<optgroup label="Categories In Cart"><!-- At least one of these should present in the cart to apply. --><option value="categories_atleast_one">At least one category in cart</option><!-- These Category should not present in the cart to apply. --><option value="categories_not_in">None of selected categories in cart</option></optgroup>' +
321
  '<optgroup label="Customer Details (must be logged in)"><option disabled>User in list <b>' + pro_suffix + '</b></option><option disabled>User role in list <b>' + pro_suffix + '</b></option><option disabled>Shipping country in list <b>' + pro_suffix + '</b></option></optgroup>' +
322
  '<optgroup label="Customer Email Domain (Eg: edu)"><option disabled>Email ends with <b>' + pro_suffix + '</b></option></optgroup></select></label></div>' +
 
323
  '<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
324
  '<div id="user_div_' + count + '"><select id="cart_user_list_' + count + '" class="user_list selectpicker" multiple name="discount_rule[' + count + '][users_to_apply][]"></select></div>' +
325
  '<div id="product_div_' + count + '"><select id="cart_product_list_' + count + '" class="product_list selectpicker" multiple name="discount_rule[' + count + '][product_to_apply][]"></select></div>' +
304
  //'<optgroup label="Categories In Cart"><!-- At least one of these should present in the cart to apply. --><option value="categories_atleast_one">At least one category in cart</option><!-- These Category should not present in the cart to apply. --><!--<option value="categories_not_in">None of selected categories in cart</option>--></optgroup>' +
305
  '<optgroup label="Customer Details (must be logged in)"><option value="users_in">User in list</option><option value="roles_in">User role in list</option><option value="shipping_countries_in">Shipping country in list</option></optgroup>' +
306
  '<optgroup label="Customer Email Domain (Eg: edu)"><option value="customer_email_tld">Email ends with</option></optgroup></select></label></div>' +
307
+ '<optgroup label="Customer Billing Details"><option value="customer_billing_city">Billing city</option></optgroup></select></label></div>' +
308
  '<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
309
  '<div id="user_div_' + count + '"><select id="cart_user_list_' + count + '" class="user_list selectpicker" multiple name="discount_rule[' + count + '][users_to_apply][]"></select></div>' +
310
  '<div id="product_div_' + count + '"><select id="cart_product_list_' + count + '" class="product_list selectpicker" multiple name="discount_rule[' + count + '][product_to_apply][]"></select></div>' +
321
  //'<optgroup label="Categories In Cart"><!-- At least one of these should present in the cart to apply. --><option value="categories_atleast_one">At least one category in cart</option><!-- These Category should not present in the cart to apply. --><option value="categories_not_in">None of selected categories in cart</option></optgroup>' +
322
  '<optgroup label="Customer Details (must be logged in)"><option disabled>User in list <b>' + pro_suffix + '</b></option><option disabled>User role in list <b>' + pro_suffix + '</b></option><option disabled>Shipping country in list <b>' + pro_suffix + '</b></option></optgroup>' +
323
  '<optgroup label="Customer Email Domain (Eg: edu)"><option disabled>Email ends with <b>' + pro_suffix + '</b></option></optgroup></select></label></div>' +
324
+ '<optgroup label="Customer Billing Details"><option disabled>Billing city <b>' + pro_suffix + '</b></option></optgroup></select></label></div>' +
325
  '<div class="col-md-3 form-group"><label> Value<div id="general_' + count + '"><input type="text" name="discount_rule[' + count + '][option_value]"></div>' +
326
  '<div id="user_div_' + count + '"><select id="cart_user_list_' + count + '" class="user_list selectpicker" multiple name="discount_rule[' + count + '][users_to_apply][]"></select></div>' +
327
  '<div id="product_div_' + count + '"><select id="cart_product_list_' + count + '" class="product_list selectpicker" multiple name="discount_rule[' + count + '][product_to_apply][]"></select></div>' +
includes/cart-rules-3.php CHANGED
@@ -767,6 +767,43 @@ if (!class_exists('woo_dicount_rules_cartRules')) {
767
  }
768
  return false;
769
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  /*case 'categories_atleast_one':
771
  if(count($rule)){
772
  $w_categories = $this->getCartProductCaregories();
767
  }
768
  return false;
769
  break;
770
+
771
+ case 'customer_billing_city':
772
+ $rule = explode(',', $rule);
773
+ foreach($rule as $key => $r){
774
+ $rule[$key] = strtolower(trim($r));
775
+ }
776
+ $postData = $this->postData->get('post_data', '', 'raw');
777
+ $postDataArray = array();
778
+ if($postData != ''){
779
+ parse_str($postData, $postDataArray);
780
+ }
781
+ $postBillingEmail = $this->postData->get('billing_city', '', 'raw');
782
+ if($postBillingEmail != ''){
783
+ $postDataArray['billing_city'] = $postBillingEmail;
784
+ }
785
+ if(!get_current_user_id()){
786
+ $order_id = $this->postData->get('order-received', 0);
787
+ if($order_id){
788
+ $order = new WC_Order( $order_id);
789
+ $postDataArray['billing_city'] = $order->billing_city;
790
+ }
791
+ }
792
+ if(isset($postDataArray['billing_city']) && $postDataArray['billing_city'] != ''){
793
+ $billingCity = $postDataArray['billing_city'];
794
+ if(in_array(strtolower($billingCity), $rule)){
795
+ return true;
796
+ }
797
+ } else if(get_current_user_id()){
798
+ $billingCity = get_user_meta( get_current_user_id(), 'billing_city', true );
799
+ if($billingCity != '' && !empty($billingCity)){
800
+ if(in_array(strtolower($billingCity), $rule)){
801
+ return true;
802
+ }
803
+ }
804
+ }
805
+ return false;
806
+ break;
807
  /*case 'categories_atleast_one':
808
  if(count($rule)){
809
  $w_categories = $this->getCartProductCaregories();
includes/cart-rules.php CHANGED
@@ -768,6 +768,43 @@ if (!class_exists('woo_dicount_rules_cartRules')) {
768
  }
769
  return false;
770
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
771
  /*case 'categories_atleast_one':
772
  if(count($rule)){
773
  $w_categories = $this->getCartProductCaregories();
768
  }
769
  return false;
770
  break;
771
+
772
+ case 'customer_billing_city':
773
+ $rule = explode(',', $rule);
774
+ foreach($rule as $key => $r){
775
+ $rule[$key] = strtolower(trim($r));
776
+ }
777
+ $postData = $this->postData->get('post_data', '', 'raw');
778
+ $postDataArray = array();
779
+ if($postData != ''){
780
+ parse_str($postData, $postDataArray);
781
+ }
782
+ $postBillingEmail = $this->postData->get('billing_city', '', 'raw');
783
+ if($postBillingEmail != ''){
784
+ $postDataArray['billing_city'] = $postBillingEmail;
785
+ }
786
+ if(!get_current_user_id()){
787
+ $order_id = $this->postData->get('order-received', 0);
788
+ if($order_id){
789
+ $order = new WC_Order( $order_id);
790
+ $postDataArray['billing_city'] = $order->billing_city;
791
+ }
792
+ }
793
+ if(isset($postDataArray['billing_city']) && $postDataArray['billing_city'] != ''){
794
+ $billingCity = $postDataArray['billing_city'];
795
+ if(in_array(strtolower($billingCity), $rule)){
796
+ return true;
797
+ }
798
+ } else if(get_current_user_id()){
799
+ $billingCity = get_user_meta( get_current_user_id(), 'billing_city', true );
800
+ if($billingCity != '' && !empty($billingCity)){
801
+ if(in_array(strtolower($billingCity), $rule)){
802
+ return true;
803
+ }
804
+ }
805
+ }
806
+ return false;
807
+ break;
808
  /*case 'categories_atleast_one':
809
  if(count($rule)){
810
  $w_categories = $this->getCartProductCaregories();
includes/discount-base.php CHANGED
@@ -73,9 +73,11 @@ if (!class_exists('woo_dicount_rules_WooDiscountBase')) {
73
  public function addScriptInCheckoutPage(){
74
  $script = '<script type="text/javascript">
75
  jQuery( function( $ ) {
76
- $( document.body ).on( "blur", "input#billing_email", function() {
77
- $("select#billing_country").trigger("change");
78
- })
 
 
79
  });
80
  </script>';
81
  echo $script;
73
  public function addScriptInCheckoutPage(){
74
  $script = '<script type="text/javascript">
75
  jQuery( function( $ ) {
76
+ $(document).ready(function() {
77
+ $( document.body ).on( "blur", "input#billing_email", function() {
78
+ $("select#billing_country").trigger("change");
79
+ });
80
+ });
81
  });
82
  </script>';
83
  echo $script;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.8.1
7
- Stable tag: 1.4.16
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -111,6 +111,9 @@ More information could be found in the documentation
111
 
112
  == Changelog ==
113
 
 
 
 
114
  = 1.4.16 - 21/08/17 =
115
  * Fix - WooCommerce Products Carousel all in one compatibility issue
116
 
4
  Tags: woocommerce, ecommerce, discounts, coupons, promotion, campaigns, sales, price rules, advanced coupons, advanced discounts
5
  Requires at least: 4.4.1
6
  Tested up to: 4.8.1
7
+ Stable tag: 1.4.17
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
111
 
112
  == Changelog ==
113
 
114
+ = 1.4.17 - 07/09/17 =
115
+ * Fix – Cart rule based on billing city for pro version
116
+
117
  = 1.4.16 - 21/08/17 =
118
  * Fix - WooCommerce Products Carousel all in one compatibility issue
119
 
view/view-cart-rules.php CHANGED
@@ -277,6 +277,18 @@ if (empty($discount_rules)) {
277
  <?php } ?>
278
  </option>
279
  </optgroup>
 
 
 
 
 
 
 
 
 
 
 
 
280
  </select>
281
  </label>
282
  </div>
277
  <?php } ?>
278
  </option>
279
  </optgroup>
280
+ <optgroup label="Customer Billing Details">
281
+ <option
282
+ <?php if (!$pro) { ?> disabled <?php } else { ?> value="customer_billing_city" <?php
283
+ }
284
+ if ($type == 'customer_billing_city') { ?> selected=selected <?php } ?>>
285
+ <?php if (!$pro) { ?>
286
+ Billing city <b><?php echo $suffix; ?></b>
287
+ <?php } else { ?>
288
+ Billing city
289
+ <?php } ?>
290
+ </option>
291
+ </optgroup>
292
  </select>
293
  </label>
294
  </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.4.16
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.17
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Requires at least: 4.6.1