Accept cart item values in is_valid_for_product method and pass these to the woocommerce_coupon_is_valid_for_product filter
This commit is contained in:
parent
504253c909
commit
00c77d1716
|
@ -474,9 +474,9 @@ class WC_Coupon {
|
||||||
* @param WC_Product $product
|
* @param WC_Product $product
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function is_valid_for_product( $product ) {
|
public function is_valid_for_product( $product, $values ) {
|
||||||
if ( $this->type != 'fixed_product' && $this->type != 'percent_product' )
|
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;
|
$valid = false;
|
||||||
$product_cats = wp_get_post_terms( $product->id, 'product_cat', array( "fields" => "ids" ) );
|
$product_cats = wp_get_post_terms( $product->id, 'product_cat', array( "fields" => "ids" ) );
|
||||||
|
@ -516,7 +516,7 @@ class WC_Coupon {
|
||||||
$valid = false;
|
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue