Format order number format and invoice number format with autoincremental

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 3 weeks ago #288831

-- 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

Attachments:

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
6 years 3 weeks ago #288833

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.

The following user(s) said Thank You: PeterChain

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

  • Posts: 634
  • Thank you received: 16
  • Hikashop Business
6 years 3 weeks ago #288898

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

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

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
6 years 3 weeks ago #288900

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.

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

Time to create page: 0.051 seconds
Powered by Kunena Forum