WordPress at Your Fingertips
function is not described

WC_Coupon::set_discount_type() public WC 3.0.0

Set discount type.

{} It's a method of the class: WC_Coupon{}

No Hooks.

Return

null. Nothing.

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.

Code of WC_Coupon::set_discount_type() WC 5.7.1

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 );
}