Custom fields for product in order variable

  • Posts: 72
  • Thank you received: 3
3 months 3 days 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: 75905
  • Thank you received: 11855
  • MODERATOR
3 months 1 day 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: 3 months 1 day 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.041 seconds
Powered by Kunena Forum