WC_Coupon::set_amount() public WC 3.0.0
Set amount.
{} Это метод класса: WC_Coupon{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WC_Coupon = new WC_Coupon(); $WC_Coupon->set_amount( $amount );
- $amount(float) (обязательный)
- Amount.
Список изменений
С версии 3.0.0 | Введена. |
Код WC_Coupon::set_amount() WC Coupon::set amount WC 5.0.0
public function set_amount( $amount ) {
$amount = wc_format_decimal( $amount );
if ( ! is_numeric( $amount ) ) {
$amount = 0;
}
if ( $amount < 0 ) {
$this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) );
}
if ( 'percent' === $this->get_discount_type() && $amount > 100 ) {
$this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) );
}
$this->set_prop( 'amount', $amount );
}