fix coupon check

This commit is contained in:
Mike Jolley 2012-03-20 18:36:25 +00:00
parent 4fe459ddc5
commit aea9f5f55e
3 changed files with 6 additions and 2 deletions

View File

@ -246,13 +246,16 @@ class WC_Cart {
$coupon = new WC_Coupon( $code ); $coupon = new WC_Coupon( $code );
if ( is_array( $coupon->customer_email ) && sizeof( $coupon->customer_email ) > 0 ) { if ( is_array( $coupon->customer_email ) && sizeof( $coupon->customer_email ) > 0 ) {
if ( is_user_logged_in() ) { if ( is_user_logged_in() ) {
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
$check_emails[] = $current_user->user_email; $check_emails[] = $current_user->user_email;
} }
$check_emails[] = $posted['billing_email']; $check_emails[] = $posted['billing_email'];
if ( ! in_array($check_emails, $coupon->customer_email) ) { $check_emails = array_map( 'strtolower', $check_emails );
if ( sizeof( array_intersect( $check_emails, $coupon->customer_email ) ) == 0 ) {
$woocommerce->add_error( sprintf( __('Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.', 'woocommerce'), $code ) ); $woocommerce->add_error( sprintf( __('Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.', 'woocommerce'), $code ) );
// Remove the coupon // Remove the coupon
unset( $this->applied_coupons[$key] ); unset( $this->applied_coupons[$key] );

View File

@ -95,7 +95,7 @@ class WC_Coupon {
$this->expiry_date = ($this->expiry_date) ? strtotime($this->expiry_date) : ''; $this->expiry_date = ($this->expiry_date) ? strtotime($this->expiry_date) : '';
$this->product_categories = array_filter(array_map('trim', (array) maybe_unserialize($this->product_categories))); $this->product_categories = array_filter(array_map('trim', (array) maybe_unserialize($this->product_categories)));
$this->exclude_product_categories = array_filter(array_map('trim', (array) maybe_unserialize($this->exclude_product_categories))); $this->exclude_product_categories = array_filter(array_map('trim', (array) maybe_unserialize($this->exclude_product_categories)));
$this->customer_email = array_filter(array_map('trim', (array) maybe_unserialize($this->customer_email))); $this->customer_email = array_filter(array_map('trim', array_map('strtolower', (array) maybe_unserialize($this->customer_email))));
return true; return true;
endif; endif;

View File

@ -149,6 +149,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Order items table (for emails) moved to template file * Tweak - Order items table (for emails) moved to template file
* Tweak - Queries on report pages to replace get_posts to resolve issues on stores with a shed load of orders * Tweak - Queries on report pages to replace get_posts to resolve issues on stores with a shed load of orders
* Tweak - Remove case sensitively from order tracking and force email lowercase on checkout * Tweak - Remove case sensitively from order tracking and force email lowercase on checkout
* Fix - User email check for coupons
* Fix - Put chosen frontend script back * Fix - Put chosen frontend script back
* Fix - Make download links use billing email, not user email * Fix - Make download links use billing email, not user email
* Fix - ' in prices (thousand separator) * Fix - ' in prices (thousand separator)