is_valid功能核心代碼如何刪除is_valid
功能$this->validate_product_categories();
在WooCommerce class-wc-coupon.php
文件,而無需編輯插件?旁路validate_product_categories()在類WC_Coupon
在functions.php中有這樣做的鉤子嗎?
這裏是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;
}
感謝
爲什麼要刪除它?你可以更新插件,並檢查是否有任何問題,並可以聯繫支持論壇的問題。強烈推薦。 –
回到你的問題的解決方案,在你的* functions.php *我想你需要覆蓋這個功能。像這樣的http://hookr.io/filters/woocommerce_coupon_is_valid/不知道。 –
也檢查這一次http://stackoverflow.com/questions/21397325/want-to-overwrite-functions-written-in-woocommerce-functions-php-file –