WC_Discounts::validate_coupon_exists
Ensure coupon exists or throw exception.
A coupon is also considered to no longer exist if it has been placed in the trash, even if the trash has not yet been emptied.
Метод класса: WC_Discounts{}
Хуков нет.
Возвращает
true|false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->validate_coupon_exists( $coupon );
- $coupon(WC_Coupon) (обязательный)
- Coupon data.
Список изменений
| С версии 3.2.0 | Введена. |
Код WC_Discounts::validate_coupon_exists() WC Discounts::validate coupon exists WC 10.8.1
protected function validate_coupon_exists( $coupon ) {
if ( ( ! $coupon->get_id() && ! $coupon->get_virtual() ) || 'trash' === $coupon->get_status() ) {
throw new Exception(
sprintf(
/* translators: %s: coupon code */
esc_html__( 'Coupon "%s" cannot be applied because it does not exist.', 'woocommerce' ),
esc_html( $coupon->get_code() )
),
105
);
}
return true;
}