WC_Payment_Token::__construct( mixed $token = '' )
Initialize a payment token.
Description Description
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
Parameters Parameters
- $token
-
(Optional) Token.
Default value: ''
Source Source
File: includes/abstracts/abstract-wc-payment-token.php
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 );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |