/** * Update a payment token. * * @since 2.7.0 * @param WC_Payment_Token $token */ public function update(&$token) { if (false === $token->validate()) { throw new Exception(__('Invalid or missing payment token fields.', 'woocommerce')); } global $wpdb; $payment_token_data = array('gateway_id' => $token->get_gateway_id('edit'), 'token' => $token->get_token('edit'), 'user_id' => $token->get_user_id('edit'), 'type' => $token->get_type('edit')); $wpdb->update($wpdb->prefix . 'woocommerce_payment_tokens', $payment_token_data, array('token_id' => $token->get_id('edit'))); $token->save_meta_data(); $token->apply_changes(); // Make sure all other tokens are not set to default if ($token->is_default() && $token->get_user_id() > 0) { WC_Payment_Tokens::set_users_default($token->get_user_id(), $token->get_id()); } do_action('woocommerce_payment_token_updated', $token->get_id()); }