After updating commerce module to version 7.x-1.0-beta4, I receive the error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'order_number': INSERT INTO {commerce_order}(order_number, revision_id, type, uid, mail, status, created, changed, hostname, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 0 …
When I truncate the "commerce_order" table, and click the "add to cart" button, the first time data is entering the DB, but on the website I still receive "the website encountered an unexpected error. Please try again later."
So is "db_insert_placeholder_0" causing problems or could it be because of a corrupt database?
I am using the following modules too:
Rules: 7.x-2.0-beta2
Entity API: 7.x-1.x-dev (2011-Jun-29)
Views 7.x-3.x-dev (2011-Jun-29)
Chaos tool suite 7.x-1.x-dev (2011-Jun-24)
Address Field 7.x-1.x-dev (2011-Jun-12)
In mysite/users/duo#overlay=admin/commerce/orders I see only one order entry with "create date", user and order status=Shopping cart but no order number, total or name.
Also, none of the operations are visible.
Comments
Comment #1
rszrama commentedJust truncating a table is bound to cause problems, as the data in commerce_order is tied to the data in commerce_order_revision and a number of different field data tables. This stuff is all then tied together through a couple of caches, too. I'm not sure why it would be trying to reuse order numbers, though... check your commerce_order table and see what's showing up in there. Is the order_id column auto incrementing properly?
Comment #2
jurgenr commentedThnx for your answer Ryan!
I'm starting to believe that the problem wasn't caused because of the update but different databases where added together.
Anyway I've started to truncate all related tables and the problem is fixed.
Related tables:
commerce_order
commerce_order_revision
field_data_commerce_order_total
field_revision_commerce_order_total
commerce_customer_profile
field_data_commerce_customer_address
Comment #4
krisrobinson commentedJust want to make a note here, I had the same error after migrating from Ubercart. I believe it's because ubercart order_id's and order_numbers are different and in commerce they're the same. I fixed it running an UPDATE sql statement in phpmyadmin, because I didn't want to truncate my tables with the data I just migrated. Documented here: http://drupal.org/node/1730814