- Posts: 640
- Thank you received: 16
Format order number format and invoice number format with autoincremental
- PeterChain
-
Topic Author
- Offline
Less
More
8 years 6 months ago #288831
by PeterChain
-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.1
Hi,
I'm adjusting the format for "Order number format" and "Invoice Number Format", and now I have something like that:
M{date format="y"}{id size="4"} -> for order number
F{date format="y"}{id size="4"} -> for invoice number
But that's not what I need. I need the "id" to be an autoincremental number (begining with 1) that every year resets.
For example, if in 2018 we have 300 orders, the last format it would be "M180300" and the next year it will begin with "M190001".
I'm doing it in the Hikashop configuration options -> Main -> order.
How can I do this?
Thanks in advance.
--
Victor
-- Joomla version -- : 3.8.1
Hi,
I'm adjusting the format for "Order number format" and "Invoice Number Format", and now I have something like that:
M{date format="y"}{id size="4"} -> for order number
F{date format="y"}{id size="4"} -> for invoice number
But that's not what I need. I need the "id" to be an autoincremental number (begining with 1) that every year resets.
For example, if in 2018 we have 300 orders, the last format it would be "M180300" and the next year it will begin with "M190001".
I'm doing it in the Hikashop configuration options -> Main -> order.
How can I do this?
Thanks in advance.
--
Victor
Please Log in or Create an account to join the conversation.
8 years 6 months ago #288833
by nicolas
Replied by nicolas on topic Format order number format and invoice number format with autoincremental
Hi,
For the invoice number, it's configured properly to do that.
So you should already have the invoice number reset like you want at each new year.
However, there is no such capability for the order number. The order number is based on the order_id which is incremented automatically by MySQL when it adds a new entry in the hikashop_order table. There is no way to reset that number every year besides deleting all the orders and resetting the auto_increment of the MySQL table, which is probably not something you'll want to do.
In that case, the only solution would be to develop a plugin and implement the onBeforeOrderNumberGenerate(&$data, &$result) trigger and set the order number you want in order $result variable based on the data of the order in $data. And for that, you would have to create a custom order field to store the increment, updating it manually yourself in your plugin, and reseting it when necessary yourself in your plugin.
For the invoice number, it's configured properly to do that.
So you should already have the invoice number reset like you want at each new year.
However, there is no such capability for the order number. The order number is based on the order_id which is incremented automatically by MySQL when it adds a new entry in the hikashop_order table. There is no way to reset that number every year besides deleting all the orders and resetting the auto_increment of the MySQL table, which is probably not something you'll want to do.
In that case, the only solution would be to develop a plugin and implement the onBeforeOrderNumberGenerate(&$data, &$result) trigger and set the order number you want in order $result variable based on the data of the order in $data. And for that, you would have to create a custom order field to store the increment, updating it manually yourself in your plugin, and reseting it when necessary yourself in your plugin.
The following user(s) said Thank You: PeterChain
Please Log in or Create an account to join the conversation.
- PeterChain
-
Topic Author
- Offline
Less
More
- Posts: 640
- Thank you received: 16
8 years 6 months ago #288898
by PeterChain
Replied by PeterChain on topic Format order number format and invoice number format with autoincremental
Hi again,
So, there's no token besides id to count numbers periodically, like {COUNT} or {AUTOINCREMENTAL} or something like that?
Thanks in advance, and thanks for the idea.
--
Victor
So, there's no token besides id to count numbers periodically, like {COUNT} or {AUTOINCREMENTAL} or something like that?
Thanks in advance, and thanks for the idea.
--
Victor
Please Log in or Create an account to join the conversation.
8 years 6 months ago #288900
by nicolas
Replied by nicolas on topic Format order number format and invoice number format with autoincremental
Hi,
No, there is no other tag for that. The system bases itself on the order_id and order_invoice_id columns of the hikashop_order table.
No, there is no other tag for that. The system bases itself on the order_id and order_invoice_id columns of the hikashop_order table.
Please Log in or Create an account to join the conversation.
Time to create page: 0.176 seconds