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

#   Custom fields in order variable

##

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216446](#216446) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216446 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")* was created by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")*

-- HikaShop version -- : 2.6.0
-- Joomla version -- : 3.4.1

Hi,

I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo_discount and flo_originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping_groups-&gt;products (see variable dump attached). Is this correct? If so, why?

Thanks for clarifying!

Michel

- [ ![hika1&#95;2015-10-06.png](/forum/attachment/26890) ](/forum/attachment/26890 "...2015-10-06.png") [ ](/forum/attachment/26890?download=1 "...2015-10-06.png")

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

11 years 1 month ago [\#216472](#216472) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216472 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

That's because the "frontend" setting is disabled for these custom fields so the system is not saving them when the order is being created.
If you want to manually set them in the onBeforeOrderCreate function of a plugin, you want to set them in the cart-&gt;products array

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

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216609](#216609) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  Replied by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216609 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi Nicolas,

Thanks for the reply.
I have changed the "frontend" setting to visible and set the access level to none (because I don't want these fields to be displayed on the frontend, they only serve to keep the original price and discount info). I was now able to update the order variable in the onBeforeOrderCreate function (see order_updated_dump.txt). However I can't acces this information in the on AfterOrderUpdate, where the order information is transmitted to our invoicing platform. I get the order information as follows:

$orderClass-&gt;loadFullOrder($order-&gt;order_id, false, false)

However, here the custom fields are empty (see fullorder_dump.txt) and they are also empty in the DB. So how can I access the values of my custom fields so I can use them for transferring to our invoicing platform?

Thanks
Michel

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

11 years 1 month ago [\#216615](#216615) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216615 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

I don't see why that wouldn't work.
So there must be an issue with your code.
For example, if you didn't add the &amp; before the $order parameter of the onBeforeOrderCreate function definition.
Do you get the data in the fields in the hikashop_order_product table after the order is stored in the database ?

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

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216704](#216704) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  Replied by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216704 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi Nicolas,

yes, the order variable is passed by reference. No I can't see any data stored in the DB
I have attached a code file of the onBeforeOrderCreate function (only 46 lines) and would be very grateful if you could have a look.

Many thanks,
Michel

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

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216796](#216796) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  Replied by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216796 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi Nicolas,

I found out, that the custom fields need to be visible on the website to be taken into account. It doesn't work if I set the "frontend" setting to visible and set the access level to none. The access level must be "all", but this causes the fields to show on the frontend and I don't want that. So back to square one... How can I save the discount and original price information for later use in the AfterOrderUpdate function?

Thanks,
Michel

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3OTY4NS1jdXN0b20tZmllbGRzLWluLW9yZGVyLXZhcmlhYmxlP3RtcGw9bWFya2Rvd24=) 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: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

11 years 1 month ago [\#216797](#216797) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216797 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

That's right, the "order_product" class does not authorize the modification of custom fields like that.
There is a filtering system in the "save" function.

So I suggest you to use the "onAfterOrderCreate" trigger and update manually your "order_product" in the database.
You will find the "order_product_id" data in the $order-&gt;cart-&gt;products objects.

Regards,

---

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

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

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216825](#216825) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  Replied by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216825 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

Yes, but is the information I need (discount und original price that was applied per product) available in he "onAfterOrderCreate" trigger? That was the whole point, why it had to be done in "onBeforeOrderCreate"...

Thanks,
Michel

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3OTY4NS1jdXN0b20tZmllbGRzLWluLW9yZGVyLXZhcmlhYmxlP3RtcGw9bWFya2Rvd24=) 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: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

11 years 1 month ago [\#216828](#216828) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216828 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

I didn't tell you to not use the "onBeforeOrderCreate" trigger ; I told you to also use the "onAfterOrderCreate" to store the data in the database.
The order object will be the same, you can still put your data during the "onBeforeOrderCreate" but it won't be saved by the "order_product" class (like I explained).
So you have to use the "onAfterOrderCreate" to perform that saving operation.

Is that more clear ?

Regards,

---

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

The following user(s) said Thank You: [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")

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

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

Less More

- Posts: 71
- Thank you received: 0
-
-

11 years 1 month ago [\#216884](#216884) by [bmichu](/forum/user/32093-bmichu "View bmichu's Profile")  Replied by *[bmichu](/forum/user/32093-bmichu "View bmichu's Profile")* on topic *[Custom fields in order variable](/forum/31-development/879685-custom-fields-in-order-variable#216884 "-- HikaShop version -- : 2.6.0 -- Joomla version -- : 3.4.1  Hi,  I'm modifying the plugin we wrote to send order information to our invoicing platform so that discount information is also sent. To this effect I have created 2 custom fields (flo&#95;discount and flo&#95;originalprice) in the item table (see screenshot attached). I want to save the discount and original price information in these two fileds by setting them on the corresponding products in the order variable passed by the onBeforeOrderCreate function. When I look for these fields, they ar not found in the cart-&gt;products array, but only under cart-&gt;shipping&#95;groups-&gt;products (see variable dump attached). Is this correct? If so, why?  Thanks for clarifying!  Michel")*

Hi,

Thanks, now it works!

Michel

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3OTY4NS1jdXN0b20tZmllbGRzLWluLW9yZGVyLXZhcmlhYmxlP3RtcGw9bWFya2Rvd24=) 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?

[](/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)
