WooCommerce Extended Coupon Features - Version 1.0.1

Version Description

  • Don't add the coupon if Individual use only is checked and another coupon is already applied.
Download this release

Release Info

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

Code changes from version 1.0 to 1.0.1

Files changed (3) hide show
  1. assets/Thumbs.db +0 -0
  2. readme.txt +20 -9
  3. woocommerce-jos-autocoupon.php +10 -3
assets/Thumbs.db CHANGED
Binary file
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: 3.9.1
7
- Stable tag: 1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,27 +12,35 @@ Allow discounts to be automatically added to the WooCommerce cart when it's rest
12
 
13
  == Description ==
14
 
15
- "Jos - WooCommerce auto added coupons" allows you to select coupons that will automatically be added to
16
- the users cart if it's restrictions are met. The coupon will be removed when the restrictions are not met.
17
 
18
  The discount will be presented to the user by a descriptive text. No coupon code will be shown.
19
 
20
  No programming required.
21
 
22
- This plugin has been tested with WordPress 3.9.1 and WooCommerce 2.1.11. Also in combination with WPML.
23
 
24
- = How to create an automatically added coupon? =
 
 
25
 
26
- 1. Create a coupon through the 'Coupons' menu in WooCommerce. TIP: Name it auto_'whatever' so it will be easy to recognize the auto coupons
27
- 2. Setup the coupon as you'd normally would. Make sure you enter a description for the coupon and set usage restrictions
28
- 3. In the "Usage Restriction" tab, check the box "Auto coupon"
29
- 4. Voila! That's it
30
 
31
  == Installation ==
32
 
33
  1. Upload the plugin in the `/wp-content/plugins/` directory, or automatically install it through the 'New Plugin' menu in WordPress
34
  2. Activate the plugin through the 'Plugins' menu in WordPress
35
 
 
 
 
 
 
 
 
36
  == Frequently Asked Questions ==
37
 
38
  = Is the plugin translatable? =
@@ -49,6 +57,9 @@ Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
49
 
50
  == Changelog ==
51
 
 
 
 
52
  = 1.0 =
53
  * First version ever!
54
 
4
  Tags: woocommerce, coupons, discount
5
  Requires at least: 3.0.1
6
  Tested up to: 3.9.1
7
+ Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ "WooCommerce auto added coupons" allows you to select coupons that will automatically be added to
16
+ the users cart if it's restrictions are met. The coupon will be removed when the restrictions are no longer met.
17
 
18
  The discount will be presented to the user by a descriptive text. No coupon code will be shown.
19
 
20
  No programming required.
21
 
22
+ **Example**: Want to have a discount of $ 5.00 when the cart reaches $ 50.00 ?
23
 
24
+ 1. Create a coupon, let's name it *auto_50bucks* and enter a short description e.g. *$ 50.00 order discount*
25
+ 2. On the General tab: Select discount type *Cart discount*, and set the coupon amount to $ 5.00
26
+ 3. On the Usage restrictions tab: Set minimum spend to $ 50.00 and check the *Auto coupon*-box
27
 
28
+ Voila! The discount will be applied when the customer reaches $ 50.00.
29
+
30
+ This plugin has been tested with WordPress 3.9.1 and WooCommerce 2.1.11 and 2.1.12. Also in combination with WPML.
 
31
 
32
  == Installation ==
33
 
34
  1. Upload the plugin in the `/wp-content/plugins/` directory, or automatically install it through the 'New Plugin' menu in WordPress
35
  2. Activate the plugin through the 'Plugins' menu in WordPress
36
 
37
+ = How to create an automatically added coupon? =
38
+
39
+ 1. Create a coupon through the 'Coupons' menu in WooCommerce. TIP: Name it auto_'whatever' so it will be easy to recognize the auto coupons
40
+ 2. Setup the coupon as you'd normally would. Make sure you enter a description for the coupon and set usage restrictions
41
+ 3. In the "Usage Restriction" tab, check the box *Auto coupon*
42
+ 4. Voila! That's it
43
+
44
  == Frequently Asked Questions ==
45
 
46
  = Is the plugin translatable? =
57
 
58
  == Changelog ==
59
 
60
+ = 1.0.1 =
61
+ * Don't add the coupon if *Individual use only* is checked and another coupon is already applied.
62
+
63
  = 1.0 =
64
  * First version ever!
65
 
woocommerce-jos-autocoupon.php CHANGED
@@ -1,13 +1,20 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce auto added coupons
4
- * Plugin URI: none yet
5
  * Description: Automatically add certain coupons to the cart if it's conditions are met.
6
- * Version: 1.0
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
10
 
 
 
 
 
 
 
 
11
  defined('ABSPATH') or die();
12
 
13
  class WC_Jos_AutoCoupon_Controller{
@@ -105,7 +112,7 @@ class WC_Jos_AutoCoupon_Controller{
105
  foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
106
  if ( ! $woocommerce->cart->has_discount( $coupon_code ) ) {
107
  $coupon = new WC_Coupon($coupon_code);
108
- if ( $coupon->is_valid() ) {
109
  $woocommerce->cart->add_discount( $coupon_code );
110
  $this->overwrite_success_message( $coupon );
111
  }
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce auto added coupons
4
+ * Plugin URI: http://wordpress.org/plugins/woocommerce-auto-added-coupons
5
  * Description: Automatically add certain coupons to the cart if it's conditions are met.
6
+ * Version: 1.0.1
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
10
 
11
+ /*
12
+ Change history:
13
+ 1.0.1:
14
+ - Don't apply an autocoupon if the coupon is for individual_use and another coupon is already applied.
15
+
16
+ */
17
+
18
  defined('ABSPATH') or die();
19
 
20
  class WC_Jos_AutoCoupon_Controller{
112
  foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
113
  if ( ! $woocommerce->cart->has_discount( $coupon_code ) ) {
114
  $coupon = new WC_Coupon($coupon_code);
115
+ if ( $coupon->is_valid() && ( $coupon->individual_use != 'yes' || count($woocommerce->cart->applied_coupons) == 0 )) {
116
  $woocommerce->cart->add_discount( $coupon_code );
117
  $this->overwrite_success_message( $coupon );
118
  }