WordPress at Your Fingertips
function is not described

WC_Abstract_Order::add_payment_token() public WC 2.6

Add a payment token to an order

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

Return

true|false|Int. The new token ID or false if it failed.

Usage

$WC_Abstract_Order = new WC_Abstract_Order();
$WC_Abstract_Order->add_payment_token( $token );
$token(WC_Payment_Token) (required)
Payment token object.

Changelog

Since 2.6 Introduced.

Code of WC_Abstract_Order::add_payment_token() WC 5.8.0

public function add_payment_token( $token ) {
	if ( empty( $token ) || ! ( $token instanceof WC_Payment_Token ) ) {
		return false;
	}

	$token_ids   = $this->data_store->get_payment_token_ids( $this );
	$token_ids[] = $token->get_id();
	$this->data_store->update_payment_token_ids( $this, $token_ids );

	do_action( 'woocommerce_payment_token_added_to_order', $this->get_id(), $token->get_id(), $token, $token_ids );
	return $token->get_id();
}