Database Error During Checkout

Hello



This error seems to have popped up at random during the checkout process at my store. We’re currently running on 4.3.3 version. Please help!



Tygh\Exceptions\AException



Message

[color=#000000][font=Times][size=4]

Duplicate entry ‘16777215’ for key ‘PRIMARY’ b[/b][/size][/font][/color][color=#000000][font=Times][size=4]

INSERT INTO cscart_orders (payment_id, payment_surcharge, discount, total, subtotal, shipping_cost, promotions, subtotal_discount, profile_id, parent_order_id, user_id, tax_exempt, issuer_id, status, company_id, timestamp, email, lang_code, b_firstname, b_lastname, b_address, b_address_2, b_city, b_county, b_state, b_country, b_zipcode, b_phone, s_firstname, s_lastname, s_address, s_address_2, s_city, s_county, s_state, s_country, s_zipcode, s_phone, firstname, lastname, shipping_ids, ip_address, is_parent_order) VALUES (12, 0, 0, 1110, 1110, 0, ‘a:0:{}’, 0, 46, 0, 46, ‘N’, NULL, ‘N’, 1, 1437411510, ‘kamaldh94@gmail.com’, ‘en’, ‘Kamaljeet’, ‘Dhiman’, ‘Chandigarh’, ‘’, ‘Chandigarh’, ‘’, ‘Chandigarh’, ‘IN’, 160036, ‘’, ‘Kamaljeet’, ‘Dhiman’, ‘Chandigarh’, ‘’, ‘Chandigarh’, ‘’, ‘Chandigarh’, ‘IN’, 160036, ‘’, ‘Kamaljeet’, ‘Dhiman’, 1, ‘75dcb78b’, ‘N’)[/size][/font][/color]



Error at

[color=#000000][font=Times][size=4]

app/Tygh/Database.php, line: 714[/size][/font][/color]

Backtrace

File: app/Tygh/Database.php Line: 359 Function: error File: app/functions/fn.database.php Line: 130 Function: query File: app/functions/fn.cart.php Line: 923 Function: db_query File: app/functions/fn.cart.php Line: 1220 Function: fn_update_order File: app/functions/fn.cart.php Line: 7739 Function: fn_place_order File: app/controllers/frontend/checkout.php Line: 327 Function: fn_checkout_place_order File: app/functions/fn.control.php Line: 680 Function: include File: app/functions/fn.control.php Line: 451 Function: fn_run_controller File: index.php Line: 25 Function:

fn_dispatch







Thanks

Something is trying to create an order at the end of the checkout process where the order already exists. Is this from the customer side during checkout or from the admin side when editing an order?

Apparently, I was checking out the forums and this is a problem. This occurs for order numbers with a large number of digits (our order was 16777215. When I deleted the order, the checkout starting functioning normally. Then, I changing the initial order ID to 101 in General backend settings. However, even though the checkout after this change was successful, it was still with the order ID 16777215, and again the checkout started showing “Service Unavailable”.

Looks like the maximum value for the auto_increment property of the 'order_id' field in this table is 16777215. You should make this field use an int type:



MySQL :: MySQL 8.0 Reference Manual :: 11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT



It can be changed in the phpMyAdmin

Is there a way to reset it to a number like 100?

It is not recommended. You can get errors in the future:

Alright, thanks. For now, we need to change it to a lesser value, and have contacted the CS-Cart team. Will let you know when they fix it.

To maintain your order numbers, you will have to change the type of the order_id from an unsigned mediumint(8) to an unsigned int(11) in your database. But you will also have to change that schema in many other tables for consistency. This shouldn’t cause you upgrade problems/issues but might in the future. Note also that in many other tables there is an ‘object_id’ that will also need to be extended to properly handle your large order numbers.