How to update a custom field value using code ?

  • Posts: 19
  • Thank you received: 0
10 years 4 months ago #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 "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.

class plgHikashoppaymentMyPayment extends hikashopPaymentPlugin
{

              function onAfterOrderConfirm(&$order,&$methods,$method_id){
                   
                     $order->firstpayment  = 100;
                      .....
                    $this->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->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

Attachments:

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

  • Posts: 19
  • Thank you received: 0
10 years 4 months ago #162386

Hi,
after reviewing this post
www.hikashop.com/forum/payment-methods/8...m-fields.html#160883
i moved the code assigning new values to $order->firstpayment custom fields ,
to be triggered under onBeforeOrderCreate function.
it solved it.

Thanks

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

Time to create page: 0.062 seconds
Powered by Kunena Forum