WC_Coupon::set_discount_type( string $discount_type )
Set discount type.
Description Description
Parameters Parameters
- $discount_type
-
(Required) Discount type.
Source Source
File: includes/class-wc-coupon.php
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 );
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |