Only apply product/cat coupon checks for cart to cart coupons.
Closes #7389
This commit is contained in:
parent
0ef336d97c
commit
c71bff2844
|
@ -354,7 +354,7 @@ class WC_Coupon {
|
||||||
* Ensure coupon is valid for products in the cart is valid or throw exception
|
* Ensure coupon is valid for products in the cart is valid or throw exception
|
||||||
*/
|
*/
|
||||||
private function validate_product_ids() {
|
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;
|
$valid_for_cart = false;
|
||||||
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
|
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
|
||||||
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
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
|
* Ensure coupon is valid for product categories in the cart is valid or throw exception
|
||||||
*/
|
*/
|
||||||
private function validate_product_categories() {
|
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;
|
$valid_for_cart = false;
|
||||||
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
|
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
|
||||||
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||||
|
@ -543,19 +543,19 @@ class WC_Coupon {
|
||||||
|
|
||||||
// Specific products get the discount
|
// Specific products get the discount
|
||||||
if ( sizeof( $this->product_ids ) > 0 ) {
|
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 ) ) {
|
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;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Category discounts
|
// Category discounts
|
||||||
} elseif ( sizeof( $this->product_categories ) > 0 ) {
|
if ( sizeof( $this->product_categories ) > 0 ) {
|
||||||
|
|
||||||
if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 ) {
|
if ( sizeof( array_intersect( $product_cats, $this->product_categories ) ) > 0 ) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
if ( ! sizeof( $this->product_ids ) && ! sizeof( $this->product_categories ) ) {
|
||||||
// No product ids - all items discounted
|
// No product ids - all items discounted
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 - Typo in get_from_name method.
|
||||||
* Fix - Fix errors during checkout when mb_convert_encoding() is not supported.
|
* 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 - 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.
|
* Tweak - Only run the uninstaller if the "Uninstall on Delete" option is checked in system status.
|
||||||
|
|
||||||
= 2.3.2 - 12/02/2015 =
|
= 2.3.2 - 12/02/2015 =
|
||||||
|
|
Loading…
Reference in New Issue