WC_Coupon::set_discount_type()
Set discount type.
Method of the class: WC_Coupon{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Coupon = new WC_Coupon(); $WC_Coupon->set_discount_type( $discount_type );
- $discount_type(string) (required)
- Discount type.
Changelog
Since 3.0.0 | Introduced. |
WC_Coupon::set_discount_type() WC Coupon::set discount type code WC 9.4.2
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 ); }