Custom fields for product in order variable

  • Posts: 77
  • Thank you received: 4
  • Hikashop Business
2 years 3 weeks ago #340633

Hi,

I created a custom field for the product table which I would need in the order variable:
$order_full = $orderClass->loadFullOrder($order->order_id, true, false);

This custom field is also displayed on the frontend.

I need this custom field for the product in the function: onAfterOrderUpdate(&$order, &$send_email)

But the custom field is not available in the order variable.

Why not and how can I add it , so that I can use it in the function onAfterOrderUpdate ???

Thanks and br
Rene

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
2 years 3 weeks ago #340651

Hi,

Well, the whole product data in not loaded with the order. That's because this is usually not needed.
You can do this in your code:

$productClass = hikashop_get('class.product);
foreach( $order_full->products as $product) {
 $productData = $productClass->get($product->product_id);
 echo $productData->xxx;
}
where xxx is the column name of your custom field of the table "product".

Last edit: 2 years 3 weeks ago by nicolas.
The following user(s) said Thank You: tgdkere2

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

Time to create page: 0.046 seconds
Powered by Kunena Forum