3

Ubercart order number start at 1. How can I set the order number to start with a larger number, e.g. 100001?

3

Run this query against your database:

ALTER TABLE uc_orders AUTO_INCREMENT = 100001;

The next record added will use 100001 as the ID.

Or for Postgres (Thanks @Mołot for the heads up):

SELECT setval('SEQUENCE_ID', 100001, FALSE);

You'll need to replace SEQUENCE_ID with the appropriate sequence id for the uc_orders table.

For sequence-enabled databases that lack setval (like Oracle, at least in some versions), you can:

ALTER SEQUENCE schema.sequence_id INCREMENT BY 1000;
SELECT schema.sequence_id.NEXTVAL FROM dual;
ALTER SEQUENCE schema.sequence_id INCREMENT BY 1;
  • 1
    For PostgreSQL, Oracle and similar, one needs to use ALTER SEQUENCE instead. Can't find Drupal's default sequence names now. – Mołot May 22 '13 at 14:37
  • Good point, thanks - I don't stray very far from Maria/MySQL with relational DBs these days, totally forgot about those – Clive May 22 '13 at 14:40
  • Now we need someone with postgre & ubercart to update your answer with full query ;) – Mołot May 22 '13 at 14:41
  • 1
    Sequences works alike in both (in ibm db2 too), at least when all you want is to increment by 1, so your answer should be valid for pretty much any sequence-enabled database. – Mołot May 22 '13 at 14:49
  • 1
    Oh my, I forgot Oracle has some problems. Edited your answer to address them. – Mołot May 22 '13 at 14:57
0

Other approach is to make order number not sequential. You may dislike the idea that user can count total orders between his orders - if he orders some minor stuff every month, he knows your monthly order volume, and that's bad. "Sanitization" of order number to prevent this was discussed here on ubercart.org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.