Merge pull request #6507 from chrisnharvey/master

Pass cart item values to is_valid_for_product method in WC_Coupon
This commit is contained in:
Mike Jolley 2014-10-17 12:09:23 +01:00
commit 5ff8f65d1f
2 changed files with 4 additions and 4 deletions

View File

@ -1741,7 +1741,7 @@ class WC_Cart {
$coupon = new WC_Coupon( $code );
if ( $coupon->apply_before_tax() && $coupon->is_valid() ) {
if ( $coupon->is_valid_for_product( $values['data'] ) || $coupon->is_valid_for_cart() ) {
if ( $coupon->is_valid_for_product( $values['data'], $values ) || $coupon->is_valid_for_cart() ) {
$discount_amount = $coupon->get_discount_amount( $price, $values, $single = true );
$price = max( $price - $discount_amount, 0 );

View File

@ -477,9 +477,9 @@ class WC_Coupon {
* @param WC_Product $product
* @return boolean
*/
public function is_valid_for_product( $product ) {
public function is_valid_for_product( $product, $values = array() ) {
if ( $this->type != 'fixed_product' && $this->type != 'percent_product' )
return apply_filters( 'woocommerce_coupon_is_valid_for_product', false, $product, $this );
return apply_filters( 'woocommerce_coupon_is_valid_for_product', false, $product, $this, $values );
$valid = false;
$product_cats = wp_get_post_terms( $product->id, 'product_cat', array( "fields" => "ids" ) );
@ -519,7 +519,7 @@ class WC_Coupon {
$valid = false;
}
return apply_filters( 'woocommerce_coupon_is_valid_for_product', $valid, $product, $this );
return apply_filters( 'woocommerce_coupon_is_valid_for_product', $valid, $product, $this, $values );
}
/**