WC_Coupon::set_discount_type()publicWC 3.0.0

Set discount type.

Метод класса: WC_Coupon{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Coupon = new WC_Coupon();
$WC_Coupon->set_discount_type( $discount_type );
$discount_type(строка) (обязательный)
Discount type.

Список изменений

С версии 3.0.0 Введена.

Код WC_Coupon::set_discount_type() WC 8.7.0

public function set_discount_type( $discount_type ) {
	if ( 'percent_product' === $discount_type ) {
		$discount_type = 'percent'; // Backwards compatibility.
	}
	if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ), true ) ) {
		$this->error( 'coupon_invalid_discount_type', __( 'Invalid discount type', 'woocommerce' ) );
	}
	$this->set_prop( 'discount_type', $discount_type );
}