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

#   programmatically set extra fields value

##

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

Less More

- Posts: 53
- Thank you received: 1
-
-

4 years 7 months ago [\#339805](#339805) by [matmosis](/forum/user/61552-matmosis "View matmosis's Profile")  *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339805 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")* was created by *[matmosis](/forum/user/61552-matmosis "View matmosis's Profile")*

-- HikaShop version -- : 4.5.0
-- Joomla version -- : 3.10.6
-- PHP version -- : 7.4.3
-- Browser(s) name and version -- : Chrome 90.0.4430.212

Hello,
is there the possibility to set the value for extra fields programmatically via php?

I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwNDA0OS1wcm9ncmFtbWF0aWNhbGx5LXNldC1leHRyYS1maWVsZHMtdmFsdWU/dG1wbD1tYXJrZG93bg==) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

4 years 7 months ago [\#339806](#339806) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339806 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")*

Hi,

It's possible.
What to do exactly depends on what your goal is.
If it is to set the value of a custom field of the table "order" when the order is being created, then it's quite easy. You can implement the onBeforeOrderCreate(&amp;$order, &amp;$do) event in a plugin of the group "hikashop" and just add the data like so:
$order-&gt;xxx = 'yyy';
where xxx is the column name of the field and yyy the value you want to set.

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

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

Less More

- Posts: 53
- Thank you received: 1
-
-

4 years 7 months ago [\#339815](#339815) by [matmosis](/forum/user/61552-matmosis "View matmosis's Profile")  Replied by *[matmosis](/forum/user/61552-matmosis "View matmosis's Profile")* on topic *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339815 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")*

thank you,
the goal is to set value to custom fields (order table) while they are shown in checkout page (show_block_fields)
is it possibile?

with your code i think the value is set only after user click "Confrm button" on checkout page, but my custom fields are shown in that page and i want to set a default value for they, and let user change it if he wants to.

thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwNDA0OS1wcm9ncmFtbWF0aWNhbGx5LXNldC1leHRyYS1maWVsZHMtdmFsdWU/dG1wbD1tYXJrZG93bg==) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

4 years 7 months ago [\#339818](#339818) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339818 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")*

Hi,

In that case, you can implement the event onAfterCartProductsLoad(&amp;$cart)
And you can use this code:
$cart-&gt;cart_fields-&gt;xxx = 'yyy';
Note that you'll want to check if that value is not empty before doing this so that you don't overwrite what the user selected/entered in the field since this event will be called each time the cart is loaded from the database (so on every page of the checkout, and every page where the cart module is displayed).

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

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

Less More

- Posts: 53
- Thank you received: 1
-
-

4 years 7 months ago [\#339829](#339829) by [matmosis](/forum/user/61552-matmosis "View matmosis's Profile")  Replied by *[matmosis](/forum/user/61552-matmosis "View matmosis's Profile")* on topic *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339829 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")*

ok thank you
i tried to create a plugin w/ group "hikashop" implementing JPlugin with:

function onAfterCartProductsLoad(&amp;$cart) {
$cart-&gt;cart_fields-&gt;xxx = 'yyy';
}

but it is never invoked! am I wrong?

thanks

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

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

Less More

- Posts: 53
- Thank you received: 1
-
-

4 years 7 months ago [\#339831](#339831) by [matmosis](/forum/user/61552-matmosis "View matmosis's Profile")  Replied by *[matmosis](/forum/user/61552-matmosis "View matmosis's Profile")* on topic *[programmatically set extra fields value](/forum/4-how-to/904049-programmatically-set-extra-fields-value#339831 "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 3.10.6 -- PHP version -- : 7.4.3 -- Browser(s) name and version -- : Chrome 90.0.4430.212  Hello, is there the possibility to set the value for extra fields programmatically via php?  I have managed extra fields for order, and i want to set their value on checkout page based on the user logged in. Those data are stored for user in a third party backend.  Thank you")*

ok i manage to resolve my problem!
thank you very much for support

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwNDA0OS1wcm9ncmFtbWF0aWNhbGx5LXNldC1leHRyYS1maWVsZHMtdmFsdWU/dG1wbD1tYXJrZG93bg==) 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.262 seconds

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

[](#top)
