In WooCommerce, how to remove $this->validate_product_categories();
in is_valid function in WooCommerce class-wc-coupon.php
file without editing plugin?
Is there any hook for to do that in functions.php?
Here is the source code of class-wc-coupon.php
:
/**
* Check if a coupon is valid.
*
* @return boolean validity
* @throws Exception
*/
public function is_valid() {
try {
$this->validate_exists();
$this->validate_usage_limit();
$this->validate_user_usage_limit();
$this->validate_expiry_date();
$this->validate_minimum_amount();
$this->validate_maximum_amount();
$this->validate_product_ids();
$this->validate_product_categories();
$this->validate_sale_items();
$this->validate_excluded_items();
$this->validate_cart_excluded_items();
if ( ! apply_filters( 'woocommerce_coupon_is_valid', true, $this ) ) {
throw new Exception( self::E_WC_COUPON_INVALID_FILTERED );
}
} catch ( Exception $e ) {
echo $this->error_message = $this->get_coupon_error( $e->getMessage() );
return false;
}
return true;
}
Thanks
Read more here: Bypass validate_product_categories() in is_valid function core code for Class WC_Coupon