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

#   How to update a custom field value using code ?

##

- **[buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")**
- [![buzibuzi's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/butterfly.gif)](/forum/user/30472-buzibuzi "View buzibuzi's Profile") Topic Author
- [ Offline](/forum/user/30472-buzibuzi)

Less More

- Posts: 19
- Thank you received: 0
-
- [](http://www.hubeza.com)
-

12 years 3 months ago [\#162361](#162361) by [buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")  *[How to update a custom field value using code ?](/forum/31-development/869382-how-to-update-a-custom-field-value-using-code#162361 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.1 -- PHP version -- : 5.4.29  Hi, i created an order table custom field called &quot;firstpayment&quot;. (text type) attached screen capture. i want to update its value (according to some calculations im doing in the payment plugin) and save to the order table when order is saved.  here is the relevant part of the code from my payment plugin im using to achieve this.  for some reason the value is not saved to the order and its not showing up in the back-end order display.  i checked the $order-&gt;firstpayment before the modifyOrder function and it contains the value.  can anyone explain why ?  perhaps im not using the modifyOrder function correctly ? (i couldnt find documentation on this function usage) also, i tried adding a default value.same result.  Thanks")* was created by *[buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")*

-- HikaShop version -- : 2.3.0
-- Joomla version -- : Joomla! 3.3.1
-- PHP version -- : 5.4.29

Hi,
i created an order table custom field called "firstpayment". (text type) attached screen capture.
i want to update its value (according to some calculations im doing in the payment plugin) and save to the order table when order is saved.

here is the relevant part of the code from my payment plugin im using to achieve this.
Code:

class plgHikashoppaymentMyPayment extends hikashopPaymentPlugin { function onAfterOrderConfirm(&amp;$order,&amp;$methods,$method_id){ $order-&gt;firstpayment = 100; ..... $this-&gt;modifyOrder($order,$order_status,$history,$email); } }

for some reason the value is not saved to the order and its not showing up in the back-end order display.

i checked the $order-&gt;firstpayment before the modifyOrder function and it contains the value.

can anyone explain why ?

perhaps im not using the modifyOrder function correctly ?
(i couldnt find documentation on this function usage)
also, i tried adding a default value.same result.

Thanks

- [ ![h2b66fe2.png](/forum/attachment/18202) ](/forum/attachment/18202 "h2b66fe2.png") [ ](/forum/attachment/18202?download=1 "h2b66fe2.png")

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

- **[buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")**
- [![buzibuzi's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/butterfly.gif)](/forum/user/30472-buzibuzi "View buzibuzi's Profile") Topic Author
- [ Offline](/forum/user/30472-buzibuzi)

Less More

- Posts: 19
- Thank you received: 0
-
- [](http://www.hubeza.com)
-

12 years 3 months ago [\#162386](#162386) by [buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")  Replied by *[buzibuzi](/forum/user/30472-buzibuzi "View buzibuzi's Profile")* on topic *[How to update a custom field value using code ?](/forum/31-development/869382-how-to-update-a-custom-field-value-using-code#162386 "-- HikaShop version -- : 2.3.0 -- Joomla version -- : Joomla! 3.3.1 -- PHP version -- : 5.4.29  Hi, i created an order table custom field called &quot;firstpayment&quot;. (text type) attached screen capture. i want to update its value (according to some calculations im doing in the payment plugin) and save to the order table when order is saved.  here is the relevant part of the code from my payment plugin im using to achieve this.  for some reason the value is not saved to the order and its not showing up in the back-end order display.  i checked the $order-&gt;firstpayment before the modifyOrder function and it contains the value.  can anyone explain why ?  perhaps im not using the modifyOrder function correctly ? (i couldnt find documentation on this function usage) also, i tried adding a default value.same result.  Thanks")*

Hi,
after reviewing this post
[ www.hikashop.com/forum/payment-methods/8...m-fields.html#160883](https://www.hikashop.com/forum/payment-methods/869110-authorize-net-and-custom-fields.html#160883)
i moved the code assigning new values to $order-&gt;firstpayment custom fields ,
to be triggered under onBeforeOrderCreate function.
it solved it.

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2OTM4Mi1ob3ctdG8tdXBkYXRlLWEtY3VzdG9tLWZpZWxkLXZhbHVlLXVzaW5nLWNvZGU/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.094 seconds

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

[](#top)
