WordPress at Your Fingertips
function is not described

WC_Payment_Token_Data_Store::read() public WC 3.0.0

Read a token from the database.

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

Hooks from the method

Return

null. Nothing.

Usage

$WC_Payment_Token_Data_Store = new WC_Payment_Token_Data_Store();
$WC_Payment_Token_Data_Store->read( $token );
$token(WC_Payment_Token) (required) (passed by reference — &)
Payment token object.

Changelog

Since 3.0.0 Introduced.

Code of WC_Payment_Token_Data_Store::read() WC 5.8.0

public function read( &$token ) {
	global $wpdb;

	$data = $wpdb->get_row(
		$wpdb->prepare(
			"SELECT token, user_id, gateway_id, is_default FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token_id = %d LIMIT 1",
			$token->get_id()
		)
	);

	if ( $data ) {
		$token->set_props(
			array(
				'token'      => $data->token,
				'user_id'    => $data->user_id,
				'gateway_id' => $data->gateway_id,
				'default'    => $data->is_default,
			)
		);
		$this->read_extra_data( $token );
		$token->read_meta_data();
		$token->set_object_read( true );
		do_action( 'woocommerce_payment_token_loaded', $token );
	} else {
		throw new Exception( __( 'Invalid payment token.', 'woocommerce' ) );
	}
}