WordPress at Your Fingertips
function is not described

WC_Abstract_Order::hold_coupon() private WC 1.0

Hold coupon if a global usage limit is defined.

{} It's a method of the class: WC_Abstract_Order{}

No Hooks.

Return

String. Meta key which indicates held coupon.

Usage

// private - for code of main (parent) class only
$result = $this->hold_coupon( $coupon );
$coupon(WC_Coupon) (required)
Coupon object.

Code of WC_Abstract_Order::hold_coupon() WC 5.8.0

private function hold_coupon( $coupon ) {
	$result = $coupon->get_data_store()->check_and_hold_coupon( $coupon );
	if ( false === $result ) {
		// translators: Actual coupon code.
		throw new Exception( sprintf( __( 'An unexpected error happened while applying the Coupon %s.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
	} elseif ( 0 === $result ) {
		// translators: Actual coupon code.
		throw new Exception( sprintf( __( 'Coupon %s was used in another transaction during this checkout, and coupon usage limit is reached. Please remove the coupon and try again.', 'woocommerce' ), esc_html( $coupon->get_code() ) ) );
	}
	return $result;
}