[Skip to main content](#vessel-content)

#   Even Order number format

##

- **[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")**
- [![pepecortez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31475-pepecortez "View pepecortez's Profile") Topic Author
- [ Offline](/forum/user/31475-pepecortez)

Less More

- Posts: 171
- Thank you received: 9
-
-

12 years 4 months ago -  12 years 4 months ago [\#162109](#162109) by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")  *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#162109 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")* was created by *[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")*

Hi,

We have multiple vendors, and wants to achieve to main vendor see all the orders.
A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?

Example:
We have an order number format:BIF-{id size="5"}/{date format="d/m/Y"}
The order numbers after each other are:
BIF-00002/26/06/2014
BIF-00004/26/06/2014
BIF-00006/26/06/2014
...
but it should be like
BIF-00001/26/06/2014
BIF-00002/26/06/2014
BIF-00003/26/06/2014
etc.

Also wanted to ask, is there a way to modify the automatism of creating invoice number format.
The format is: PO-{id size="5"}/{date format="d/m/Y"}
It's working as always adding +1 to each new order after it has been set to "Approved". Do we have any option/hack to be in relation with ordernumber.

Example:
Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order)
Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)

Thanks,
PePe

Last edit: 12 years 4 months ago by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

12 years 4 months ago [\#162142](#162142) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#162142 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Hi,

The order number is based on the order id.
You should see in your database why this number is growing by two. It is possible that you have one sub-sale for the main vendor.

About the invoice number, if you use "{id}" it will use the invoice id and not the order id.
The invoice id is generated when an order is confirmed in order to be sure that there is no hole in the invoice id suite.

Regarding the function " hikashop_encode " which is used to create the order number and invoice number, it is not possible to access to the "order_id" while creating the invoice number.
We will have to check when the function is called, to see if there is the order object is always passed (because we can just pass the order_id or the invoice_id) ; if so, it could be possible to update the function to access to the order_id while creating the invoice number.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")**
- [![pepecortez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31475-pepecortez "View pepecortez's Profile") Topic Author
- [ Offline](/forum/user/31475-pepecortez)

Less More

- Posts: 171
- Thank you received: 9
-
-

12 years 3 weeks ago -  12 years 3 weeks ago [\#177642](#177642) by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")  Replied by *[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177642 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

I had an idea to solve that, but maybe I complicated it too much:

As configuration is set to use the same order_id for sale and subsale as well, I should just solve somehow to load order_id not from the #__hikashop_order table's order_id column, but from a column I added manually.

So I added a new column in phpMyAdmin: 'order_bif_az' with type: int(10)
I created a hikashop plugin, with this content (used history plugin for base):
Code:

&lt;?php class plgHikashopBifupdate extends JPlugin { function plgHikashopBifupdate(&amp;$subject, $config){ parent::__construct($subject, $config); if(!isset($this-&gt;params)){ $plugin = JPluginHelper::getPlugin('hikashop', 'bifupdate'); if(version_compare(JVERSION,'2.5','&lt;')){ jimport('joomla.html.parameter'); $this-&gt;params = new JParameter($plugin-&gt;params); } else { $this-&gt;params = new JRegistry($plugin-&gt;params); } } } function onAfterOrderCreate(&amp;$order,&amp;$send_email){ $db = JFactory::getDBO(); $query = 'UPDATE '.hikashop_table('order').' SET '.hikashop_table('order').'.order_bif_az = (SELECT MAX(order_bif_az)+1) WHERE'.hikashop_table('order').'.order_id = '.$order-&gt;order_id.' AND '.hikashop_table('order').'.order_type = SALE; $db-&gt;setQuery($query); } }

This should update the freshly created order's order_bif_az row with +1

As it not worked I also tried adding SQL update query to /admin/com_hikashop/helpers/helper.php to around line 256., in function hikashop_encode: Code:

if(is_object($data)){ function hikashop_encode(&amp;$data,$type='order', $format = '') { $id = null; if(is_object($data)){ if($type=='order') $db = JFactory::getDBO(); $query = 'UPDATE '.hikashop_table('order').' SET '.hikashop_table('order').'.order_bif_az = (SELECT MAX(order_bif_az)+1) WHERE'.hikashop_table('order').'.order_id = '.$data-&gt;order_id.' AND '.hikashop_table('order').'.order_type = SALE'; $db-&gt;setQuery($query); $id = $data-&gt;order_bif_az; if($type=='invoice') $id = $data-&gt;order_invoice_id; }

I also changed line from: Code:

$id = $data-&gt;order_id;

to Code:

$id = $data-&gt;order_bif_az;

nondepending from where the SQL syntax is given (plugin or helper.php).

But update sql is not running on, also $id = $data-&gt;order_bif_az is not OK.
Where am I wrong?

Last edit: 12 years 3 weeks ago by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile"). Reason: +info

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

12 years 3 weeks ago [\#177664](#177664) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177664 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Hi,

Why not using the invoice number ?
If you change the option "invoice order statuses" in the HikaShop configuration, you can generate the invoice id (and the invoice number) when the order is created ; so you won't have any hole in the system because it is not something managed by the database.
It will do the same you are trying to do ; but it's already implemented in HikaShop.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")**
- [![pepecortez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31475-pepecortez "View pepecortez's Profile") Topic Author
- [ Offline](/forum/user/31475-pepecortez)

Less More

- Posts: 171
- Thank you received: 9
-
-

12 years 3 weeks ago [\#177698](#177698) by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")  Replied by *[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177698 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Yeah, that would be a good trick, but...
The mechanism should work this way:
Order number format is: BIF-{id size="5"}/{date format="d/m/Y"}
Invoice number is generated in this format: PO-{order_id size="5"}/{date format="d/m/Y"}

But the main problem, that we MUST give the invoice number just if / when order is APPROVED. And as not all orders are approved we can not let the system to generate it automatically when order is created... ![:(](/media/kunena/emoticons/22.png ":(")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

12 years 3 weeks ago [\#177707](#177707) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177707 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Hi,

Okay ; but because you are using the multi vendor, it creates entries in the order table for the vendor sales. So the "order_id" is growing automatically (by the database increment) and we can't do something special for that.
At least you can duplicate the used code for the "invoice_id" and use it for an another column, which will be use in the hikashop_encode function for the order number.

It is the best I can recommend you ; because the order id is unique for the entire store ; shared between your store and your vendors. There is nothing wrong in that.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")**
- [![pepecortez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31475-pepecortez "View pepecortez's Profile") Topic Author
- [ Offline](/forum/user/31475-pepecortez)

Less More

- Posts: 171
- Thank you received: 9
-
-

12 years 3 weeks ago [\#177748](#177748) by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")  Replied by *[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177748 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Yeah, that's clear, that's why I tried to solve my problem this way.

But the **main problem is, that the earlier written UPDATE SQL is not running down.** I turned on Joomla's built in Debug and Error reporting tool, but in Database checker tab, I can not find my UPDATE method, also I can not see the waited result in phpMyAdmin, in hikashop_order table, so it seems it's not running down.

Why? Can u see anything what is maybe wrong with it, what can cause it's not loaded to run?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

12 years 3 weeks ago [\#177765](#177765) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177765 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Hi,

Your plugin you wrote should update the "bif" value ; but I recommend you to:
- read the maximum in a single request ; do not try to update the value in the database
- use the onBeforeOrderCreate
- update the value directly in the object ; the order_number is generated using a value that does not exist in the object, because you're just updating the database (and maybe too late regarding when the order number is generated).

Otherwise you will have to re-create the order number yourself in your plugin and it could be a good solution if you want to keep the compatibility with updates :
- get the "bif" value
- create a fake object to call the function hikashop_encode
- get the order_number from the object
- update the object in the database
And you can do that in the afterCreate trigger.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")**
- [![pepecortez's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31475-pepecortez "View pepecortez's Profile") Topic Author
- [ Offline](/forum/user/31475-pepecortez)

Less More

- Posts: 171
- Thank you received: 9
-
-

12 years 2 weeks ago -  12 years 2 weeks ago [\#177976](#177976) by [pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")  Replied by *[pepecortez](/forum/user/31475-pepecortez "View pepecortez's Profile")* on topic *[Even Order number format](/forum/19-hikamarket/869328-even-order-number-format#177976 "Hi,  We have multiple vendors, and wants to achieve to main vendor see all the orders. A problem I've just noticed that all the order numbers are even (dividible by 2). What can cause this?  Example: We have an order number format:BIF-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} The order numbers after each other are: BIF-00002/26/06/2014 BIF-00004/26/06/2014 BIF-00006/26/06/2014 ... but it should be like BIF-00001/26/06/2014 BIF-00002/26/06/2014 BIF-00003/26/06/2014 etc.  Also wanted to ask, is there a way to modify the automatism of creating invoice number format. The format is: PO-{id size=&quot;5&quot;}/{date format=&quot;d/m/Y&quot;} It's working as always adding +1 to each new order after it has been set to &quot;Approved&quot;. Do we have any option/hack to be in relation with ordernumber.  Example: Now: BIF-00003/26/06/2014 -&gt; PO-00001/26/06/2014 (if this is the firsty approved order) Should be: BIF-00003/26/06/2014 -&gt; PO-00003/26/06/2014 (the same ID as order number id)  Thanks, PePe")*

Successfully solved by this way, maybe this helps somebody:
in administrator/com_hikashop/helpers/helper.php around line 255.:
Code:

if(is_object($data) &amp;&amp; ($type=='order')){ $query_bif = 'SELECT MAX(order_bif_az) FROM '.hikashop_table('order').' WHERE order_id &lt;= '.$data-&gt;order_id; $db-&gt;setQuery($query_bif); $bif = $db-&gt;loadResult(); $id = $bif; }

I created a custom plugin with this content:
Code:

&lt;?php class plgHikashopBifupdate extends JPlugin { function onBeforeOrderCreate(&amp;$order,&amp;$do){ $db = JFactory::getDBO(); $rendid = @$order-&gt;order_id; $ordertype = @$order-&gt;order_type; if ($ordertype == 'sale') { $query_null = 'SELECT COUNT(*) FROM '.hikashop_table('order'); $db-&gt;setQuery($query_null); $count_null = $db-&gt;loadResult(); if ($count_null == 0){ $order-&gt;order_bif_az = 1; } else { $query_bifaz = 'SELECT (MAX(order_bif_az)+1) FROM '.hikashop_table('order'); $db-&gt;setQuery($query_bifaz); $bifaz = $db-&gt;loadResult(); $order-&gt;order_bif_az = $bifaz; } } } function onAfterOrderCreate(&amp;$order,&amp;$do){ $db = JFactory::getDBO(); $rendid = @$order-&gt;order_id; $ordertype = @$order-&gt;order_type; if ($ordertype == 'sale') { $query_bifmax = "SELECT MAX(order_bif_az) FROM ".hikashop_table('order'); $db-&gt;setQuery($query_bifmax); $bifmax = $db-&gt;loadResult(); $query_bifupdate = "UPDATE ".hikashop_table('order')." SET ".hikashop_table('order').".order_bif_az = ".$bifmax." WHERE order_id = ".$rendid ; $db-&gt;setQuery($query_bifupdate); $db-&gt;execute($query_bifupdate); } } }

Thanks for all your help Jerome!

Last edit: 12 years 2 weeks ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: code cleaning

The following user(s) said Thank You: [Jerome](/forum/user/80-jerome "View Jerome's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE5LWhpa2FtYXJrZXQvODY5MzI4LWV2ZW4tb3JkZXItbnVtYmVyLWZvcm1hdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

Moderators: [Obsidev](/forum/user/7040-obsidev "View Obsidev's Profile")

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.068 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
