WooCommerce Extended Coupon Features - Version 2.2.3

Version Description

  • (PRO) FEATURE: Allow discount on cart with excluded items
  • (PRO) FEATURE: Free products!
  • FEATURE: Allow coupon in cart even if minimum spend not reached
  • FEATURE: New coupon feature: Minimum / maximum price subtotal of matching products in the cart
  • COSMETIC: Admin Extended coupon features in multiple tabs
  • FIX: Create session cookie if no session was initialized when applying coupon by url
  • TWEAK: Auto coupon: Use woocommerce_after_calculate_totals hook for update_matched_autocoupons
  • API: New function: $wjecf_extended_coupon_features->get_quantity_of_matching_products( $coupon )
  • API: New function: $wjecf_extended_coupon_features->get_subtotal_of_matching_products( $coupon )
Download this release

Release Info

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

Code changes from version 2.2.1 to 2.2.3

assets/screenshot-1.png CHANGED
Binary file
assets/screenshot-2.png ADDED
Binary file
assets/screenshot-3.png ADDED
Binary file
assets/screenshot-4.png ADDED
Binary file
includes/wjecf-autocoupon.php CHANGED
@@ -18,19 +18,17 @@ class WC_Jos_AutoCoupon_Controller{
18
  if ( ! class_exists('WC_Coupon') ) {
19
  return;
20
  }
21
-
22
  //Admin hooks
23
  add_action( 'admin_init', array( &$this, 'admin_init' ) );
24
-
25
- //Frontend hooks
26
- //add_action( 'woocommerce_cart_updated', array( &$this, 'update_matched_autocoupons' ) ); //experiment 2.1.0-b1
27
- add_action( 'woocommerce_check_cart_items', array( &$this, 'update_matched_autocoupons' ) , 0 ); //Remove coupon before WC does it and shows a message
28
- add_action( 'woocommerce_before_cart_totals', array( &$this, 'update_matched_autocoupons' ) ); //When cart is updated after changing shipping method
29
- add_action( 'woocommerce_review_order_before_cart_contents', array( &$this, 'update_matched_autocoupons' ) ); //When cart is updated after changing shipping or payment method
30
-
31
  //Last check for coupons with restricted_emails
32
  add_action( 'woocommerce_checkout_update_order_review', array( $this, 'fetch_billing_email' ), 10 ); // AJAX One page checkout
33
 
 
34
  add_filter('woocommerce_cart_totals_coupon_label', array( &$this, 'coupon_label' ), 10, 2 );
35
  add_filter('woocommerce_cart_totals_coupon_html', array( &$this, 'coupon_html' ), 10, 2 );
36
 
@@ -45,15 +43,15 @@ class WC_Jos_AutoCoupon_Controller{
45
 
46
  /* ADMIN HOOKS */
47
  public function admin_init() {
48
- add_action( 'wjecf_woocommerce_coupon_options_extended_features', array( $this, 'admin_coupon_options_extended_features' ), 20, 0 );
49
  add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
50
  }
51
 
52
- public function admin_coupon_options_extended_features() {
53
 
54
  //=============================
55
  //Title
56
- echo "<h3 style='display:inline'>" . esc_html( __( 'Auto coupon', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
57
 
58
 
59
  //=============================
@@ -99,7 +97,9 @@ class WC_Jos_AutoCoupon_Controller{
99
 
100
  /* FRONTEND HOOKS */
101
 
102
- //Inhibit redirect to cart when apply_coupon supplied
 
 
103
  public function option_woocommerce_cart_redirect_after_add ( $value ) {
104
  if ( ! $this->_executed_coupon_by_url && isset( $_GET['apply_coupon'] ) ) {
105
  $value = 'no';
@@ -107,19 +107,24 @@ class WC_Jos_AutoCoupon_Controller{
107
  return $value;
108
  }
109
 
110
- /**
111
- * Add coupon through url
112
- */
113
  public function coupon_by_url() {
114
- if (! $this->_executed_coupon_by_url && isset($_GET['apply_coupon'])) {
115
- $this->_executed_coupon_by_url = true;
116
- $split = explode( ",", $_GET['apply_coupon'] );
117
-
118
- global $woocommerce;
119
- foreach ( $split as $coupon_code ) {
120
- $woocommerce->cart->add_discount( $coupon_code );
121
- }
122
- }
 
 
 
 
 
123
  }
124
 
125
  /**
@@ -171,20 +176,19 @@ class WC_Jos_AutoCoupon_Controller{
171
  * @return void
172
  */
173
  function update_matched_autocoupons() {
174
- //$this->log ( 'update_matched_autocoupons' );
175
  if ( $this->_check_already_performed ) {
176
  //$this->log ( 'check already performed' );
177
  return;
178
  }
 
179
 
180
- global $woocommerce;
181
  $calc_needed = $this->remove_unmatched_autocoupons();
182
  foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
183
- if ( ! $woocommerce->cart->has_discount( $coupon_code ) ) {
184
- $coupon = new WC_Coupon($coupon_code);
185
- if ( $this->coupon_can_be_applied($coupon) && $this->coupon_has_a_value( $coupon ) ) {
186
  //$this->log( sprintf( "Applying %s", $coupon_code ) );
187
- $woocommerce->cart->add_discount( $coupon_code );
188
  $calc_needed = false; //Already done by adding the discount
189
  $apply_silently = get_post_meta( $coupon->id, '_wjecf_apply_silently', true ) == 'yes';
190
  $this->overwrite_success_message( $coupon, $apply_silently );
@@ -193,10 +197,9 @@ class WC_Jos_AutoCoupon_Controller{
193
  }
194
  }
195
  }
196
- $this->_check_already_performed = true;
197
 
198
  if ( $calc_needed ) {
199
- $woocommerce->cart->calculate_totals();
200
  }
201
 
202
  }
@@ -206,16 +209,18 @@ class WC_Jos_AutoCoupon_Controller{
206
  * @return bool
207
  */
208
  function coupon_can_be_applied($coupon) {
209
- global $woocommerce;
210
-
211
  $can_be_applied = true;
212
 
213
  //Test validity
214
  if ( ! $coupon->is_valid() ) {
215
  $can_be_applied = false;
 
 
 
 
216
  }
217
  //Test individual use
218
- elseif ( $coupon->individual_use == 'yes' && count( $woocommerce->cart->applied_coupons ) != 0 ) {
219
  $can_be_applied = false;
220
  }
221
  //Test restricted emails
@@ -228,7 +233,6 @@ class WC_Jos_AutoCoupon_Controller{
228
  $can_be_applied = false;
229
  }
230
  }
231
-
232
  return apply_filters( 'wjecf_coupon_can_be_applied', $can_be_applied, $coupon );
233
 
234
  }
@@ -438,9 +442,10 @@ class WC_Jos_AutoCoupon_Controller{
438
  }
439
  return $this->_autocoupon_codes;
440
  }
441
-
442
  //FOR DEBUGGING ONLY
443
  private function log ( $string ) {
 
444
  // file_put_contents ( "/lamp/www/logfile.log", date("Y-m-d | h:i:sa") . " " . current_filter() . ": " . $string . "\n" , FILE_APPEND );
445
  }
446
  }
18
  if ( ! class_exists('WC_Coupon') ) {
19
  return;
20
  }
21
+
22
  //Admin hooks
23
  add_action( 'admin_init', array( &$this, 'admin_init' ) );
24
+
25
+ //Frontend hooks - logic
26
+ add_action( 'woocommerce_after_calculate_totals', array( &$this, 'update_matched_autocoupons' ) );
27
+ add_action( 'woocommerce_check_cart_items', array( &$this, 'update_matched_autocoupons' ) , 0 ); //Remove coupon before WC does it and shows a message
 
 
 
28
  //Last check for coupons with restricted_emails
29
  add_action( 'woocommerce_checkout_update_order_review', array( $this, 'fetch_billing_email' ), 10 ); // AJAX One page checkout
30
 
31
+ //Frontend hooks - visualisation
32
  add_filter('woocommerce_cart_totals_coupon_label', array( &$this, 'coupon_label' ), 10, 2 );
33
  add_filter('woocommerce_cart_totals_coupon_html', array( &$this, 'coupon_html' ), 10, 2 );
34
 
43
 
44
  /* ADMIN HOOKS */
45
  public function admin_init() {
46
+ add_action( 'wjecf_woocommerce_coupon_options_extended_features', array( $this, 'admin_coupon_options_extended_features' ), 20, 2 );
47
  add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
48
  }
49
 
50
+ public function admin_coupon_options_extended_features( $thepostid, $post ) {
51
 
52
  //=============================
53
  //Title
54
+ echo "<h3>" . esc_html( __( 'Auto coupon', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
55
 
56
 
57
  //=============================
97
 
98
  /* FRONTEND HOOKS */
99
 
100
+ /**
101
+ ** Inhibit redirect to cart when apply_coupon supplied
102
+ */
103
  public function option_woocommerce_cart_redirect_after_add ( $value ) {
104
  if ( ! $this->_executed_coupon_by_url && isset( $_GET['apply_coupon'] ) ) {
105
  $value = 'no';
107
  return $value;
108
  }
109
 
110
+ /**
111
+ * Add coupon through url
112
+ */
113
  public function coupon_by_url() {
114
+ if ( ! $this->_executed_coupon_by_url && isset( $_GET['apply_coupon'] ) ) {
115
+ $this->_executed_coupon_by_url = true;
116
+ $split = explode( ",", $_GET['apply_coupon'] );
117
+ //2.2.2 Make sure a session cookie is set
118
+ if( ! WC()->session->has_session() )
119
+ {
120
+ WC()->session->set_customer_session_cookie( true );
121
+ }
122
+
123
+ $cart = WC()->cart;
124
+ foreach ( $split as $coupon_code ) {
125
+ $cart->add_discount( $coupon_code );
126
+ }
127
+ }
128
  }
129
 
130
  /**
176
  * @return void
177
  */
178
  function update_matched_autocoupons() {
 
179
  if ( $this->_check_already_performed ) {
180
  //$this->log ( 'check already performed' );
181
  return;
182
  }
183
+ $this->_check_already_performed = true;
184
 
 
185
  $calc_needed = $this->remove_unmatched_autocoupons();
186
  foreach ( $this->get_all_auto_coupons() as $coupon_code ) {
187
+ if ( ! WC()->cart->has_discount( $coupon_code ) ) {
188
+ $coupon = new WC_Coupon( $coupon_code );
189
+ if ( $this->coupon_can_be_applied( $coupon ) && $this->coupon_has_a_value( $coupon ) ) {
190
  //$this->log( sprintf( "Applying %s", $coupon_code ) );
191
+ WC()->cart->add_discount( $coupon_code );
192
  $calc_needed = false; //Already done by adding the discount
193
  $apply_silently = get_post_meta( $coupon->id, '_wjecf_apply_silently', true ) == 'yes';
194
  $this->overwrite_success_message( $coupon, $apply_silently );
197
  }
198
  }
199
  }
 
200
 
201
  if ( $calc_needed ) {
202
+ WC()->cart->calculate_totals();
203
  }
204
 
205
  }
209
  * @return bool
210
  */
211
  function coupon_can_be_applied($coupon) {
 
 
212
  $can_be_applied = true;
213
 
214
  //Test validity
215
  if ( ! $coupon->is_valid() ) {
216
  $can_be_applied = false;
217
+ //$this->log( "Not valid. ");
218
+ //echo "<pre>";
219
+ //print_r (WC()->cart->get_cart());
220
+ //echo "</pre>";
221
  }
222
  //Test individual use
223
+ elseif ( $coupon->individual_use == 'yes' && count( WC()->cart->applied_coupons ) != 0 ) {
224
  $can_be_applied = false;
225
  }
226
  //Test restricted emails
233
  $can_be_applied = false;
234
  }
235
  }
 
236
  return apply_filters( 'wjecf_coupon_can_be_applied', $can_be_applied, $coupon );
237
 
238
  }
442
  }
443
  return $this->_autocoupon_codes;
444
  }
445
+
446
  //FOR DEBUGGING ONLY
447
  private function log ( $string ) {
448
+ error_log($string);
449
  // file_put_contents ( "/lamp/www/logfile.log", date("Y-m-d | h:i:sa") . " " . current_filter() . ": " . $string . "\n" , FILE_APPEND );
450
  }
451
  }
includes/wjecf-coupon-extensions.php CHANGED
@@ -5,6 +5,7 @@ defined('ABSPATH') or die();
5
 
6
  class WC_Jos_Extended_Coupon_Features_Controller {
7
  private $options = false;
 
8
 
9
  public function __construct() {
10
  add_action('init', array( &$this, 'controller_init' ));
@@ -22,6 +23,8 @@ class WC_Jos_Extended_Coupon_Features_Controller {
22
 
23
  //Frontend hooks
24
  add_filter('woocommerce_coupon_is_valid', array( &$this, 'coupon_is_valid' ), 10, 2 );
 
 
25
  }
26
 
27
  public function init_options() {
@@ -68,83 +71,97 @@ class WC_Jos_Extended_Coupon_Features_Controller {
68
  //Admin hooks
69
  add_filter( 'woocommerce_coupon_data_tabs', array( $this, 'admin_coupon_options_tabs' ), 10, 1);
70
  add_action( 'woocommerce_coupon_data_panels', array( $this, 'admin_coupon_options_panels' ), 10, 0 );
71
-
72
- add_action( 'wjecf_woocommerce_coupon_options_extended_features', array( $this, 'admin_coupon_options_extended_features' ), 10, 0 );
73
  add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
 
 
 
 
 
74
  }
75
 
76
  //Add panels to the coupon option page
77
  public function admin_coupon_options_panels() {
 
 
78
  ?>
79
- <div id="wjecf_extended_features_coupon_data" class="panel woocommerce_options_panel">
80
- <h3 style='display:inline'><?php echo esc_html( __( 'Extended Coupon Features', 'woocommerce-jos-autocoupon' ) ); ?></h3>
81
-
82
  <?php
83
  //Feed the panel with options
84
- do_action( 'wjecf_woocommerce_coupon_options_extended_features' );
 
85
  ?>
86
-
87
- <h3><?php _e( 'Do you find WooCommerce Extended Coupon Features useful?', 'woocommerce-jos-autocoupon'); ?></h3>
88
- <p class="form-field"><label for="wjecf_donate_button"><?php
89
- echo esc_html( __('Express your gratitude', 'woocommerce-jos-autocoupon' ) );
90
- ?></label>
91
- <a id="wjecf_donate_button" href="<?php echo $this->get_donate_url(); ?>" target="_blank" class="button button-primary">
 
 
 
92
  <?php
93
- echo esc_html( __('Donate to the developer', 'woocommerce-jos-autocoupon' ) );
94
- ?></a>
95
- </p>
 
 
96
  </div>
97
  <?php
98
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  //Add tabs to the coupon option page
102
  public function admin_coupon_options_tabs( $tabs ) {
103
 
104
- $tabs['extended_features'] = array(
105
- 'label' => __( 'Extended features', 'woocommerce-jos-autocoupon' ),
106
- 'target' => 'wjecf_extended_features_coupon_data',
107
- 'class' => 'wjecf_extended_features_coupon_data',
 
 
 
 
 
 
 
 
 
 
 
 
108
  );
 
109
  return $tabs;
110
  }
111
 
112
  //Tab 'extended features'
113
- public function admin_coupon_options_extended_features() {
114
- global $thepostid, $post;
115
- $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
116
-
117
  //See WooCommerce class-wc-meta-box-coupon-data.php function ouput
118
 
119
-
120
  //=============================
121
- // AND in stead of OR the products
122
  woocommerce_wp_checkbox( array(
123
  'id' => '_wjecf_products_and',
124
  'label' => __( 'AND Products (not OR)', 'woocommerce-jos-autocoupon' ),
125
  'description' => __( 'Check this box if ALL of the products (see tab \'usage restriction\') must be in the cart to use this coupon (in stead of only one of the products).', 'woocommerce-jos-autocoupon' )
126
  ) );
127
-
128
- // Minimum quantity of matching products (product/category)
129
- woocommerce_wp_text_input( array(
130
- 'id' => '_wjecf_min_matching_product_qty',
131
- 'label' => __( 'Minimum quantity of matching products', 'woocommerce-jos-autocoupon' ),
132
- 'placeholder' => __( 'No minimum', 'woocommerce' ),
133
- 'description' => __( 'Minimum quantity of the products that match the given product or category restrictions (see tab \'usage restriction\'). If no product or category restrictions are specified, the total number of products is used.', 'woocommerce-jos-autocoupon' ),
134
- 'data_type' => 'decimal',
135
- 'desc_tip' => true
136
- ) );
137
-
138
- // Minimum quantity of matching products (product/category)
139
- woocommerce_wp_text_input( array(
140
- 'id' => '_wjecf_max_matching_product_qty',
141
- 'label' => __( 'Maximum quantity of matching products', 'woocommerce-jos-autocoupon' ),
142
- 'placeholder' => __( 'No maximum', 'woocommerce' ),
143
- 'description' => __( 'Maximum quantity of the products that match the given product or category restrictions (see tab \'usage restriction\'). If no product or category restrictions are specified, the total number of products is used.', 'woocommerce-jos-autocoupon' ),
144
- 'data_type' => 'decimal',
145
- 'desc_tip' => true
146
- ) );
147
-
148
  //=============================
149
  //Trick to show AND or OR next to the product_ids field
150
  $label_and = __( '(AND)', 'woocommerce-jos-autocoupon' );
@@ -162,9 +179,53 @@ class WC_Jos_Extended_Coupon_Features_Controller {
162
  //Append AND/OR to the product_ids label
163
  jQuery(".form-field:has('[name=\"product_ids\"]') label").append( ' <strong><span id="wjecf_products_and_label"><?php echo esc_html( $label ); ?></span></strong>' );
164
  </script>
165
- <?php //End of the AND/OR trick
166
 
 
 
 
 
 
 
 
 
 
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  //=============================
169
  // Shipping methods
170
  ?>
@@ -198,11 +259,13 @@ class WC_Jos_Extended_Coupon_Features_Controller {
198
  ?>
199
  </select> <img class="help_tip" data-tip='<?php _e( 'One of these payment methods must be selected in order for this coupon to be valid.', 'woocommerce-jos-autocoupon' ); ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
200
  <?php
 
 
 
201
 
202
-
203
  //=============================
204
  //Title: "CUSTOMER RESTRICTIONS"
205
- echo "<h3 style='display:inline'>" . esc_html( __( 'Customer restrictions', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
206
  echo "<p><span class='description'>" . __( 'If both a customer and a role restriction are supplied, matching either one of them will suffice.' , 'woocommerce-jos-autocoupon' ) . "</span></p>\n";
207
 
208
  //=============================
@@ -269,17 +332,39 @@ class WC_Jos_Extended_Coupon_Features_Controller {
269
  ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
270
  <?php
271
  }
272
-
 
 
 
 
 
 
 
 
 
 
 
273
  public function process_shop_coupon_meta( $post_id, $post ) {
274
  $wjecf_min_matching_product_qty = isset( $_POST['_wjecf_min_matching_product_qty'] ) ? $_POST['_wjecf_min_matching_product_qty'] : '';
275
  update_post_meta( $post_id, '_wjecf_min_matching_product_qty', $wjecf_min_matching_product_qty );
276
 
277
  $wjecf_max_matching_product_qty = isset( $_POST['_wjecf_max_matching_product_qty'] ) ? $_POST['_wjecf_max_matching_product_qty'] : '';
278
  update_post_meta( $post_id, '_wjecf_max_matching_product_qty', $wjecf_max_matching_product_qty );
 
 
 
 
279
 
 
 
 
280
  $wjecf_products_and = isset( $_POST['_wjecf_products_and'] ) ? 'yes' : 'no';
281
  update_post_meta( $post_id, '_wjecf_products_and', $wjecf_products_and );
282
 
 
 
 
 
283
  $wjecf_shipping_methods = isset( $_POST['wjecf_shipping_methods'] ) ? $_POST['wjecf_shipping_methods'] : '';
284
  update_post_meta( $post_id, '_wjecf_shipping_methods', $wjecf_shipping_methods );
285
 
@@ -295,11 +380,35 @@ class WC_Jos_Extended_Coupon_Features_Controller {
295
  $wjecf_excluded_customer_roles = isset( $_POST['wjecf_excluded_customer_roles'] ) ? $_POST['wjecf_excluded_customer_roles'] : '';
296
  update_post_meta( $post_id, '_wjecf_excluded_customer_roles', $wjecf_excluded_customer_roles );
297
 
298
- }
299
 
300
  /* FRONTEND HOOKS */
301
 
302
- /* Extra validation rules for coupons */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  function coupon_is_valid ( $valid, $coupon ) {
304
  //Not valid? Then it will never validate, so get out of here
305
  if ( ! $valid ) {
@@ -333,22 +442,29 @@ class WC_Jos_Extended_Coupon_Features_Controller {
333
  // If coupon contains either a product OR category exclusion filter: the item will NOT be counted if it matches either one of them
334
  // If sale items are excluded by the coupon: the item will NOT be counted if it is a sale item
335
  // If no filter exist, all items will be counted
 
 
 
 
336
  $min_matching_product_qty = intval(get_post_meta( $coupon->id, '_wjecf_min_matching_product_qty', true ));
337
  $max_matching_product_qty = intval(get_post_meta( $coupon->id, '_wjecf_max_matching_product_qty', true ));
338
- if ( $min_matching_product_qty > 0 || $max_matching_product_qty > 0 ) {
339
  //Count the products
340
- $qty = 0;
341
- foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
342
- $_product = $cart_item['data'];
343
- if ($this->coupon_is_valid_for_product( $coupon, $_product )) {
344
- $qty += $cart_item['quantity'];
345
- }
346
- }
347
- //Validate range
348
  if ($min_matching_product_qty > 0 && $qty < $min_matching_product_qty) return false;
349
  if ($max_matching_product_qty > 0 && $qty > $max_matching_product_qty) return false;
 
350
  }
351
 
 
 
 
 
 
 
 
 
 
352
 
353
  //============================
354
  //Test restricted shipping methods
@@ -399,87 +515,113 @@ class WC_Jos_Extended_Coupon_Features_Controller {
399
  return false;
400
  }
401
  }
402
-
 
 
 
 
 
 
 
403
  return true;
404
  }
405
-
406
-
407
-
408
- //Test if coupon is valid for the product
409
- // (this function is used to count the quantity of matching products)
410
- private function coupon_is_valid_for_product( $coupon, $product, $values = array() ) {
411
- //===================================================================
412
- //This is almost a duplicate of function is_valid_for_product in WooCommerce class-wc-coupon.php
413
- //The only differences are:
414
- // - I removed the verification for fixed_product or percent_product
415
- // - I replaced $this with $coupon
416
- //===================================================================
417
-
418
- //if ( ! $this->is_type( array( 'fixed_product', 'percent_product' ) ) ) {
419
- // return apply_filters( 'woocommerce_coupon_is_valid_for_product', false, $product, $this, $values );
420
- //}
421
 
422
- $valid = false;
423
- $product_cats = wp_get_post_terms( $product->id, 'product_cat', array( "fields" => "ids" ) );
 
 
 
 
424
 
425
- // Specific products get the discount
426
- if ( sizeof( $coupon->product_ids ) > 0 ) {
427
- if ( in_array( $product->id, $coupon->product_ids ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $coupon->product_ids ) ) || in_array( $product->get_parent(), $coupon->product_ids ) ) {
428
- $valid = true;
429
- }
430
- }
431
 
432
- // Category discounts
433
- if ( sizeof( $coupon->product_categories ) > 0 ) {
434
- if ( sizeof( array_intersect( $product_cats, $coupon->product_categories ) ) > 0 ) {
435
- $valid = true;
436
- }
437
  }
438
 
439
- if ( ! sizeof( $coupon->product_ids ) && ! sizeof( $coupon->product_categories ) ) {
440
- // No product ids - all items discounted
441
- $valid = true;
442
- }
443
 
444
- // Specific product ID's excluded from the discount
445
- if ( sizeof( $coupon->exclude_product_ids ) > 0 ) {
446
- if ( in_array( $product->id, $coupon->exclude_product_ids ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $coupon->exclude_product_ids ) ) || in_array( $product->get_parent(), $coupon->exclude_product_ids ) ) {
447
- $valid = false;
448
- }
449
- }
450
 
451
- // Specific categories excluded from the discount
452
- if ( sizeof( $coupon->exclude_product_categories ) > 0 ) {
453
- if ( sizeof( array_intersect( $product_cats, $coupon->exclude_product_categories ) ) > 0 ) {
454
- $valid = false;
 
 
 
 
 
 
 
 
 
 
455
  }
456
  }
 
 
457
 
458
- // Sale Items excluded from discount
459
- if ( $coupon->exclude_sale_items == 'yes' ) {
460
- $product_ids_on_sale = wc_get_product_ids_on_sale();
461
-
462
- if ( isset( $product->variation_id ) ) {
463
- if ( in_array( $product->variation_id, $product_ids_on_sale, true ) ) {
464
- $valid = false;
465
- }
466
- } elseif ( in_array( $product->id, $product_ids_on_sale, true ) ) {
467
- $valid = false;
 
 
 
468
  }
469
  }
 
 
470
 
471
- return apply_filters( 'woocommerce_coupon_is_valid_for_product', $valid, $product, $coupon, $values );
 
 
 
 
 
 
 
 
 
 
 
472
  }
473
 
474
 
475
 
476
- //
 
 
 
 
 
 
 
 
 
 
 
 
477
 
478
- /**
479
- * Get array of the selected shipping methods ids.
480
- * @param int $coupon_id The coupon id
481
- * @return array Id's of the shipping methods or an empty array.
482
- */
483
  private function get_coupon_shipping_method_ids($coupon_id) {
484
  $v = get_post_meta( $coupon_id, '_wjecf_shipping_methods', true );
485
  if ($v == '') {
@@ -547,6 +689,11 @@ class WC_Jos_Extended_Coupon_Features_Controller {
547
 
548
  return $v;
549
  }
 
 
 
 
 
550
 
551
  public static function get_donate_url() {
552
  return "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
5
 
6
  class WC_Jos_Extended_Coupon_Features_Controller {
7
  private $options = false;
8
+
9
 
10
  public function __construct() {
11
  add_action('init', array( &$this, 'controller_init' ));
23
 
24
  //Frontend hooks
25
  add_filter('woocommerce_coupon_is_valid', array( &$this, 'coupon_is_valid' ), 10, 2 );
26
+ add_action('woocommerce_coupon_loaded', array( $this, 'woocommerce_coupon_loaded' ), 10, 1);
27
+ add_filter('woocommerce_coupon_get_discount_amount', array( $this, 'woocommerce_coupon_get_discount_amount' ), 10, 5);
28
  }
29
 
30
  public function init_options() {
71
  //Admin hooks
72
  add_filter( 'woocommerce_coupon_data_tabs', array( $this, 'admin_coupon_options_tabs' ), 10, 1);
73
  add_action( 'woocommerce_coupon_data_panels', array( $this, 'admin_coupon_options_panels' ), 10, 0 );
 
 
74
  add_action( 'woocommerce_process_shop_coupon_meta', array( $this, 'process_shop_coupon_meta' ), 10, 2 );
75
+
76
+ add_action( 'wjecf_coupon_metabox_products', array( $this, 'admin_coupon_metabox_products' ), 10, 2 );
77
+ add_action( 'wjecf_coupon_metabox_checkout', array( $this, 'admin_coupon_metabox_checkout' ), 10, 2 );
78
+ add_action( 'wjecf_coupon_metabox_customer', array( $this, 'admin_coupon_metabox_customer' ), 10, 2 );
79
+ add_action( 'wjecf_coupon_metabox_misc', array( $this, 'admin_coupon_metabox_misc' ), 10, 2 );
80
  }
81
 
82
  //Add panels to the coupon option page
83
  public function admin_coupon_options_panels() {
84
+ global $thepostid, $post;
85
+ $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
86
  ?>
87
+ <div id="wjecf_coupondata_products" class="panel woocommerce_options_panel">
 
 
88
  <?php
89
  //Feed the panel with options
90
+ do_action( 'wjecf_coupon_metabox_products', $thepostid, $post );
91
+ $this->admin_coupon_data_footer();
92
  ?>
93
+ </div>
94
+ <div id="wjecf_coupondata_checkout" class="panel woocommerce_options_panel">
95
+ <?php
96
+ do_action( 'wjecf_coupon_metabox_checkout', $thepostid, $post );
97
+ do_action( 'wjecf_coupon_metabox_customer', $thepostid, $post );
98
+ $this->admin_coupon_data_footer();
99
+ ?>
100
+ </div>
101
+ <div id="wjecf_coupondata_misc" class="panel woocommerce_options_panel">
102
  <?php
103
+ //Allow other classes to inject options
104
+ do_action( 'wjecf_woocommerce_coupon_options_extended_features', $thepostid, $post );
105
+ do_action( 'wjecf_coupon_metabox_misc', $thepostid, $post );
106
+ $this->admin_coupon_data_footer();
107
+ ?>
108
  </div>
109
  <?php
110
+ }
111
+ private function admin_coupon_data_footer() {
112
+ if ( ! $this->is_pro() ) {
113
+ ?>
114
+ <h3><?php _e( 'Do you find WooCommerce Extended Coupon Features useful?', 'woocommerce-jos-autocoupon'); ?></h3>
115
+ <p class="form-field"><label for="wjecf_donate_button"><?php
116
+ echo esc_html( __('Express your gratitude', 'woocommerce-jos-autocoupon' ) );
117
+ ?></label>
118
+ <a id="wjecf_donate_button" href="<?php echo $this->get_donate_url(); ?>" target="_blank" class="button button-primary">
119
+ <?php
120
+ echo esc_html( __('Donate to the developer', 'woocommerce-jos-autocoupon' ) );
121
+ ?></a><br>
122
+ Or get the PRO version at <a href="http://www.soft79.nl" target="_blank">www.soft79.nl</a>.
123
+ </p>
124
+ <?php
125
+ }
126
  }
127
 
128
  //Add tabs to the coupon option page
129
  public function admin_coupon_options_tabs( $tabs ) {
130
 
131
+ $tabs['extended_features_products'] = array(
132
+ 'label' => __( 'Products', 'woocommerce-jos-autocoupon' ),
133
+ 'target' => 'wjecf_coupondata_products',
134
+ 'class' => 'wjecf_coupondata_products',
135
+ );
136
+
137
+ $tabs['extended_features_checkout'] = array(
138
+ 'label' => __( 'Checkout', 'woocommerce-jos-autocoupon' ),
139
+ 'target' => 'wjecf_coupondata_checkout',
140
+ 'class' => 'wjecf_coupondata_checkout',
141
+ );
142
+
143
+ $tabs['extended_features_misc'] = array(
144
+ 'label' => __( 'Miscellaneous', 'woocommerce-jos-autocoupon' ),
145
+ 'target' => 'wjecf_coupondata_misc',
146
+ 'class' => 'wjecf_coupondata_misc',
147
  );
148
+
149
  return $tabs;
150
  }
151
 
152
  //Tab 'extended features'
153
+ public function admin_coupon_metabox_products( $thepostid, $post ) {
 
 
 
154
  //See WooCommerce class-wc-meta-box-coupon-data.php function ouput
155
 
156
+ echo "<h3>" . esc_html( __( 'Matching products', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
157
  //=============================
158
+ // AND instead of OR the products
159
  woocommerce_wp_checkbox( array(
160
  'id' => '_wjecf_products_and',
161
  'label' => __( 'AND Products (not OR)', 'woocommerce-jos-autocoupon' ),
162
  'description' => __( 'Check this box if ALL of the products (see tab \'usage restriction\') must be in the cart to use this coupon (in stead of only one of the products).', 'woocommerce-jos-autocoupon' )
163
  ) );
164
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  //=============================
166
  //Trick to show AND or OR next to the product_ids field
167
  $label_and = __( '(AND)', 'woocommerce-jos-autocoupon' );
179
  //Append AND/OR to the product_ids label
180
  jQuery(".form-field:has('[name=\"product_ids\"]') label").append( ' <strong><span id="wjecf_products_and_label"><?php echo esc_html( $label ); ?></span></strong>' );
181
  </script>
182
+ <?php //End of the AND/OR trick
183
 
184
+ // Minimum quantity of matching products (product/category)
185
+ woocommerce_wp_text_input( array(
186
+ 'id' => '_wjecf_min_matching_product_qty',
187
+ 'label' => __( 'Minimum quantity of matching products', 'woocommerce-jos-autocoupon' ),
188
+ 'placeholder' => __( 'No minimum', 'woocommerce' ),
189
+ 'description' => __( 'Minimum quantity of the products that match the given product or category restrictions (see tab \'usage restriction\'). If no product or category restrictions are specified, the total number of products is used.', 'woocommerce-jos-autocoupon' ),
190
+ 'data_type' => 'decimal',
191
+ 'desc_tip' => true
192
+ ) );
193
 
194
+ // Maximum quantity of matching products (product/category)
195
+ woocommerce_wp_text_input( array(
196
+ 'id' => '_wjecf_max_matching_product_qty',
197
+ 'label' => __( 'Maximum quantity of matching products', 'woocommerce-jos-autocoupon' ),
198
+ 'placeholder' => __( 'No maximum', 'woocommerce' ),
199
+ 'description' => __( 'Maximum quantity of the products that match the given product or category restrictions (see tab \'usage restriction\'). If no product or category restrictions are specified, the total number of products is used.', 'woocommerce-jos-autocoupon' ),
200
+ 'data_type' => 'decimal',
201
+ 'desc_tip' => true
202
+ ) );
203
+
204
+ // Minimum subtotal of matching products (product/category)
205
+ woocommerce_wp_text_input( array(
206
+ 'id' => '_wjecf_min_matching_product_subtotal',
207
+ 'label' => __( 'Minimum subtotal of matching products', 'woocommerce-jos-autocoupon' ),
208
+ 'placeholder' => __( 'No minimum', 'woocommerce' ),
209
+ 'description' => __( 'Minimum price subtotal of the products that match the given product or category restrictions (see tab \'usage restriction\').', 'woocommerce-jos-autocoupon' ),
210
+ 'data_type' => 'price',
211
+ 'desc_tip' => true
212
+ ) );
213
+
214
+ // Maximum subtotal of matching products (product/category)
215
+ woocommerce_wp_text_input( array(
216
+ 'id' => '_wjecf_max_matching_product_subtotal',
217
+ 'label' => __( 'Maximum subtotal of matching products', 'woocommerce-jos-autocoupon' ),
218
+ 'placeholder' => __( 'No maximum', 'woocommerce' ),
219
+ 'description' => __( 'Maximum price subtotal of the products that match the given product or category restrictions (see tab \'usage restriction\').', 'woocommerce-jos-autocoupon' ),
220
+ 'data_type' => 'price',
221
+ 'desc_tip' => true
222
+ ) );
223
+ }
224
+
225
+ public function admin_coupon_metabox_checkout( $thepostid, $post ) {
226
+
227
+ echo "<h3>" . esc_html( __( 'Checkout', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
228
+
229
  //=============================
230
  // Shipping methods
231
  ?>
259
  ?>
260
  </select> <img class="help_tip" data-tip='<?php _e( 'One of these payment methods must be selected in order for this coupon to be valid.', 'woocommerce-jos-autocoupon' ); ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
261
  <?php
262
+ }
263
+
264
+ public function admin_coupon_metabox_customer( $thepostid, $post ) {
265
 
 
266
  //=============================
267
  //Title: "CUSTOMER RESTRICTIONS"
268
+ echo "<h3>" . esc_html( __( 'Customer restrictions', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
269
  echo "<p><span class='description'>" . __( 'If both a customer and a role restriction are supplied, matching either one of them will suffice.' , 'woocommerce-jos-autocoupon' ) . "</span></p>\n";
270
 
271
  //=============================
332
  ?>' src="<?php echo WC()->plugin_url(); ?>/assets/images/help.png" height="16" width="16" /></p>
333
  <?php
334
  }
335
+
336
+ public function admin_coupon_metabox_misc( $thepostid, $post ) {
337
+ echo "<h3>" . esc_html( __( 'Miscellaneous', 'woocommerce-jos-autocoupon' ) ). "</h3>\n";
338
+ //=============================
339
+ //2.2.2 Allow if minimum spend not met
340
+ woocommerce_wp_checkbox( array(
341
+ 'id' => '_wjecf_allow_below_minimum_spend',
342
+ 'label' => __( 'Allow when minimum spend not reached', 'woocommerce-jos-autocoupon' ),
343
+ 'description' => '<b>' . __( 'EXPERIMENTAL: ', 'woocommerce-jos-autocoupon' ) . '</b>' . __( 'Check this box to allow the coupon to be in the cart even when minimum spend (see tab \'usage restriction\') is not reached. Value of the discount will be 0 until minimum spend is reached.', 'woocommerce-jos-autocoupon' ),
344
+ ) );
345
+ }
346
+
347
  public function process_shop_coupon_meta( $post_id, $post ) {
348
  $wjecf_min_matching_product_qty = isset( $_POST['_wjecf_min_matching_product_qty'] ) ? $_POST['_wjecf_min_matching_product_qty'] : '';
349
  update_post_meta( $post_id, '_wjecf_min_matching_product_qty', $wjecf_min_matching_product_qty );
350
 
351
  $wjecf_max_matching_product_qty = isset( $_POST['_wjecf_max_matching_product_qty'] ) ? $_POST['_wjecf_max_matching_product_qty'] : '';
352
  update_post_meta( $post_id, '_wjecf_max_matching_product_qty', $wjecf_max_matching_product_qty );
353
+
354
+ //2.2.2
355
+ $wjecf_min_matching_product_subtotal = isset( $_POST['_wjecf_min_matching_product_subtotal'] ) ? $_POST['_wjecf_min_matching_product_subtotal'] : '';
356
+ update_post_meta( $post_id, '_wjecf_min_matching_product_subtotal', $wjecf_min_matching_product_subtotal );
357
 
358
+ $wjecf_max_matching_product_subtotal = isset( $_POST['_wjecf_max_matching_product_subtotal'] ) ? $_POST['_wjecf_max_matching_product_subtotal'] : '';
359
+ update_post_meta( $post_id, '_wjecf_max_matching_product_subtotal', $wjecf_max_matching_product_subtotal );
360
+
361
  $wjecf_products_and = isset( $_POST['_wjecf_products_and'] ) ? 'yes' : 'no';
362
  update_post_meta( $post_id, '_wjecf_products_and', $wjecf_products_and );
363
 
364
+ //2.2.2
365
+ $wjecf_allow_below_minimum_spend = isset( $_POST['_wjecf_allow_below_minimum_spend'] ) ? 'yes' : 'no';
366
+ update_post_meta( $post_id, '_wjecf_allow_below_minimum_spend', $wjecf_allow_below_minimum_spend );
367
+
368
  $wjecf_shipping_methods = isset( $_POST['wjecf_shipping_methods'] ) ? $_POST['wjecf_shipping_methods'] : '';
369
  update_post_meta( $post_id, '_wjecf_shipping_methods', $wjecf_shipping_methods );
370
 
380
  $wjecf_excluded_customer_roles = isset( $_POST['wjecf_excluded_customer_roles'] ) ? $_POST['wjecf_excluded_customer_roles'] : '';
381
  update_post_meta( $post_id, '_wjecf_excluded_customer_roles', $wjecf_excluded_customer_roles );
382
 
383
+ }
384
 
385
  /* FRONTEND HOOKS */
386
 
387
+ //2.2.2
388
+ function woocommerce_coupon_loaded ( $coupon ) {
389
+ if ( ! is_admin() ) {
390
+ //2.2.2 Allow coupon even if minimum spend not reached
391
+ if ( get_post_meta( $coupon->id, '_wjecf_allow_below_minimum_spend', true ) == 'yes' ) {
392
+ //HACK: Overwrite the minimum amount with 0 so WooCommerce will allow the coupon
393
+ $coupon->wjecf_minimum_amount_for_discount = $coupon->minimum_amount;
394
+ $coupon->minimum_amount = 0;
395
+ }
396
+ }
397
+ }
398
+
399
+ //2.2.2
400
+ function woocommerce_coupon_get_discount_amount ( $discount, $discounting_amount, $cart_item, $single, $coupon ) {
401
+ //2.2.2 No value if minimum spend not reached
402
+ if (isset( $coupon->wjecf_minimum_amount_for_discount ) ) {
403
+ if ( wc_format_decimal( $coupon->wjecf_minimum_amount_for_discount ) > wc_format_decimal( WC()->cart->subtotal ) ) {
404
+ return 0;
405
+ };
406
+ }
407
+ return $discount;
408
+ }
409
+
410
+
411
+ /* Extra validation rules for coupons */
412
  function coupon_is_valid ( $valid, $coupon ) {
413
  //Not valid? Then it will never validate, so get out of here
414
  if ( ! $valid ) {
442
  // If coupon contains either a product OR category exclusion filter: the item will NOT be counted if it matches either one of them
443
  // If sale items are excluded by the coupon: the item will NOT be counted if it is a sale item
444
  // If no filter exist, all items will be counted
445
+
446
+ $multiplier = null; //null = not initialized
447
+
448
+ //Validate quantity
449
  $min_matching_product_qty = intval(get_post_meta( $coupon->id, '_wjecf_min_matching_product_qty', true ));
450
  $max_matching_product_qty = intval(get_post_meta( $coupon->id, '_wjecf_max_matching_product_qty', true ));
451
+ if ( $min_matching_product_qty > 0 || $max_matching_product_qty > 0 ) {
452
  //Count the products
453
+ $qty = $this->get_quantity_of_matching_products( $coupon );
 
 
 
 
 
 
 
454
  if ($min_matching_product_qty > 0 && $qty < $min_matching_product_qty) return false;
455
  if ($max_matching_product_qty > 0 && $qty > $max_matching_product_qty) return false;
456
+ $multiplier = self::min_value( floor( $qty / $min_matching_product_qty ), $multiplier );
457
  }
458
 
459
+ //Validate subtotal (2.2.2)
460
+ $min_matching_product_subtotal = intval(get_post_meta( $coupon->id, '_wjecf_min_matching_product_subtotal', true ));
461
+ $max_matching_product_subtotal = intval(get_post_meta( $coupon->id, '_wjecf_max_matching_product_subtotal', true ));
462
+ if ( $min_matching_product_subtotal > 0 || $max_matching_product_subtotal > 0 ) {
463
+ $subtotal = $this->get_subtotal_of_matching_products( $coupon );
464
+ if ($min_matching_product_subtotal > 0 && $subtotal < $min_matching_product_subtotal) return false;
465
+ if ($max_matching_product_subtotal > 0 && $subtotal > $max_matching_product_subtotal) return false;
466
+ $multiplier = self::min_value( floor( $subtotal / $min_matching_product_subtotal ), $multiplier );
467
+ }
468
 
469
  //============================
470
  //Test restricted shipping methods
515
  return false;
516
  }
517
  }
518
+
519
+ if ( $coupon->minimum_amount ) {
520
+ $multiplier = self::min_value( floor( WC()->cart->subtotal / $coupon->minimum_amount ), $multiplier );
521
+ }
522
+
523
+
524
+ $this->coupon_multiplier_values[ $coupon->code ] = $multiplier;
525
+
526
  return true;
527
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
 
529
+ /**
530
+ * Return the lowest multiplier value
531
+ */
532
+ private static function min_value( $value, $current_multiplier_value = null ) {
533
+ return ( $current_multiplier_value === null || $value < $current_multiplier_value ) ? $value : $current_multiplier_value;
534
+ }
535
 
536
+ /**
537
+ * The amount of times the minimum spend / quantity / subtotal values are reached
538
+ * @return int 1 or more
539
+ */
540
+ public function get_coupon_multiplier_value( $coupon ) {
541
+ $coupon = $this->get_coupon( $coupon );
542
 
543
+ if ( ! isset( $this->coupon_multiplier_values[ $coupon->code ] ) || ! $this->coupon_multiplier_values[ $coupon->code ] ) {
544
+ return 1;
 
 
 
545
  }
546
 
547
+ return $this->coupon_multiplier_values[ $coupon->code ];
548
+ }
 
 
549
 
550
+ //Temporary storage
551
+ private $coupon_multiplier_values = array();
 
 
 
 
552
 
553
+
554
+ /**
555
+ * PUBLIC USAGE OF THIS FUNCTION IS ALLOWED!
556
+ * The total amount of the products in the cart that match the coupon restrictions
557
+ * since 2.2.2-b3
558
+ */
559
+ public function get_quantity_of_matching_products( $coupon ) {
560
+ $coupon = $this->get_coupon( $coupon );
561
+
562
+ $qty = 0;
563
+ foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
564
+ $_product = $cart_item['data'];
565
+ if ($this->coupon_is_valid_for_product( $coupon, $_product, $cart_item ) ) {
566
+ $qty += $cart_item['quantity'];
567
  }
568
  }
569
+ return $qty;
570
+ }
571
 
572
+ /**
573
+ * PUBLIC USAGE OF THIS FUNCTION IS ALLOWED!
574
+ * The total value of the products in the cart that match the coupon restrictions
575
+ * since 2.2.2-b3
576
+ */
577
+ public function get_subtotal_of_matching_products( $coupon ) {
578
+ $coupon = $this->get_coupon( $coupon );
579
+
580
+ $subtotal = 0;
581
+ foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
582
+ $_product = $cart_item['data'];
583
+ if ($this->coupon_is_valid_for_product( $coupon, $_product, $cart_item ) ) {
584
+ $subtotal += $_product->get_price() * $cart_item['quantity'];
585
  }
586
  }
587
+ return $subtotal;
588
+ }
589
 
590
+ //Test if coupon is valid for the product
591
+ // (this function is used to count the quantity of matching products)
592
+ private function coupon_is_valid_for_product( $coupon, $product, $values = array() ) {
593
+ //Ugly hack: $coupon->is_valid_for_product only works for these types
594
+ $original_discount_type = $coupon->discount_type;
595
+ if ( ! $coupon->is_type( array( 'fixed_product', 'percent_product' ) ) ) {
596
+ $coupon->discount_type = 'fixed_product';
597
+ }
598
+ $valid = $coupon->is_valid_for_product( $product, $values );
599
+ $coupon->discount_type = $original_discount_type;
600
+
601
+ return $valid;
602
  }
603
 
604
 
605
 
606
+ //
607
+
608
+ /**
609
+ * Get a WC_Coupon object
610
+ * @param WC_Coupon|string $coupon The coupon code or a WC_Coupon object
611
+ * @return WC_Coupon The coupon object
612
+ */
613
+ private function get_coupon( $coupon ) {
614
+ if ( ! ( $coupon instanceof WC_Coupon ) ) {
615
+ $coupon = new WC_Coupon( $coupon );
616
+ }
617
+ return $coupon;
618
+ }
619
 
620
+ /**
621
+ * Get array of the selected shipping methods ids.
622
+ * @param int $coupon_id The coupon id
623
+ * @return array Id's of the shipping methods or an empty array.
624
+ */
625
  private function get_coupon_shipping_method_ids($coupon_id) {
626
  $v = get_post_meta( $coupon_id, '_wjecf_shipping_methods', true );
627
  if ($v == '') {
689
 
690
  return $v;
691
  }
692
+
693
+ public function is_pro() {
694
+ return class_exists( 'WC_Jos_Pro_Controller' );
695
+ }
696
+
697
 
698
  public static function get_donate_url() {
699
  return "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted";
languages/woocommerce-jos-autocoupon-nl_NL.mo CHANGED
Binary file
languages/woocommerce-jos-autocoupon-nl_NL.po CHANGED
@@ -4,24 +4,24 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-added-coupons\n"
7
- "POT-Creation-Date: 2015-08-15 20:20+0100\n"
8
- "PO-Revision-Date: 2015-08-15 20:39+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
11
  "Language: nl_NL\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
- "X-Generator: Poedit 1.8.1\n"
16
  "X-Poedit-KeywordsList: __;_e\n"
17
- "X-Poedit-Basepath: ..\\\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
 
20
- #: includes/wjecf-autocoupon.php:49 includes/wjecf-autocoupon.php:56
21
  msgid "Auto coupon"
22
  msgstr "Automatisch toepassen"
23
 
24
- #: includes/wjecf-autocoupon.php:57
25
  msgid ""
26
  "Automatically add the coupon to the cart if the restrictions are met. Please enter a "
27
  "description when you check this box, the description will be shown in the customer's cart if "
@@ -31,48 +31,56 @@ msgstr ""
31
  "voldaan. Vult u a.u.b. een omschrijving in als u deze optie aanvinkt, de omschrijving zal aan "
32
  "de klant worden getoond wanneer de kortingsbon wordt toegevoegd."
33
 
34
- #: includes/wjecf-autocoupon.php:64
35
  msgid "Apply silently"
36
  msgstr "Toepassen zonder melding"
37
 
38
- #: includes/wjecf-autocoupon.php:65
39
  msgid "Don't display a message when this coupon is automatically applied."
40
  msgstr "Geen melding weergeven wanneer deze kortingsbon automatisch wordt toegepast."
41
 
42
- #: includes/wjecf-autocoupon.php:144
43
  msgid "Free shipping coupon"
44
  msgstr "Gratis verzending kortingsbon"
45
 
46
- #: includes/wjecf-autocoupon.php:285
47
  #, php-format
48
  msgid "Discount applied: %s"
49
  msgstr "Korting toegepast: %s"
50
 
51
- #: includes/wjecf-coupon-extensions.php:80
52
- msgid "Extended Coupon Features"
53
- msgstr "Uitgebreide Kortingsbon Functies"
54
-
55
- #: includes/wjecf-coupon-extensions.php:87
56
  msgid "Do you find WooCommerce Extended Coupon Features useful?"
57
  msgstr "Vindt u WooCommerce Extended Coupon Features handig?"
58
 
59
- #: includes/wjecf-coupon-extensions.php:89
60
  msgid "Express your gratitude"
61
  msgstr "Toon uw waardering"
62
 
63
- #: includes/wjecf-coupon-extensions.php:93
64
  msgid "Donate to the developer"
65
  msgstr "Doneer aan de ontwikkelaar"
66
 
67
- #: includes/wjecf-coupon-extensions.php:105
68
- msgid "Extended features"
69
- msgstr "Uitgebreide functies"
 
 
 
 
 
 
 
 
70
 
71
- #: includes/wjecf-coupon-extensions.php:124
 
 
 
 
72
  msgid "AND Products (not OR)"
73
  msgstr "ALLE Producten (niet OF)"
74
 
75
- #: includes/wjecf-coupon-extensions.php:125
76
  msgid ""
77
  "Check this box if ALL of the products (see tab 'usage restriction') must be in the cart to "
78
  "use this coupon (in stead of only one of the products)."
@@ -80,15 +88,23 @@ msgstr ""
80
  "Aanvinken als ALLE producten (zie tab 'gebruiksbeperkingen') in de winkelwagen moeten zitten "
81
  "om deze kortingsbon te kunnen gebruiken (in plaats van één van de producten)."
82
 
83
- #: includes/wjecf-coupon-extensions.php:131
 
 
 
 
 
 
 
 
84
  msgid "Minimum quantity of matching products"
85
  msgstr "Minimum aantal overeengekomen producten"
86
 
87
- #: includes/wjecf-coupon-extensions.php:132
88
  msgid "No minimum"
89
  msgstr "Geen minimum"
90
 
91
- #: includes/wjecf-coupon-extensions.php:133
92
  msgid ""
93
  "Minimum quantity of the products that match the given product or category restrictions (see "
94
  "tab 'usage restriction'). If no product or category restrictions are specified, the total "
@@ -98,15 +114,15 @@ msgstr ""
98
  "'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven worden alle "
99
  "producten in de winkelwagen geteld."
100
 
101
- #: includes/wjecf-coupon-extensions.php:141
102
  msgid "Maximum quantity of matching products"
103
  msgstr "Maximum aantal overeengekomen producten"
104
 
105
- #: includes/wjecf-coupon-extensions.php:142
106
  msgid "No maximum"
107
  msgstr "Geen maximum"
108
 
109
- #: includes/wjecf-coupon-extensions.php:143
110
  msgid ""
111
  "Maximum quantity of the products that match the given product or category restrictions (see "
112
  "tab 'usage restriction'). If no product or category restrictions are specified, the total "
@@ -116,43 +132,61 @@ msgstr ""
116
  "'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven worden alle "
117
  "producten in de winkelwagen geteld."
118
 
119
- #: includes/wjecf-coupon-extensions.php:150
120
- msgid "(AND)"
121
- msgstr "(ALLE)"
122
 
123
- #: includes/wjecf-coupon-extensions.php:151
124
- msgid "(OR)"
125
- msgstr "(OF)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
- #: includes/wjecf-coupon-extensions.php:171
128
  msgid "Shipping methods"
129
  msgstr "Verzendmethoden"
130
 
131
- #: includes/wjecf-coupon-extensions.php:172
132
  msgid "Any shipping method"
133
  msgstr "Verzendmethoden"
134
 
135
- #: includes/wjecf-coupon-extensions.php:181
136
  msgid "One of these shipping methods must be selected in order for this coupon to be valid."
137
  msgstr "Een van deze verzendmethoden moet gekozen zijn om deze kortingsbon te kunnen gebruiken."
138
 
139
- #: includes/wjecf-coupon-extensions.php:187
140
  msgid "Payment methods"
141
  msgstr "Betaalmethoden"
142
 
143
- #: includes/wjecf-coupon-extensions.php:188
144
  msgid "Any payment method"
145
  msgstr "Betaalmethoden"
146
 
147
- #: includes/wjecf-coupon-extensions.php:199
148
  msgid "One of these payment methods must be selected in order for this coupon to be valid."
149
  msgstr "Een van deze betaalmethoden moet gekozen zijn om deze kortingsbon te kunnen gebruiken."
150
 
151
- #: includes/wjecf-coupon-extensions.php:205
152
  msgid "Customer restrictions"
153
  msgstr "Klantbeperkingen"
154
 
155
- #: includes/wjecf-coupon-extensions.php:206
156
  msgid ""
157
  "If both a customer and a role restriction are supplied, matching either one of them will "
158
  "suffice."
@@ -160,38 +194,91 @@ msgstr ""
160
  "Als zowel een klant- als klantrolrestrictie is opgegeven hoeft slechts aan één van de "
161
  "restricties worden voldaan."
162
 
163
- #: includes/wjecf-coupon-extensions.php:211
164
  msgid "Allowed Customers"
165
  msgstr "Toegestane klanten"
166
 
167
- #: includes/wjecf-coupon-extensions.php:212
168
  msgid "Any customer"
169
  msgstr "Klanten"
170
 
171
- #: includes/wjecf-coupon-extensions.php:225
172
  msgid "Only these customers may use this coupon."
173
  msgstr "Alleen deze klanten kunnen deze kortingsbon gebruiken."
174
 
175
- #: includes/wjecf-coupon-extensions.php:232
176
  msgid "Allowed User Roles"
177
  msgstr "Toegestane klantrollen"
178
 
179
- #: includes/wjecf-coupon-extensions.php:233 includes/wjecf-coupon-extensions.php:255
180
  msgid "Any role"
181
  msgstr "Klantrollen"
182
 
183
- #: includes/wjecf-coupon-extensions.php:247
184
  msgid "Only these User Roles may use this coupon."
185
  msgstr "Alleen deze klantrollen kunnen deze kortingsbon gebruiken."
186
 
187
- #: includes/wjecf-coupon-extensions.php:254
188
  msgid "Disallowed User Roles"
189
  msgstr "Uitgesloten klantrollen"
190
 
191
- #: includes/wjecf-coupon-extensions.php:268
192
  msgid "These User Roles will be specifically excluded from using this coupon."
193
  msgstr "Deze klantrollen zijn uitgesloten om deze kortingsbon te gebruiken."
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  #~ msgid "Customers"
196
  #~ msgstr "Klanten"
197
 
4
  msgstr ""
5
  "Project-Id-Version: WooCommerce auto added coupons 1.1.3.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/woocommerce-auto-added-coupons\n"
7
+ "POT-Creation-Date: 2015-11-20 00:06+0100\n"
8
+ "PO-Revision-Date: 2015-11-20 00:08+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: \n"
11
  "Language: nl_NL\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
+ "X-Generator: Poedit 1.8.5\n"
16
  "X-Poedit-KeywordsList: __;_e\n"
17
+ "X-Poedit-Basepath: ..\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
 
20
+ #: includes/wjecf-autocoupon.php:54 includes/wjecf-autocoupon.php:61
21
  msgid "Auto coupon"
22
  msgstr "Automatisch toepassen"
23
 
24
+ #: includes/wjecf-autocoupon.php:62
25
  msgid ""
26
  "Automatically add the coupon to the cart if the restrictions are met. Please enter a "
27
  "description when you check this box, the description will be shown in the customer's cart if "
31
  "voldaan. Vult u a.u.b. een omschrijving in als u deze optie aanvinkt, de omschrijving zal aan "
32
  "de klant worden getoond wanneer de kortingsbon wordt toegevoegd."
33
 
34
+ #: includes/wjecf-autocoupon.php:69
35
  msgid "Apply silently"
36
  msgstr "Toepassen zonder melding"
37
 
38
+ #: includes/wjecf-autocoupon.php:70
39
  msgid "Don't display a message when this coupon is automatically applied."
40
  msgstr "Geen melding weergeven wanneer deze kortingsbon automatisch wordt toegepast."
41
 
42
+ #: includes/wjecf-autocoupon.php:165
43
  msgid "Free shipping coupon"
44
  msgstr "Gratis verzending kortingsbon"
45
 
46
+ #: includes/wjecf-autocoupon.php:305
47
  #, php-format
48
  msgid "Discount applied: %s"
49
  msgstr "Korting toegepast: %s"
50
 
51
+ #: includes/wjecf-coupon-extensions.php:114
 
 
 
 
52
  msgid "Do you find WooCommerce Extended Coupon Features useful?"
53
  msgstr "Vindt u WooCommerce Extended Coupon Features handig?"
54
 
55
+ #: includes/wjecf-coupon-extensions.php:116
56
  msgid "Express your gratitude"
57
  msgstr "Toon uw waardering"
58
 
59
+ #: includes/wjecf-coupon-extensions.php:120
60
  msgid "Donate to the developer"
61
  msgstr "Doneer aan de ontwikkelaar"
62
 
63
+ #: includes/wjecf-coupon-extensions.php:132
64
+ msgid "Products"
65
+ msgstr "Producten"
66
+
67
+ #: includes/wjecf-coupon-extensions.php:138 includes/wjecf-coupon-extensions.php:227
68
+ msgid "Checkout"
69
+ msgstr "Afrekenen"
70
+
71
+ #: includes/wjecf-coupon-extensions.php:144 includes/wjecf-coupon-extensions.php:337
72
+ msgid "Miscellaneous"
73
+ msgstr "Diversen"
74
 
75
+ #: includes/wjecf-coupon-extensions.php:156
76
+ msgid "Matching products"
77
+ msgstr "Overeenkomende producten"
78
+
79
+ #: includes/wjecf-coupon-extensions.php:161
80
  msgid "AND Products (not OR)"
81
  msgstr "ALLE Producten (niet OF)"
82
 
83
+ #: includes/wjecf-coupon-extensions.php:162
84
  msgid ""
85
  "Check this box if ALL of the products (see tab 'usage restriction') must be in the cart to "
86
  "use this coupon (in stead of only one of the products)."
88
  "Aanvinken als ALLE producten (zie tab 'gebruiksbeperkingen') in de winkelwagen moeten zitten "
89
  "om deze kortingsbon te kunnen gebruiken (in plaats van één van de producten)."
90
 
91
+ #: includes/wjecf-coupon-extensions.php:167
92
+ msgid "(AND)"
93
+ msgstr "(ALLE)"
94
+
95
+ #: includes/wjecf-coupon-extensions.php:168
96
+ msgid "(OR)"
97
+ msgstr "(OF)"
98
+
99
+ #: includes/wjecf-coupon-extensions.php:187
100
  msgid "Minimum quantity of matching products"
101
  msgstr "Minimum aantal overeengekomen producten"
102
 
103
+ #: includes/wjecf-coupon-extensions.php:188 includes/wjecf-coupon-extensions.php:208
104
  msgid "No minimum"
105
  msgstr "Geen minimum"
106
 
107
+ #: includes/wjecf-coupon-extensions.php:189
108
  msgid ""
109
  "Minimum quantity of the products that match the given product or category restrictions (see "
110
  "tab 'usage restriction'). If no product or category restrictions are specified, the total "
114
  "'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven worden alle "
115
  "producten in de winkelwagen geteld."
116
 
117
+ #: includes/wjecf-coupon-extensions.php:197
118
  msgid "Maximum quantity of matching products"
119
  msgstr "Maximum aantal overeengekomen producten"
120
 
121
+ #: includes/wjecf-coupon-extensions.php:198 includes/wjecf-coupon-extensions.php:218
122
  msgid "No maximum"
123
  msgstr "Geen maximum"
124
 
125
+ #: includes/wjecf-coupon-extensions.php:199
126
  msgid ""
127
  "Maximum quantity of the products that match the given product or category restrictions (see "
128
  "tab 'usage restriction'). If no product or category restrictions are specified, the total "
132
  "'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven worden alle "
133
  "producten in de winkelwagen geteld."
134
 
135
+ #: includes/wjecf-coupon-extensions.php:207
136
+ msgid "Minimum subtotal of matching products"
137
+ msgstr "Minimum subtotaal overeengekomen producten"
138
 
139
+ #: includes/wjecf-coupon-extensions.php:209
140
+ msgid ""
141
+ "Minimum price subtotal of the products that match the given product or category restrictions "
142
+ "(see tab 'usage restriction')."
143
+ msgstr ""
144
+ "Minimum subtotaal van de producten welke aan de product- of categorierestricties voldoet (zie "
145
+ "tab 'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven wordt het "
146
+ "subtotaal van alle producten in de winkelwagen opgeteld."
147
+
148
+ #: includes/wjecf-coupon-extensions.php:217
149
+ msgid "Maximum subtotal of matching products"
150
+ msgstr "Maximum subtotaal overeengekomen producten"
151
+
152
+ #: includes/wjecf-coupon-extensions.php:219
153
+ msgid ""
154
+ "Maximum price subtotal of the products that match the given product or category restrictions "
155
+ "(see tab 'usage restriction')."
156
+ msgstr ""
157
+ "Maximum subtotaal van de producten welke aan de product- of categorierestricties voldoet (zie "
158
+ "tab 'gebruiksbeperkingen'). Als geen product- of categorierestrictie is opgegeven wordt het "
159
+ "subtotaal van alle producten in de winkelwagen opgeteld."
160
 
161
+ #: includes/wjecf-coupon-extensions.php:232
162
  msgid "Shipping methods"
163
  msgstr "Verzendmethoden"
164
 
165
+ #: includes/wjecf-coupon-extensions.php:233
166
  msgid "Any shipping method"
167
  msgstr "Verzendmethoden"
168
 
169
+ #: includes/wjecf-coupon-extensions.php:242
170
  msgid "One of these shipping methods must be selected in order for this coupon to be valid."
171
  msgstr "Een van deze verzendmethoden moet gekozen zijn om deze kortingsbon te kunnen gebruiken."
172
 
173
+ #: includes/wjecf-coupon-extensions.php:248
174
  msgid "Payment methods"
175
  msgstr "Betaalmethoden"
176
 
177
+ #: includes/wjecf-coupon-extensions.php:249
178
  msgid "Any payment method"
179
  msgstr "Betaalmethoden"
180
 
181
+ #: includes/wjecf-coupon-extensions.php:260
182
  msgid "One of these payment methods must be selected in order for this coupon to be valid."
183
  msgstr "Een van deze betaalmethoden moet gekozen zijn om deze kortingsbon te kunnen gebruiken."
184
 
185
+ #: includes/wjecf-coupon-extensions.php:268
186
  msgid "Customer restrictions"
187
  msgstr "Klantbeperkingen"
188
 
189
+ #: includes/wjecf-coupon-extensions.php:269
190
  msgid ""
191
  "If both a customer and a role restriction are supplied, matching either one of them will "
192
  "suffice."
194
  "Als zowel een klant- als klantrolrestrictie is opgegeven hoeft slechts aan één van de "
195
  "restricties worden voldaan."
196
 
197
+ #: includes/wjecf-coupon-extensions.php:274
198
  msgid "Allowed Customers"
199
  msgstr "Toegestane klanten"
200
 
201
+ #: includes/wjecf-coupon-extensions.php:275
202
  msgid "Any customer"
203
  msgstr "Klanten"
204
 
205
+ #: includes/wjecf-coupon-extensions.php:288
206
  msgid "Only these customers may use this coupon."
207
  msgstr "Alleen deze klanten kunnen deze kortingsbon gebruiken."
208
 
209
+ #: includes/wjecf-coupon-extensions.php:295
210
  msgid "Allowed User Roles"
211
  msgstr "Toegestane klantrollen"
212
 
213
+ #: includes/wjecf-coupon-extensions.php:296 includes/wjecf-coupon-extensions.php:318
214
  msgid "Any role"
215
  msgstr "Klantrollen"
216
 
217
+ #: includes/wjecf-coupon-extensions.php:310
218
  msgid "Only these User Roles may use this coupon."
219
  msgstr "Alleen deze klantrollen kunnen deze kortingsbon gebruiken."
220
 
221
+ #: includes/wjecf-coupon-extensions.php:317
222
  msgid "Disallowed User Roles"
223
  msgstr "Uitgesloten klantrollen"
224
 
225
+ #: includes/wjecf-coupon-extensions.php:331
226
  msgid "These User Roles will be specifically excluded from using this coupon."
227
  msgstr "Deze klantrollen zijn uitgesloten om deze kortingsbon te gebruiken."
228
 
229
+ #: includes/wjecf-coupon-extensions.php:342
230
+ msgid "Allow when minimum spend not reached"
231
+ msgstr "Toestaan wanneer minimale besteding nog niet is behaald."
232
+
233
+ #: includes/wjecf-coupon-extensions.php:343
234
+ msgid "EXPERIMENTAL: "
235
+ msgstr "EXPERIMENTEEL:"
236
+
237
+ #: includes/wjecf-coupon-extensions.php:343
238
+ msgid ""
239
+ "Check this box to allow the coupon to be in the cart even when minimum spend (see tab 'usage "
240
+ "restriction') is not reached. Value of the discount will be 0 until minimum spend is reached."
241
+ msgstr ""
242
+ "Aanvinken als de coupon in de winkelwagen mag zitten zelfs als minimale besteding nog niet is "
243
+ "gehaald. De coupon zal een waarde van 0 hebben tot de minimale besteding is bereikt."
244
+
245
+ #~ msgid "Extended Coupon Features"
246
+ #~ msgstr "Uitgebreide Kortingsbon Functies"
247
+
248
+ #~ msgid "Extended features"
249
+ #~ msgstr "Uitgebreide functies"
250
+
251
+ #~ msgid "Allow if minimum spend not reached"
252
+ #~ msgstr "Toestaan als minimale besteding niet is bereikt"
253
+
254
+ #~ msgid ""
255
+ #~ "Check this box to allow the coupon to be in the cart even if minimum spend (see tab 'usage "
256
+ #~ "restriction') is not reached. Value of the discount will be 0 until minimum spend is "
257
+ #~ "reached."
258
+ #~ msgstr ""
259
+ #~ "Aanvinken als de kortingsbon ook in de winkelwagen mag zitten als 'minimale besteding' nog "
260
+ #~ "niet is bereikt."
261
+
262
+ #~ msgid "Free!"
263
+ #~ msgstr "Gratis!"
264
+
265
+ #~ msgid "Free products"
266
+ #~ msgstr "Gratis producten"
267
+
268
+ #~ msgid "Free products that will be added to the cart when this coupon is applied."
269
+ #~ msgstr ""
270
+ #~ "Gratis producten welke aan de winkelwagen worden toegevoegd als de coupon is toegepast."
271
+
272
+ #~ msgid "Allow multiplication of the free products"
273
+ #~ msgstr "Vermenigvuldigen gratis producten toestaan"
274
+
275
+ #~ msgid ""
276
+ #~ "The amount of free products is multiplied every time the minimum spend, subtotal or "
277
+ #~ "quantity is reached."
278
+ #~ msgstr ""
279
+ #~ "Het aantal van de gratis producten wordt vermenigvuldigd met het totale aantal keer dat "
280
+ #~ "minimale besteding, subtotaal of aantal is bereikt."
281
+
282
  #~ msgid "Customers"
283
  #~ msgstr "Klanten"
284
 
languages/woocommerce-jos-autocoupon.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WooCommerce Extended Coupon Features 2.00\n"
5
- "POT-Creation-Date: 2015-08-20 19:18+0100\n"
6
  "PO-Revision-Date: 2015-05-09 18:12+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Jos Koenis\n"
@@ -10,175 +10,222 @@ msgstr ""
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.1\n"
14
  "X-Poedit-KeywordsList: __;_e\n"
15
- "X-Poedit-Basepath: ..\\\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- #: includes/wjecf-autocoupon.php:49 includes/wjecf-autocoupon.php:56
20
  msgid "Auto coupon"
21
  msgstr ""
22
 
23
- #: includes/wjecf-autocoupon.php:57
24
  msgid ""
25
  "Automatically add the coupon to the cart if the restrictions are met. Please "
26
  "enter a description when you check this box, the description will be shown "
27
  "in the customer's cart if the coupon is applied."
28
  msgstr ""
29
 
30
- #: includes/wjecf-autocoupon.php:64
31
  msgid "Apply silently"
32
  msgstr ""
33
 
34
- #: includes/wjecf-autocoupon.php:65
35
  msgid "Don't display a message when this coupon is automatically applied."
36
  msgstr ""
37
 
38
- #: includes/wjecf-autocoupon.php:144
39
  msgid "Free shipping coupon"
40
  msgstr ""
41
 
42
- #: includes/wjecf-autocoupon.php:285
43
  #, php-format
44
  msgid "Discount applied: %s"
45
  msgstr ""
46
 
47
- #: includes/wjecf-coupon-extensions.php:80
48
- msgid "Extended Coupon Features"
49
- msgstr ""
50
-
51
- #: includes/wjecf-coupon-extensions.php:87
52
  msgid "Do you find WooCommerce Extended Coupon Features useful?"
53
  msgstr ""
54
 
55
- #: includes/wjecf-coupon-extensions.php:89
56
  msgid "Express your gratitude"
57
  msgstr ""
58
 
59
- #: includes/wjecf-coupon-extensions.php:93
60
  msgid "Donate to the developer"
61
  msgstr ""
62
 
63
- #: includes/wjecf-coupon-extensions.php:105
64
- msgid "Extended features"
 
 
 
 
 
65
  msgstr ""
66
 
67
- #: includes/wjecf-coupon-extensions.php:124
 
 
 
 
 
 
 
 
 
68
  msgid "AND Products (not OR)"
69
  msgstr ""
70
 
71
- #: includes/wjecf-coupon-extensions.php:125
72
  msgid ""
73
  "Check this box if ALL of the products (see tab 'usage restriction') must be "
74
  "in the cart to use this coupon (in stead of only one of the products)."
75
  msgstr ""
76
 
77
- #: includes/wjecf-coupon-extensions.php:131
 
 
 
 
 
 
 
 
78
  msgid "Minimum quantity of matching products"
79
  msgstr ""
80
 
81
- #: includes/wjecf-coupon-extensions.php:132
 
82
  msgid "No minimum"
83
  msgstr ""
84
 
85
- #: includes/wjecf-coupon-extensions.php:133
86
  msgid ""
87
  "Minimum quantity of the products that match the given product or category "
88
  "restrictions (see tab 'usage restriction'). If no product or category "
89
  "restrictions are specified, the total number of products is used."
90
  msgstr ""
91
 
92
- #: includes/wjecf-coupon-extensions.php:141
93
  msgid "Maximum quantity of matching products"
94
  msgstr ""
95
 
96
- #: includes/wjecf-coupon-extensions.php:142
 
97
  msgid "No maximum"
98
  msgstr ""
99
 
100
- #: includes/wjecf-coupon-extensions.php:143
101
  msgid ""
102
  "Maximum quantity of the products that match the given product or category "
103
  "restrictions (see tab 'usage restriction'). If no product or category "
104
  "restrictions are specified, the total number of products is used."
105
  msgstr ""
106
 
107
- #: includes/wjecf-coupon-extensions.php:150
108
- msgid "(AND)"
109
  msgstr ""
110
 
111
- #: includes/wjecf-coupon-extensions.php:151
112
- msgid "(OR)"
 
 
113
  msgstr ""
114
 
115
- #: includes/wjecf-coupon-extensions.php:171
 
 
 
 
 
 
 
 
 
 
116
  msgid "Shipping methods"
117
  msgstr ""
118
 
119
- #: includes/wjecf-coupon-extensions.php:172
120
  msgid "Any shipping method"
121
  msgstr ""
122
 
123
- #: includes/wjecf-coupon-extensions.php:181
124
  msgid ""
125
  "One of these shipping methods must be selected in order for this coupon to "
126
  "be valid."
127
  msgstr ""
128
 
129
- #: includes/wjecf-coupon-extensions.php:187
130
  msgid "Payment methods"
131
  msgstr ""
132
 
133
- #: includes/wjecf-coupon-extensions.php:188
134
  msgid "Any payment method"
135
  msgstr ""
136
 
137
- #: includes/wjecf-coupon-extensions.php:199
138
  msgid ""
139
  "One of these payment methods must be selected in order for this coupon to be "
140
  "valid."
141
  msgstr ""
142
 
143
- #: includes/wjecf-coupon-extensions.php:205
144
  msgid "Customer restrictions"
145
  msgstr ""
146
 
147
- #: includes/wjecf-coupon-extensions.php:206
148
  msgid ""
149
  "If both a customer and a role restriction are supplied, matching either one "
150
  "of them will suffice."
151
  msgstr ""
152
 
153
- #: includes/wjecf-coupon-extensions.php:211
154
  msgid "Allowed Customers"
155
  msgstr ""
156
 
157
- #: includes/wjecf-coupon-extensions.php:212
158
  msgid "Any customer"
159
  msgstr ""
160
 
161
- #: includes/wjecf-coupon-extensions.php:225
162
  msgid "Only these customers may use this coupon."
163
  msgstr ""
164
 
165
- #: includes/wjecf-coupon-extensions.php:232
166
  msgid "Allowed User Roles"
167
  msgstr ""
168
 
169
- #: includes/wjecf-coupon-extensions.php:233
170
- #: includes/wjecf-coupon-extensions.php:255
171
  msgid "Any role"
172
  msgstr ""
173
 
174
- #: includes/wjecf-coupon-extensions.php:247
175
  msgid "Only these User Roles may use this coupon."
176
  msgstr ""
177
 
178
- #: includes/wjecf-coupon-extensions.php:254
179
  msgid "Disallowed User Roles"
180
  msgstr ""
181
 
182
- #: includes/wjecf-coupon-extensions.php:268
183
  msgid "These User Roles will be specifically excluded from using this coupon."
184
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: WooCommerce Extended Coupon Features 2.00\n"
5
+ "POT-Creation-Date: 2015-11-20 00:06+0100\n"
6
  "PO-Revision-Date: 2015-05-09 18:12+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Jos Koenis\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 1.8.5\n"
14
  "X-Poedit-KeywordsList: __;_e\n"
15
+ "X-Poedit-Basepath: ..\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
+ #: includes/wjecf-autocoupon.php:54 includes/wjecf-autocoupon.php:61
20
  msgid "Auto coupon"
21
  msgstr ""
22
 
23
+ #: includes/wjecf-autocoupon.php:62
24
  msgid ""
25
  "Automatically add the coupon to the cart if the restrictions are met. Please "
26
  "enter a description when you check this box, the description will be shown "
27
  "in the customer's cart if the coupon is applied."
28
  msgstr ""
29
 
30
+ #: includes/wjecf-autocoupon.php:69
31
  msgid "Apply silently"
32
  msgstr ""
33
 
34
+ #: includes/wjecf-autocoupon.php:70
35
  msgid "Don't display a message when this coupon is automatically applied."
36
  msgstr ""
37
 
38
+ #: includes/wjecf-autocoupon.php:165
39
  msgid "Free shipping coupon"
40
  msgstr ""
41
 
42
+ #: includes/wjecf-autocoupon.php:305
43
  #, php-format
44
  msgid "Discount applied: %s"
45
  msgstr ""
46
 
47
+ #: includes/wjecf-coupon-extensions.php:114
 
 
 
 
48
  msgid "Do you find WooCommerce Extended Coupon Features useful?"
49
  msgstr ""
50
 
51
+ #: includes/wjecf-coupon-extensions.php:116
52
  msgid "Express your gratitude"
53
  msgstr ""
54
 
55
+ #: includes/wjecf-coupon-extensions.php:120
56
  msgid "Donate to the developer"
57
  msgstr ""
58
 
59
+ #: includes/wjecf-coupon-extensions.php:132
60
+ msgid "Products"
61
+ msgstr ""
62
+
63
+ #: includes/wjecf-coupon-extensions.php:138
64
+ #: includes/wjecf-coupon-extensions.php:227
65
+ msgid "Checkout"
66
  msgstr ""
67
 
68
+ #: includes/wjecf-coupon-extensions.php:144
69
+ #: includes/wjecf-coupon-extensions.php:337
70
+ msgid "Miscellaneous"
71
+ msgstr ""
72
+
73
+ #: includes/wjecf-coupon-extensions.php:156
74
+ msgid "Matching products"
75
+ msgstr ""
76
+
77
+ #: includes/wjecf-coupon-extensions.php:161
78
  msgid "AND Products (not OR)"
79
  msgstr ""
80
 
81
+ #: includes/wjecf-coupon-extensions.php:162
82
  msgid ""
83
  "Check this box if ALL of the products (see tab 'usage restriction') must be "
84
  "in the cart to use this coupon (in stead of only one of the products)."
85
  msgstr ""
86
 
87
+ #: includes/wjecf-coupon-extensions.php:167
88
+ msgid "(AND)"
89
+ msgstr ""
90
+
91
+ #: includes/wjecf-coupon-extensions.php:168
92
+ msgid "(OR)"
93
+ msgstr ""
94
+
95
+ #: includes/wjecf-coupon-extensions.php:187
96
  msgid "Minimum quantity of matching products"
97
  msgstr ""
98
 
99
+ #: includes/wjecf-coupon-extensions.php:188
100
+ #: includes/wjecf-coupon-extensions.php:208
101
  msgid "No minimum"
102
  msgstr ""
103
 
104
+ #: includes/wjecf-coupon-extensions.php:189
105
  msgid ""
106
  "Minimum quantity of the products that match the given product or category "
107
  "restrictions (see tab 'usage restriction'). If no product or category "
108
  "restrictions are specified, the total number of products is used."
109
  msgstr ""
110
 
111
+ #: includes/wjecf-coupon-extensions.php:197
112
  msgid "Maximum quantity of matching products"
113
  msgstr ""
114
 
115
+ #: includes/wjecf-coupon-extensions.php:198
116
+ #: includes/wjecf-coupon-extensions.php:218
117
  msgid "No maximum"
118
  msgstr ""
119
 
120
+ #: includes/wjecf-coupon-extensions.php:199
121
  msgid ""
122
  "Maximum quantity of the products that match the given product or category "
123
  "restrictions (see tab 'usage restriction'). If no product or category "
124
  "restrictions are specified, the total number of products is used."
125
  msgstr ""
126
 
127
+ #: includes/wjecf-coupon-extensions.php:207
128
+ msgid "Minimum subtotal of matching products"
129
  msgstr ""
130
 
131
+ #: includes/wjecf-coupon-extensions.php:209
132
+ msgid ""
133
+ "Minimum price subtotal of the products that match the given product or "
134
+ "category restrictions (see tab 'usage restriction')."
135
  msgstr ""
136
 
137
+ #: includes/wjecf-coupon-extensions.php:217
138
+ msgid "Maximum subtotal of matching products"
139
+ msgstr ""
140
+
141
+ #: includes/wjecf-coupon-extensions.php:219
142
+ msgid ""
143
+ "Maximum price subtotal of the products that match the given product or "
144
+ "category restrictions (see tab 'usage restriction')."
145
+ msgstr ""
146
+
147
+ #: includes/wjecf-coupon-extensions.php:232
148
  msgid "Shipping methods"
149
  msgstr ""
150
 
151
+ #: includes/wjecf-coupon-extensions.php:233
152
  msgid "Any shipping method"
153
  msgstr ""
154
 
155
+ #: includes/wjecf-coupon-extensions.php:242
156
  msgid ""
157
  "One of these shipping methods must be selected in order for this coupon to "
158
  "be valid."
159
  msgstr ""
160
 
161
+ #: includes/wjecf-coupon-extensions.php:248
162
  msgid "Payment methods"
163
  msgstr ""
164
 
165
+ #: includes/wjecf-coupon-extensions.php:249
166
  msgid "Any payment method"
167
  msgstr ""
168
 
169
+ #: includes/wjecf-coupon-extensions.php:260
170
  msgid ""
171
  "One of these payment methods must be selected in order for this coupon to be "
172
  "valid."
173
  msgstr ""
174
 
175
+ #: includes/wjecf-coupon-extensions.php:268
176
  msgid "Customer restrictions"
177
  msgstr ""
178
 
179
+ #: includes/wjecf-coupon-extensions.php:269
180
  msgid ""
181
  "If both a customer and a role restriction are supplied, matching either one "
182
  "of them will suffice."
183
  msgstr ""
184
 
185
+ #: includes/wjecf-coupon-extensions.php:274
186
  msgid "Allowed Customers"
187
  msgstr ""
188
 
189
+ #: includes/wjecf-coupon-extensions.php:275
190
  msgid "Any customer"
191
  msgstr ""
192
 
193
+ #: includes/wjecf-coupon-extensions.php:288
194
  msgid "Only these customers may use this coupon."
195
  msgstr ""
196
 
197
+ #: includes/wjecf-coupon-extensions.php:295
198
  msgid "Allowed User Roles"
199
  msgstr ""
200
 
201
+ #: includes/wjecf-coupon-extensions.php:296
202
+ #: includes/wjecf-coupon-extensions.php:318
203
  msgid "Any role"
204
  msgstr ""
205
 
206
+ #: includes/wjecf-coupon-extensions.php:310
207
  msgid "Only these User Roles may use this coupon."
208
  msgstr ""
209
 
210
+ #: includes/wjecf-coupon-extensions.php:317
211
  msgid "Disallowed User Roles"
212
  msgstr ""
213
 
214
+ #: includes/wjecf-coupon-extensions.php:331
215
  msgid "These User Roles will be specifically excluded from using this coupon."
216
  msgstr ""
217
+
218
+ #: includes/wjecf-coupon-extensions.php:342
219
+ msgid "Allow when minimum spend not reached"
220
+ msgstr ""
221
+
222
+ #: includes/wjecf-coupon-extensions.php:343
223
+ msgid "EXPERIMENTAL: "
224
+ msgstr ""
225
+
226
+ #: includes/wjecf-coupon-extensions.php:343
227
+ msgid ""
228
+ "Check this box to allow the coupon to be in the cart even when minimum spend "
229
+ "(see tab 'usage restriction') is not reached. Value of the discount will be "
230
+ "0 until minimum spend is reached."
231
+ msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: josk79
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: woocommerce, coupons, discount
5
  Requires at least: 4.0.0
6
- Tested up to: 4.3
7
- Stable tag: 2.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -15,6 +15,8 @@ Additional functionality for WooCommerce Coupons: Allow discounts to be automati
15
  "WooCommerce Extended Coupon Features" (formerly known as: WooCommerce auto added coupons) adds functionality to the WooCommerce coupons.
16
  Very easy to use, the functionality is conveniently integrated to the WooCommerce Edit Coupon panel.
17
 
 
 
18
  * *Auto coupons*: Allow coupons to be automatically added to the users cart if it's restrictions are met,
19
  * Apply coupon via an url,
20
  * Restrict coupon by shipping method,
@@ -90,9 +92,23 @@ Sure! [This](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQ
90
 
91
  == Screenshots ==
92
 
93
- 1. Simply use the WooCommerce Coupons menu to make a coupon an "auto coupon".
 
 
 
94
 
95
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
96
  = 2.2.1 =
97
  * FIX: Prevent mulitple apply_coupon calls (for example through ajax)
98
  * FIX: Don't redirect to cart when using WooCommerce's ?add-to-cart=xxx in combination with ?apply_coupon=xxx as this would prevent the application of the coupon.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5T9XQBCS2QHRY&lc=NL&item_name=Jos%20Koenis&item_number=wordpress%2dplugin&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: woocommerce, coupons, discount
5
  Requires at least: 4.0.0
6
+ Tested up to: 4.3.1
7
+ Stable tag: 2.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
15
  "WooCommerce Extended Coupon Features" (formerly known as: WooCommerce auto added coupons) adds functionality to the WooCommerce coupons.
16
  Very easy to use, the functionality is conveniently integrated to the WooCommerce Edit Coupon panel.
17
 
18
+ * (PRO) Add *free products* to the customer's cart based on coupon rules
19
+ * (PRO) Allow a cart discount to be applied based on quantity / subtotal of matching products
20
  * *Auto coupons*: Allow coupons to be automatically added to the users cart if it's restrictions are met,
21
  * Apply coupon via an url,
22
  * Restrict coupon by shipping method,
92
 
93
  == Screenshots ==
94
 
95
+ 1. Allow a coupon to be applied automatically by checking "Auto coupon".
96
+ 2. Extra restrictions. E.g. Quantity or subtotal of matching products.
97
+ 3. (PRO) A free product has been applied to the cart
98
+ 4. Additionals restrictions based on shipping or payment method or the customer
99
 
100
  == Changelog ==
101
+ = 2.2.3 =
102
+ * (PRO) FEATURE: Allow discount on cart with excluded items
103
+ * (PRO) FEATURE: Free products!
104
+ * FEATURE: Allow coupon in cart even if minimum spend not reached
105
+ * FEATURE: New coupon feature: Minimum / maximum price subtotal of matching products in the cart
106
+ * COSMETIC: Admin Extended coupon features in multiple tabs
107
+ * FIX: Create session cookie if no session was initialized when applying coupon by url
108
+ * TWEAK: Auto coupon: Use woocommerce_after_calculate_totals hook for update_matched_autocoupons
109
+ * API: New function: $wjecf_extended_coupon_features->get_quantity_of_matching_products( $coupon )
110
+ * API: New function: $wjecf_extended_coupon_features->get_subtotal_of_matching_products( $coupon )
111
+
112
  = 2.2.1 =
113
  * FIX: Prevent mulitple apply_coupon calls (for example through ajax)
114
  * FIX: Don't redirect to cart when using WooCommerce's ?add-to-cart=xxx in combination with ?apply_coupon=xxx as this would prevent the application of the coupon.
woocommerce-jos-autocoupon.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce Extended Coupon Features
4
  * Plugin URI: http://www.soft79.nl
5
  * Description: Additional functionality for WooCommerce Coupons: Apply certain coupons automatically, allow applying coupons via an url, etc...
6
- * Version: 2.2.1
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
@@ -15,6 +15,8 @@ defined('ABSPATH') or die();
15
 
16
  require_once( 'includes/wjecf-autocoupon.php' );
17
  require_once( 'includes/wjecf-coupon-extensions.php' );
 
 
18
 
19
  /**
20
  * Create the plugin if WooCommerce is active
@@ -26,10 +28,18 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
26
  load_plugin_textdomain('woocommerce-jos-autocoupon', false, basename(dirname(__FILE__)) . '/languages/' );
27
  }
28
  add_action('plugins_loaded', 'wjecf_load_plugin_textdomain');
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
- $wjecf_extended_coupon_features = new WC_Jos_Extended_Coupon_Features_Controller();
32
- $wjecf_autocoupon = new WC_Jos_AutoCoupon_Controller();
33
 
34
  }
35
 
3
  * Plugin Name: WooCommerce Extended Coupon Features
4
  * Plugin URI: http://www.soft79.nl
5
  * Description: Additional functionality for WooCommerce Coupons: Apply certain coupons automatically, allow applying coupons via an url, etc...
6
+ * Version: 2.2.3
7
  * Author: Jos Koenis
8
  * License: GPL2
9
  */
15
 
16
  require_once( 'includes/wjecf-autocoupon.php' );
17
  require_once( 'includes/wjecf-coupon-extensions.php' );
18
+ @include_once( 'includes/wjecf-pro.php' );
19
+ @include_once( 'includes/wjecf-pro-free-products.php' );
20
 
21
  /**
22
  * Create the plugin if WooCommerce is active
28
  load_plugin_textdomain('woocommerce-jos-autocoupon', false, basename(dirname(__FILE__)) . '/languages/' );
29
  }
30
  add_action('plugins_loaded', 'wjecf_load_plugin_textdomain');
31
+ $wjecf_extended_coupon_features = new WC_Jos_Extended_Coupon_Features_Controller();
32
+ $wjecf_autocoupon = new WC_Jos_AutoCoupon_Controller();
33
+ if ( $wjecf_extended_coupon_features->is_pro() ) {
34
+ if ( class_exists( 'WC_Jos_Pro_Controller' ) ) {
35
+ $wjecf_pro = new WC_Jos_Pro_Controller();
36
+ }
37
+ if ( class_exists( 'WC_Jos_Free_Products_Controller' ) ) {
38
+ $wjecf_free_products = new WC_Jos_Free_Products_Controller();
39
+ }
40
+ }
41
  }
42
 
 
 
43
 
44
  }
45