Change order number format

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #22789

Hi!

I already know WHERE I can change the order number format, but I don't know how to change it to a custom order number.

Best regards!

The following user(s) said Thank You: irfanhanfi

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
13 years 2 months ago #22790

Hi,

We explain that in the documentation:
www.hikashop.com/support/documentation/5...hop-config.html#main

Order number format : This option enables you to set the format of order numbers. It is only available in commercial versions of HikaShop. By default, the order number uses letters and numbers interleaved together. this is represented here with the tag {automatic_code}. If you want to use the order number directly, you can use the tag {id}. In the tag id, you can specify the number of numbers with the size attribute. For example, {id size="5"} will result in 00123 for the order with the id 123. You can also use the date tag in order to insert date information. For example, {date format="m/Y"} will result in 02/11 for an order made in February 2011. You can combine them to generate pretty advanced order numbers like the format RE-{id size="5"}/{date format="m/Y"} used for German accounting which will result in RE-00123/02/11 for the order 123 made on February 2011.

Last edit: 13 years 2 months ago by nicolas.
The following user(s) said Thank You: irfanhanfi

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

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #22793

Thanks for the quick response. Since I didn't see the field in the screenshot, I assumed that it would not be explained in the text.

Is there a possibility to adapt the use of {date format="Y"}. Due to the fact that our accounting year ends in February of the following year, we would like to display 2011 still in January 2012.

Best regards

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
13 years 2 months ago #22794

You can change the format of the date with lots of options:
www.php.net/manual/en/function.date.php
However, you won't be able to change the date like that.

You would have to create a hikashop plugin and implement the onBeforeOrderCreate(&$order,&$do) event in order to set the order_number field of the order before the order is created. More information on that here: www.hikashop.com/en/support/documentatio...r-documentation.html

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

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #23135

I couldn't find the order_number in the order object in onBeforeOrderCreate(&$order,&$do)

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
13 years 2 months ago #23148

Yes of course. You need to set it in that function yourself.
If you don't, the system will generate the order_number automatically when the order is created.

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

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #23358

I would like to use a custom table where I manage the new order number. Do I have to use a "LOCK TABLE" or does Joomla automatically lock the table when using the Joomla methods (e.g. $database->setQuery($query))?

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
13 years 2 months ago #23361

There is no lock table in the joomla framework and joomla extensions do not use that method as it's not needed with mysql. If you want to use it, you will have to do it in your code.

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

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #23362

nicolas wrote:

There is no lock table in the joomla framework and joomla extensions do not use that method as it's not needed with mysql. If you want to use it, you will have to do it in your code.

Why is it not needed with mysql? When I want to check which is the last order number before creating a new order number, couldn't it be, that two users get the same result?

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
13 years 2 months ago #23365

Usually, when you use mysql, you have an auto incremented primary column in your tables. So MySQL handle itself the generation of the id for each entry and you should not set it yourself. That's what we do with HikaShop's tables. All the tables have a primary key which is auto increment, and it's mysql which attributes the id so there is no need for transactions. Then, once you did your insert, you can run another query to get the id generated if you need it. There is a function for that in Joomla:
$id = $database->insertid()

There is of course a small probability that an insert has been done between your insert and that function call, in which case you wouldn't get the correct id. That's however how Joomla handles the inserts and I've never seen a problem with that. Of course, you can always add your lock table yourself in your code to reduce that probability to 0.

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

  • Posts: 137
  • Thank you received: 2
13 years 2 months ago #23367

Our accounting year starts, as I mentioned above, with the 1st february. From the 1st february we would like to start again at id 1 for the order number.

E.g. bought on

31.1.2011 > order number = 2010-05421
1.2.2011 > order number = 2011-00001

Therefore I have to use LOCK TABLE in the plugin.

Thanks for the explanation!

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

  • Posts: 5
  • Thank you received: 1
12 years 10 months ago #31696

How can i change order ID number with customer business VAT number. eg.customer{address_vat}-{id size="3"}-{date format="m-Y"}
VAT NUMBER have 8 numbers+ invoice numer with 3 digits+ {date format="m-y"}
Thanks to everyone...

Andrej

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
12 years 10 months ago #31728

The address information is not supported in order numbers.
What you could do is unpublish the address VAT number custom field via the menu Display->Custom fields and create a new custom USER field for the VAT number.
For example, if you called it user_vat, your order numbers would look like :
{user user_vat}-{id size="3"}-{date format="m-Y"}

The downside of using a custom user field instead of the one already in HikaShop is that the customers type (with or without a vat number) won't be detected by HikaShop's tax system so if you need to have the VAT applied based on whether the user provided that information or not, that won't be possible. Also, there won't be any check on the VAT number validity.

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

  • Posts: 32
  • Thank you received: 1
  • Hikashop Essential
6 years 4 months ago #294078

Joomla! 3.8.8
HikaShop Essential 3.4.0

Is it possible to generate order numerc/codes in this format:
EHTRPSUSK
IQCDCFGEQ
QHOFPZSOC
etc.
etc.

Rgds,

Petter

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
6 years 4 months ago #294092

Hi,

There is no option for that.
However, you can implement the trigger onBeforeOrderNumberGenerate(&$order, &$result) in a plugin of the group "hikashop"
Just set the order number you generated with your custom code in $result so that the order being created will use that number.
docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla

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

  • Posts: 32
  • Thank you received: 1
  • Hikashop Essential
6 years 4 months ago #294244

Thanks Nicolas,

I suppose it's doable.

Anyone done this?

Rgds,

Petter

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
6 years 4 months ago #294258

Hi,

We did for some client, but we can't share the code.
Note however that it's really not difficult for an average PHP developer.
If you want, you can ask our partners:
www.hikashop.com/home/our-partners.html

The following user(s) said Thank You: Bouncer

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

Time to create page: 0.097 seconds
Powered by Kunena Forum