Only apply product/cat coupon checks for cart to cart coupons.

Closes #7389
This commit is contained in:
Mike Jolley 2015-02-12 16:15:28 +00:00
parent 0ef336d97c
commit c71bff2844
2 changed files with 7 additions and 6 deletions

View File

@ -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;
}

View File

@ -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 =