WC_Payment_Token::__construct()publicWC 2.6.0

Initialize a payment token.

These fields are accepted by all payment tokens: is_default - boolean Optional - Indicates this is the default payment token for a user token - string Required - The actual token to store gateway_id - string Required - Identifier for the gateway this token is associated with user_id - int Optional - ID for the user this token is associated with. 0 if this token is not associated with a user

Method of the class: WC_Payment_Token{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Payment_Token = new WC_Payment_Token();
$WC_Payment_Token->__construct( $token );
$token(mixed)
Token.
Default: ''

Changelog

Since 2.6.0 Introduced.

WC_Payment_Token::__construct() code WC 8.6.1

public function __construct( $token = '' ) {
	parent::__construct( $token );

	if ( is_numeric( $token ) ) {
		$this->set_id( $token );
	} elseif ( is_object( $token ) ) {
		$token_id = $token->get_id();
		if ( ! empty( $token_id ) ) {
			$this->set_id( $token->get_id() );
		}
	} else {
		$this->set_object_read( true );
	}

	$this->data_store = WC_Data_Store::load( 'payment-token' );
	if ( $this->get_id() > 0 ) {
		$this->data_store->read( $this );
	}
}