WooCommerce Extended Coupon Features - Version 1.1.5

Version Description

  • FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
  • Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon
Download this release

Release Info

Developer josk79
Plugin Icon 128x128 WooCommerce Extended Coupon Features
Version 1.1.5
Comparing to
See all releases

Code changes from version 1.1.4 to 1.1.5

Files changed (2) hide show
  1. readme.txt +6 -2
  2. woocommerce-jos-autocoupon.php +27 -14
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
4
  Tags: woocommerce, coupons, discount
5
  Requires at least: 3.0.1
6
  Tested up to: 4.1.1
7
- Stable tag: 1.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -69,9 +69,13 @@ Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
69
  1. Simply use the WooCommerce Coupons menu to make a coupon an "auto coupon".
70
 
71
  == Changelog ==
 
 
 
 
72
  = 1.1.4 =
73
  * Translation support through .mo / .po files
74
- * Included translations: Dutch, German, Spanish
75
 
76
  = 1.1.3.1 =
77
  * FIX: Apply auto coupon if discount is 0.00 and free shipping is ticked
4
  Tags: woocommerce, coupons, discount
5
  Requires at least: 3.0.1
6
  Tested up to: 4.1.1
7
+ Stable tag: 1.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
69
  1. Simply use the WooCommerce Coupons menu to make a coupon an "auto coupon".
70
 
71
  == Changelog ==
72
+ = 1.1.5 =
73
+ * FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
74
+ * Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes (Thanks to ircary)
75
+
76
  = 1.1.4 =
77
  * Translation support through .mo / .po files
78
+ * Included translations: Dutch, German, Spanish (Thanks to stephan.sperling for the german translation)
79
 
80
  = 1.1.3.1 =
81
  * FIX: Apply auto coupon if discount is 0.00 and free shipping is ticked
woocommerce-jos-autocoupon.php CHANGED
@@ -3,13 +3,16 @@
3
  * Plugin Name: WooCommerce auto added coupons
4
  * Plugin URI: http://wordpress.org/plugins/woocommerce-auto-added-coupons
5
  * Description: Allow discounts to be automatically added to the cart when it's restrictions are met. Allow applying coupons via an url.
6
- * Version: 1.1.4
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
10
 
11
  /*
12
  Change history:
 
 
 
13
  1.1.4:
14
  - Translation support through .mo / .po files
15
  1.1.3.1:
@@ -117,21 +120,24 @@ class WC_Jos_AutoCoupon_Controller{
117
  */
118
  function coupon_html( $originaltext, $coupon ) {
119
  if ( $this->is_auto_coupon($coupon) ) {
120
- if ( ! empty(WC()->cart->coupon_discount_amounts[ $coupon->code ]) ) {
121
- $discount_html = '-' . wc_price( WC()->cart->coupon_discount_amounts[ $coupon->code ] );
122
- $value[] = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_html, $coupon );
123
 
124
- if ( $coupon->enable_free_shipping() ) {
125
- $value[] = __( 'Free shipping coupon', 'woocommerce' );
126
- }
 
 
127
 
128
- return implode(', ', array_filter($value)); //Remove empty array elements
129
- } else {
130
- $discount_html = '';
131
- }
132
- return $discount_html;
133
- } else
 
 
134
  return $originaltext;
 
135
  }
136
 
137
  /**
@@ -267,7 +273,14 @@ class WC_Jos_AutoCoupon_Controller{
267
  'posts_per_page' => -1,
268
  'post_type' => 'shop_coupon',
269
  'post_status' => 'publish',
270
- 'orderby' => 'title'
 
 
 
 
 
 
 
271
  );
272
 
273
  $query = new WP_Query($query_args);
3
  * Plugin Name: WooCommerce auto added coupons
4
  * Plugin URI: http://wordpress.org/plugins/woocommerce-auto-added-coupons
5
  * Description: Allow discounts to be automatically added to the cart when it's restrictions are met. Allow applying coupons via an url.
6
+ * Version: 1.1.5
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
10
 
11
  /*
12
  Change history:
13
+ 1.1.5:
14
+ - FIX: Cart total discount amount showing wrong discount value in newer WooCommerce versions (tax)
15
+ - Performance: get_all_auto_coupons select only where meta woocommerce_jos_autocoupon = yes
16
  1.1.4:
17
  - Translation support through .mo / .po files
18
  1.1.3.1:
120
  */
121
  function coupon_html( $originaltext, $coupon ) {
122
  if ( $this->is_auto_coupon($coupon) ) {
123
+ $value = array();
 
 
124
 
125
+ if ( $amount = WC()->cart->get_coupon_discount_amount( $coupon->code, WC()->cart->display_cart_ex_tax ) ) {
126
+ $discount_html = '-' . wc_price( $amount );
127
+ } else {
128
+ $discount_html = '';
129
+ }
130
 
131
+ $value[] = apply_filters( 'woocommerce_coupon_discount_amount_html', $discount_html, $coupon );
132
+
133
+ if ( $coupon->enable_free_shipping() ) {
134
+ $value[] = __( 'Free shipping coupon', 'woocommerce' );
135
+ }
136
+
137
+ return implode(', ', array_filter($value)); //Remove empty array elements
138
+ } else {
139
  return $originaltext;
140
+ }
141
  }
142
 
143
  /**
273
  'posts_per_page' => -1,
274
  'post_type' => 'shop_coupon',
275
  'post_status' => 'publish',
276
+ 'orderby' => 'title',
277
+ 'meta_query' => array(
278
+ array(
279
+ 'key' => 'woocommerce-jos-autocoupon',
280
+ 'value' => 'yes',
281
+ 'compare' => '=',
282
+ ),
283
+ )
284
  );
285
 
286
  $query = new WP_Query($query_args);