WC_Order_Data_Store_CPT::get_coupon_held_keys( WC_Order $order, int $coupon_id = null )

Return array of coupon_code => meta_key for coupon which have usage limit and have tentative keys.


Description Description

Pass $coupon_id if key for only one of the coupon is needed.


Parameters Parameters

$order

(Required) Order object.

$coupon_id

(Optional) If passed, will return held key for that coupon.

Default value: null


Top ↑

Return Return

(array|string) Key value pair for coupon code and meta key name. If $coupon_id is passed, returns meta_key for only that coupon.


Top ↑

Source Source

File: includes/data-stores/class-wc-order-data-store-cpt.php

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


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.