Reset Order number
3 years 8 months ago #348580
by Joomill
Reset Order number was created by Joomill
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?
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.
3 years 8 months ago #348585
by nicolas
Replied by nicolas on topic Reset Order number
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 )
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.
3 years 8 months ago #348589
by Joomill
Replied by Joomill on topic Reset Order number
Hi,
Thanks, but i can't remove old orders. I just need to start at 1 in the new year.
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.
3 years 8 months ago #348590
by nicolas
Replied by nicolas on topic Reset Order number
Hi,
Well, it's you who said you wanted to remove the old orders:
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.
Well, it's you who said you wanted to remove the old orders:
So I was answering to that.(with removing old orders)
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.193 seconds