WC_Coupon::get_short_info()
Get the coupon information that is needed to reapply the coupon to an existing order. This information is intended to be stored as a meta value in the order line item corresponding to the coupon and should NOT be modified or extended (additional/custom data should go in a separate metadata entry).
The information returned is a JSON-encoded string of an array with the following coupon information:
0: Id
1: Code
2: Type, null is equivalent to 'fixed_cart'
3: Nominal amount (either a fixed amount or a percent, depending on the coupon type)
4: The coupon grants free shipping? (present only if true)
Method of the class: WC_Coupon{}
No Hooks.
Return
String
. A JSON string with information that allows the coupon to be reapplied to an existing order.
Usage
$WC_Coupon = new WC_Coupon(); $WC_Coupon->get_short_info(): string;
WC_Coupon::get_short_info() WC Coupon::get short info code WC 9.4.2
public function get_short_info(): string { $type = $this->get_discount_type(); $info = array( $this->get_id(), $this->get_code(), 'fixed_cart' === $type ? null : $type, (float) $this->get_prop( 'amount' ), ); if ( $this->get_free_shipping() ) { $info[] = true; } return wp_json_encode( $info ); }