WC_Discounts::validate_coupon_sale_items() protected WC 3.2.0
Ensure coupon is valid for sale items in the list is valid or throw exception.
{} Это метод класса: WC_Discounts{}
Хуков нет.
Возвращает
true/false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->validate_coupon_sale_items( $coupon );
- $coupon(WC_Coupon) (обязательный)
- Coupon data.
Список изменений
С версии 3.2.0 | Введена. |
Код WC_Discounts::validate_coupon_sale_items() WC Discounts::validate coupon sale items WC 5.0.0
protected function validate_coupon_sale_items( $coupon ) {
if ( $coupon->get_exclude_sale_items() ) {
$valid = true;
foreach ( $this->get_items_to_validate() as $item ) {
if ( $item->product && $item->product->is_on_sale() ) {
$valid = false;
break;
}
}
if ( ! $valid ) {
throw new Exception( __( 'Sorry, this coupon is not valid for sale items.', 'woocommerce' ), 110 );
}
}
return true;
}