WooCommerce Extended Coupon Features - Version 3.0.3

Version Description

Release Date - 2018-10-12 * FIX: Auto coupons: silently remove invalid coupons * FIX: WPML compatibility issue with "CATEGORIES AND" * (PRO) FIX: CSS of the column system (box-sizing: border-box)

Download this release

Release Info

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

Code changes from version 3.0.2 to 3.0.3

assets/wjecf.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- WJECF columns system v2.6.0
3
  */
4
 
5
  ul.wjecf-cols {
@@ -17,6 +17,7 @@ ul.wjecf-cols > li {
17
  padding-right:15px;
18
  position:relative;
19
  margin: 0 0 30px 0;
 
20
  }
21
 
22
  ul.wjecf-cols.cols-1 > li { width:100%; }
1
  /*
2
+ WJECF columns system v3.0.3
3
  */
4
 
5
  ul.wjecf-cols {
17
  padding-right:15px;
18
  position:relative;
19
  margin: 0 0 30px 0;
20
+ box-sizing: border-box;
21
  }
22
 
23
  ul.wjecf-cols.cols-1 > li { width:100%; }
includes/plugins/WJECF_Autocoupon.php CHANGED
@@ -30,7 +30,7 @@ if ( defined( 'ABSPATH' ) && ! class_exists( 'WJECF_Autocoupon' ) ) {
30
 
31
  //Update of auto-coupons is required after those actions:
32
  add_action( 'woocommerce_checkout_update_order_review', array( $this, 'force_update_after_calculate' ) );
33
- //add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_coupons' ) , 0, 0 ); //Remove coupon before WC does it and shows a message.
34
 
35
  //update auto-coupons before WC_Cart_Session::set_session() which has priority 10
36
  add_action( 'woocommerce_after_calculate_totals', array( $this, 'maybe_update_matched_autocoupons' ), 5 );
@@ -692,9 +692,12 @@ if ( defined( 'ABSPATH' ) && ! class_exists( 'WJECF_Autocoupon' ) ) {
692
  }
693
 
694
  function force_update_after_calculate() {
695
- //Invalidate the hash. On the cart/checkout page we want always want to update the auto coupons
696
- //due to shipping / email / payment / other changes...
697
- $this->known_situation_hash = 'FORCE!';
 
 
 
698
  }
699
 
700
  /**
@@ -790,10 +793,10 @@ if ( defined( 'ABSPATH' ) && ! class_exists( 'WJECF_Autocoupon' ) ) {
790
  /**
791
  * Remove unmatched auto-coupons from the cart.
792
  *
793
- * @param array $valid_coupon_codes string[] The valid coupon codes.
794
  * @return bool True if one or more coupons have been removed
795
  */
796
- private function remove_unmatched_autocoupons( $valid_coupon_codes ) {
797
  //Remove invalids
798
  $calc_needed = false;
799
  foreach ( WC()->cart->get_applied_coupons() as $coupon_code ) {
30
 
31
  //Update of auto-coupons is required after those actions:
32
  add_action( 'woocommerce_checkout_update_order_review', array( $this, 'force_update_after_calculate' ) );
33
+ add_action( 'woocommerce_check_cart_items', array( $this, 'action_woocommerce_check_cart_items' ), 0, 0 ); //Remove coupon before WC does it and shows a message.
34
 
35
  //update auto-coupons before WC_Cart_Session::set_session() which has priority 10
36
  add_action( 'woocommerce_after_calculate_totals', array( $this, 'maybe_update_matched_autocoupons' ), 5 );
692
  }
693
 
694
  function force_update_after_calculate() {
695
+ //Invalidate the hash
696
+ $this->known_situation_hash = '';
697
+ }
698
+
699
+ function action_woocommerce_check_cart_items() {
700
+ $this->remove_unmatched_autocoupons();
701
  }
702
 
703
  /**
793
  /**
794
  * Remove unmatched auto-coupons from the cart.
795
  *
796
+ * @param array $valid_coupon_codes string[] Coupon codes that we know that are valid and don't need to be removed.
797
  * @return bool True if one or more coupons have been removed
798
  */
799
+ private function remove_unmatched_autocoupons( $valid_coupon_codes = array() ) {
800
  //Remove invalids
801
  $calc_needed = false;
802
  foreach ( WC()->cart->get_applied_coupons() as $coupon_code ) {
includes/plugins/WJECF_WPML.php CHANGED
@@ -24,6 +24,8 @@ if ( defined( 'ABSPATH' ) && ! class_exists( 'WJECF_WPML' ) ) {
24
  //WJECF_Controller hooks
25
  add_filter( 'wjecf_get_product_id', array( $this, 'filter_get_product_id' ), 10 );
26
  add_filter( 'wjecf_get_product_ids', array( $this, 'filter_get_product_ids' ), 10 );
 
 
27
  add_filter( 'woocommerce_coupon_get_description', array( $this, 'filter_get_coupon_description' ), 10, 2 );
28
  }
29
  }
@@ -66,7 +68,7 @@ if ( defined( 'ABSPATH' ) && ! class_exists( 'WJECF_WPML' ) ) {
66
 
67
  $translated_object_ids = array();
68
  foreach ( $object_ids as $object_id ) {
69
- $translated_object_ids[] = apply_filters( 'wpml_object_id', $object_id, $object_type );
70
  }
71
  $this->log( 'debug', 'Translated ' . $object_type . ': ' . implode( ',', $object_ids ) . ' to: ' . implode( ',', $translated_object_ids ) );
72
  return $translated_object_ids;
24
  //WJECF_Controller hooks
25
  add_filter( 'wjecf_get_product_id', array( $this, 'filter_get_product_id' ), 10 );
26
  add_filter( 'wjecf_get_product_ids', array( $this, 'filter_get_product_ids' ), 10 );
27
+ add_filter( 'wjecf_get_product_cat_id', array( $this, 'filter_get_product_cat_id' ), 10 );
28
+ add_filter( 'wjecf_get_product_cat_ids', array( $this, 'filter_get_product_cat_ids' ), 10 );
29
  add_filter( 'woocommerce_coupon_get_description', array( $this, 'filter_get_coupon_description' ), 10, 2 );
30
  }
31
  }
68
 
69
  $translated_object_ids = array();
70
  foreach ( $object_ids as $object_id ) {
71
+ $translated_object_ids[] = apply_filters( 'wpml_object_id', $object_id, $object_type, true ); //true: return original if missing.
72
  }
73
  $this->log( 'debug', 'Translated ' . $object_type . ': ' . implode( ',', $object_ids ) . ' to: ' . implode( ',', $translated_object_ids ) );
74
  return $translated_object_ids;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: josk79
3
  Tags: woocommerce, coupons, discount
4
  Requires at least: 4.8
5
  Requires PHP: 5.4
6
- Tested up to: 4.9.8
7
- Stable tag: 3.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -20,7 +20,7 @@ Requires:
20
  * PHP 5.4 or newer (7.0+ Recommended)
21
  * WordPress 4.8 or newer
22
 
23
- For compatibility with older versions of WooCommerce, please use "WooCommerce Extended Coupon Features" version 2.6.3.
24
 
25
  Full documentation is available at [www.soft79.nl](http://www.soft79.nl/documentation/wjecf).
26
 
@@ -101,6 +101,12 @@ On the settings page (Settings > WooCommerce Extended Coupon Features) check the
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
104
  = 3.0.2 =
105
  *Release Date - 2018-09-03*
106
  * FIX: Email restrictions compatibility with WooCommerce versions prior to 3.4
3
  Tags: woocommerce, coupons, discount
4
  Requires at least: 4.8
5
  Requires PHP: 5.4
6
+ Tested up to: 4.9.9
7
+ Stable tag: 3.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
20
  * PHP 5.4 or newer (7.0+ Recommended)
21
  * WordPress 4.8 or newer
22
 
23
+ For compatibility with older versions of WooCommerce, please use "WooCommerce Extended Coupon Features" version 2.6.4.
24
 
25
  Full documentation is available at [www.soft79.nl](http://www.soft79.nl/documentation/wjecf).
26
 
101
 
102
  == Changelog ==
103
 
104
+ = 3.0.3 =
105
+ *Release Date - 2018-10-12*
106
+ * FIX: Auto coupons: silently remove invalid coupons
107
+ * FIX: WPML compatibility issue with "CATEGORIES AND"
108
+ * (PRO) FIX: CSS of the column system (box-sizing: border-box)
109
+
110
  = 3.0.2 =
111
  *Release Date - 2018-09-03*
112
  * FIX: Email restrictions compatibility with WooCommerce versions prior to 3.4
woocommerce-jos-autocoupon.php CHANGED
@@ -3,11 +3,11 @@
3
  * Plugin Name: WooCommerce Extended Coupon Features FREE
4
  * Plugin URI: http://www.soft79.nl
5
  * Description: Additional functionality for WooCommerce Coupons.
6
- * Version: 3.0.2
7
  * Author: Soft79
8
  * License: GPL2
9
  * WC requires at least: 3.0.0
10
- * WC tested up to: 3.4.5
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
15
  }
16
 
17
  if ( ! defined( 'WJECF_VERSION' ) ) {
18
- define( 'WJECF_VERSION', '3.0.2' );
19
  }
20
 
21
  // NOTE: This file must be compatible with old PHP versions. All other files can be PHP 5.4+ .
3
  * Plugin Name: WooCommerce Extended Coupon Features FREE
4
  * Plugin URI: http://www.soft79.nl
5
  * Description: Additional functionality for WooCommerce Coupons.
6
+ * Version: 3.0.3
7
  * Author: Soft79
8
  * License: GPL2
9
  * WC requires at least: 3.0.0
10
+ * WC tested up to: 3.5.0
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
15
  }
16
 
17
  if ( ! defined( 'WJECF_VERSION' ) ) {
18
+ define( 'WJECF_VERSION', '3.0.3' );
19
  }
20
 
21
  // NOTE: This file must be compatible with old PHP versions. All other files can be PHP 5.4+ .