Reset Order number

  • Posts: 200
  • Thank you received: 9
  • Hikashop Multisite
1 year 2 months ago #348580

Hi,

I can reset the invoice number every year, but i would like to reset the order number also. (with removing old orders) and
keep the order id and invoice id the same.

Is there a way to do this?

Please Log in or Create an account to join the conversation.

  • Posts: 81377
  • Thank you received: 13037
  • MODERATOR
1 year 2 months ago #348585

Hi,

You need to use {order_id} instead of {id} in the "invoice number format" so that it will use the order_id and not the order_invoice_id for the invoice number, like for the order number.
To reset the order_id (and thus the order_number generated from it), you need to remove all the orders from the hikashop_order table :
www.quora.com/How-do-I-truncate-a-MySQL-...sing-Xamp-phpMyAdmin
It should both remove all the orders and reset the auto_increment value of the table (which can be changed manually if necessary after removing all the entries: dba.stackexchange.com/questions/43812/ho...t-to-1-in-phpmyadmin )

Please Log in or Create an account to join the conversation.

  • Posts: 200
  • Thank you received: 9
  • Hikashop Multisite
1 year 2 months ago #348589

Hi,

Thanks, but i can't remove old orders. I just need to start at 1 in the new year.

Please Log in or Create an account to join the conversation.

  • Posts: 81377
  • Thank you received: 13037
  • MODERATOR
1 year 2 months ago #348590

Hi,

Well, it's you who said you wanted to remove the old orders:

(with removing old orders)

So I was answering to that.

The order number is generated from the order_id. The order_id is automatically incremented for each new order created. For the order number to start at 1 in the new year, it means that the order_id also need to start at 1 and thus the order table has to be emptied.

If you want to reset the order number at 1 every year without deleting all the orders, it requires the development of a plugin.
You would have to implement the event onBeforeOrderNumberGenerate(&$data, &$result) in your custom plugin.
In it, you would first load the maximum order_number of all the orders already created since the 1st day of the current year with a MySQL query, and then increment it by 1 and set $result with that new number.

Please Log in or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum