WC_Payment_Token_Data_Store::set_default_status()publicWC 3.0.0

Update's a tokens default status in the database. Used for quickly looping through tokens and setting their statuses instead of creating a bunch of objects.

Method of the class: WC_Payment_Token_Data_Store{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Payment_Token_Data_Store = new WC_Payment_Token_Data_Store();
$WC_Payment_Token_Data_Store->set_default_status( $token_id, $status );
$token_id(int) (required)
Token ID.
$status(true|false)
Whether given payment token is the default payment token or not.
Default: true

Changelog

Since 3.0.0 Introduced.

WC_Payment_Token_Data_Store::set_default_status() code WC 9.4.2

public function set_default_status( $token_id, $status = true ) {
	global $wpdb;
	$wpdb->update(
		$wpdb->prefix . 'woocommerce_payment_tokens',
		array( 'is_default' => (int) $status ),
		array(
			'token_id' => $token_id,
		)
	);
}