Patch for Ubercart hidden checkout error
Patch for Ubercart hidden checkout error | |
Uc_cart version: 6.x-2.15 | |
Drupal version: 6.38 | |
Ubercart hidden checkout error: | |
No error message appeared when the database connection error occurred. | |
The drupal user wasn't created and the customer received only one email (below) with the account settings but the username was empty. | |
The order remained in the state "in checkout". | |
This uc_cart patch solves the problem. The customer is redirected to | |
cart/checkout, infornation is written to log and one of these messages appears: | |
English: "We're sorry. An error occurred while processing your order. Please submit it again." | |
Czech: "Omlouváme se, při zpracování vaší objednávky došlo k chybě. Odešlete ji prosím znovu." | |
Sovak: "Ospravedlňujeme sa, pri spracovaní vašej objednávky došlo k chybe. Odošlite ju prosím znova." | |
The wrong email: | |
===== | |
Subject: Account details for Customer at Site | |
, | |
Thank you for registering at Site. You may now log in to ... using the following username and password: | |
username: | |
password: Password | |
You may also log in by clicking on this link or copying and pasting it in your browser: | |
... | |
This is a one-time login, so it can be used only once. | |
After logging in, you will be redirected to ... so you can change your password. | |
Site | |
===== |
diff --git a/www/sites/all/modules/ubercart/uc_cart/uc_cart.module b/www/sites/all/modules/ubercart/uc_cart/uc_cart.module | |
--- a/www/sites/all/modules/ubercart/uc_cart/uc_cart.module | |
+++ b/www/sites/all/modules/ubercart/uc_cart/uc_cart.module | |
@@ -1185,6 +1185,24 @@ function uc_cart_continue_shopping_url($unset = TRUE) { | |
return $url; | |
} | |
+function uc_cart_check_db_status($return_value) { | |
+ global $language; | |
+ if ($return_value === FALSE) { | |
+ $msg = "We're sorry. An error occurred while processing your order. Please submit it again."; | |
+ if ($language->language == "cs") { | |
+ $msg = "Omlouváme se, při zpracování vaší objednávky došlo k chybě. Odešlete ji prosím znovu."; | |
+ } elseif ($language->language == "sk") { | |
+ $msg = "Ospravedlňujeme sa, pri spracovaní vašej objednávky došlo k chybe. Odošlite ju prosím znova."; | |
+ } | |
+ watchdog('website', 'Database error. Redirecting to cart/checkout.'); | |
+ drupal_set_message($msg, "error"); | |
+ drupal_goto('cart/checkout'); | |
+ module_invoke_all('exit'); | |
+ exit; | |
+ } | |
+ return $return_value; | |
+} | |
+ | |
/** | |
* Completes a sale, including adjusting order status and creating user account. | |
* | |
@@ -1207,10 +1225,10 @@ function uc_cart_complete_sale($order, $login = FALSE) { | |
uc_cart_complete_sale_account($order); | |
// Store account data. | |
- db_query("UPDATE {uc_orders} SET uid = %d, data = '%s' WHERE order_id = %d", $order->uid, serialize($order->data), $order->order_id); | |
+ uc_cart_check_db_status(db_query("UPDATE {uc_orders} SET uid = %d, data = '%s' WHERE order_id = %d", $order->uid, serialize($order->data), $order->order_id)); | |
// Move an order's status from "In Checkout" to "Pending" | |
- $status = db_result(db_query("SELECT order_status FROM {uc_orders} WHERE order_id = %d", $order->order_id)); | |
+ $status = db_result(uc_cart_check_db_status(db_query("SELECT order_status FROM {uc_orders} WHERE order_id = %d", $order->order_id))); | |
if (uc_order_status_data($status, 'state') == 'in_checkout') { | |
$status = uc_order_state_default('post_checkout'); | |
if (uc_order_update_status($order->order_id, $status)) { | |
@@ -1294,7 +1312,7 @@ function uc_cart_complete_sale_account($order) { | |
} | |
// Create the account. | |
- $account = user_save('', $fields); | |
+ $account = uc_cart_check_db_status(user_save('', $fields)); | |
// Override the password, if specified. | |
if (isset($order->data['new_user']['hash'])) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment