Automatically update commerce_order's auto_increment value after importing orders

Created on 10 October 2012, over 12 years ago
Updated 4 May 2025, 2 months ago

We are migrating a site from an osCommerce installation, maintaining all of the old order numbers. This means that the order_id and order_number are out of sync, but both numeric. That's fine, and Commerce allows it.

However, on the new Commerce site, anytime a new order is created, we get an integrity constraint violation, because the order number already exists. That's because the next order_id to be inserted in the database already exists as an order_number. So it crashes.

Should commerce_order_commerce_order_insert first check if the order_number already exists before blindly setting the order_number to the order_id?

In our case, it stops the site from working. Should we implment hook_commerce_order_insert(). Would that be called INSTEAD of the default order module implementation? The quick, dirty solution is just to set the auto_increment higher, but I wanted to log this error.

Thanks.

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jazzdrive3 Louisville, KY

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024