WC_Order_Data_Store_CPT::get_coupon_held_keys()publicWC 1.0

Return array of coupon_code => meta_key for coupon which have usage limit and have tentative keys. Pass $coupon_id if key for only one of the coupon is needed.

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

Хуков нет.

Возвращает

Массив|Строку. Key value pair for coupon code and meta key name. If $coupon_id is passed, returns meta_key for only that coupon.

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

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->get_coupon_held_keys( $order, $coupon_id );
$order(WC_Order) (обязательный)
Order object.
$coupon_id(int)
If passed, will return held key for that coupon.
По умолчанию: null

Код WC_Order_Data_Store_CPT::get_coupon_held_keys() WC 8.7.0

public function get_coupon_held_keys( $order, $coupon_id = null ) {
	$held_keys = $order->get_meta( '_coupon_held_keys' );
	if ( $coupon_id ) {
		return isset( $held_keys[ $coupon_id ] ) ? $held_keys[ $coupon_id ] : null;
	}
	return $held_keys;
}