diff --git a/includes/class-wc-coupon.php b/includes/class-wc-coupon.php index 681f79a6ffc..b82c808d92e 100644 --- a/includes/class-wc-coupon.php +++ b/includes/class-wc-coupon.php @@ -354,7 +354,7 @@ class WC_Coupon { * Ensure coupon is valid for products in the cart is valid or throw exception */ private function validate_product_ids() { - if ( sizeof( $this->product_ids ) > 0 ) { + if ( sizeof( $this->product_ids ) > 0 && ! $this->is_type( array( 'fixed_product', 'percent_product' ) ) ) { $valid_for_cart = false; if ( sizeof( WC()->cart->get_cart() ) > 0 ) { foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { @@ -373,7 +373,7 @@ class WC_Coupon { * Ensure coupon is valid for product categories in the cart is valid or throw exception */ private function validate_product_categories() { - if ( sizeof( $this->product_categories ) > 0 ) { + if ( sizeof( $this->product_categories ) > 0 && ! $this->is_type( array( 'fixed_product', 'percent_product' ) ) ) { $valid_for_cart = false; if ( sizeof( WC()->cart->get_cart() ) > 0 ) { foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { @@ -543,19 +543,19 @@ class WC_Coupon { // Specific products get the discount if ( sizeof( $this->product_ids ) > 0 ) { - if ( in_array( $product->id, $this->product_ids ) || ( isset( $product->variation_id ) && in_array( $product->variation_id, $this->product_ids ) ) || in_array( $product->get_parent(), $this->product_ids ) ) { $valid = true; } + } // Category discounts - } elseif ( sizeof( $this->product_categories ) > 0 ) { - + if ( sizeof( $this->product_categories ) > 0 ) { if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 ) { $valid = true; } + } - } else { + if ( ! sizeof( $this->product_ids ) && ! sizeof( $this->product_categories ) ) { // No product ids - all items discounted $valid = true; } diff --git a/readme.txt b/readme.txt index 06ea8f31876..dfbdb2d9aca 100644 --- a/readme.txt +++ b/readme.txt @@ -142,6 +142,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Typo in get_from_name method. * Fix - Fix errors during checkout when mb_convert_encoding() is not supported. * Fix - Change hooks used to output post columns - fixes columns after quick edit. +* Fix - Only apply product/cat coupon checks for cart to cart coupons. * Tweak - Only run the uninstaller if the "Uninstall on Delete" option is checked in system status. = 2.3.2 - 12/02/2015 =