7

In our Magento 2 store suddenly order id has started skipping order id by 1.

Here is the order id example:

000000011
000000013
000000015
000000017
000000019

I went through multiple posts like magento-order-number-issue and magento-order-id-increment-jumps, and they say like due to failed/in-complete payment, or customer doesn't complete all checkout steps this issue might occur.

So my question is, it should happen only in the mentioned scenarios and from next order it should work fine if there isn't any issue, but in my case it always skips 1 order. I have observed this for around 100 orders.

Few posts also suggest due to abandoned cart this issue might occur so I have truncated quote tables using below query, still issue exists.

SET FOREIGN_KEY_CHECKS=0;

TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;

SET FOREIGN_KEY_CHECKS=1;

How I can fix this?

10
  • 4
    do you have any extensions that might affect the orders? There is a chance that one extension calls reserveOrderId whithout checking if the quote has already a reserved order id. Try disabling all custom extensions and see if it happens.
    – Marius
    Commented Feb 1, 2019 at 13:31
  • 1
    can you please mention which payment getaway/extension you are using. Sometime payment extension reserve the order Id before redirecting to payment get way and after successful payment order will created with that reserve order id. Commented Feb 1, 2019 at 17:55
  • @Marius, I do have a module which modifies quote and order table. I will try disabling it, if it works.
    – amitshree
    Commented Feb 2, 2019 at 5:01
  • @PritamInfo24, I am using PayUMoney payment gateway. Though order is placed in Magento as soon as I click "Place Order" button.
    – amitshree
    Commented Feb 2, 2019 at 5:03
  • 1
    I think that assumption posted by Marius is the right way to find the problem. I would suggest to search all your source code for the calls of the method setReservedOrderId($reservedOrderId) that might guide you to the right point. If you have the possibility, I would suggest to create a plugin and hook it before that method to log all the calls with backtrace, that might give you a hint where the calls come from
    – HelgeB
    Commented Feb 4, 2019 at 8:52

2 Answers 2

3
+50

After digging into the some articles I figured out, there is no other way to make increment by 2 than this:

Magento stores order auto increment id in sequence_order_1 or sequence_order_2 table, based on stores. So it uses only 1 increment id by default. Unless someone change auto_increment_increment value of database like:

SET @@auto_increment_increment=2;

Try this command and see if your auto increment value is fixed:

SET @@auto_increment_increment=1;

I didn't find any other solution.

Note: If you are getting this issue on order increment id and it is occurring due to auto increment value, then it would be occurring on all tables, because it's a global variable

Just wanted to help :)

6
  • Few days ago I have updated auto_increment for sequence_order_1 table. After changing that, incremental id was in sequence, but later on this issue started happening.
    – amitshree
    Commented Feb 8, 2019 at 10:32
  • I think @Kamal Paliwal has the point, you need to check sales_sequence_profile value, but meta value could be anything, it could be 6 Commented Feb 8, 2019 at 10:42
  • In sequence_order_1 table AUTO_INCREMENT value is 90691 but last sequence_value is 90689 in that table.
    – amitshree
    Commented Feb 8, 2019 at 11:07
  • That's weird. Have you tried SET @@auto_increment_increment=1; on database? Commented Feb 8, 2019 at 11:19
  • 2
    Thanks Shoaib. That has helped me in the right direction to find the issue. Problem was that auto-increment-increment = 2 was set in /etc/my.cnf file. After updating it, issue is resolved.
    – amitshree
    Commented Feb 8, 2019 at 12:59
2

Do check the value of step column in sales_sequence_profile table for meta_id (5 might be different but you need to check for the order one)

3
  • You have the point, but in my case, meta value is 6. Good answer Commented Feb 8, 2019 at 10:42
  • It might be due to different Magento versions Commented Feb 8, 2019 at 10:44
  • I see value of step column is 1 for all rows in sales_sequence_profile table.
    – amitshree
    Commented Feb 8, 2019 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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