WC_Payment_Token::__construct
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.
Returns
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() WC Payment Token:: construct code WC 10.5.0
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 );
}
}