Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::update_payment_token_ids()publicWC 1.0

Update token ids for an order.

Method of the class: OrdersTableDataStore{}

No Hooks.

Return

null. Nothing (null).

Usage

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->update_payment_token_ids( $order, $token_ids );
$order(WC_Order) (required)
Order object.
$token_ids(array) (required)
Payment token ids.

OrdersTableDataStore::update_payment_token_ids() code WC 8.9.0

public function update_payment_token_ids( $order, $token_ids ) {
	$meta          = new \WC_Meta_Data();
	$meta->key     = '_payment_tokens';
	$meta->value   = $token_ids;
	$existing_meta = $this->data_store_meta->get_metadata_by_key( $order, '_payment_tokens' );
	if ( $existing_meta ) {
		$existing_meta = $existing_meta[0];
		$meta->id      = $existing_meta->id;
		$this->data_store_meta->update_meta( $order, $meta );
	} else {
		$this->data_store_meta->add_meta( $order, $meta );
	}
}