WC_Order_Data_Store_CPT::set_coupon_held_keys()publicWC 1.0

Add/Update list of meta keys that are currently being used by this order to hold a coupon. This is used to figure out what all meta entries we should delete when order is cancelled/completed.

Method of the class: WC_Order_Data_Store_CPT{}

No Hooks.

Return

Mixed.

Usage

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->set_coupon_held_keys( $order, $held_keys, $held_keys_for_user );
$order(WC_Order) (required)
Order object.
$held_keys(array) (required)
Array of coupon_code => meta_key.
$held_keys_for_user(array) (required)
Array of coupon_code => meta_key for held coupon for user.

WC_Order_Data_Store_CPT::set_coupon_held_keys() code WC 9.4.2

public function set_coupon_held_keys( $order, $held_keys, $held_keys_for_user ) {
	if ( is_array( $held_keys ) && 0 < count( $held_keys ) ) {
		$order->update_meta_data( '_coupon_held_keys', $held_keys );
	}
	if ( is_array( $held_keys_for_user ) && 0 < count( $held_keys_for_user ) ) {
		$order->update_meta_data( '_coupon_held_keys_for_users', $held_keys_for_user );
	}
}