admin管理员组

文章数量:1129783

Until now, I used this code to display a order custom field value inside a template:

<?php echo esc_html( get_post_meta( $order->get_id(), 'my_custom_field', true ) ); ?>

When enabling HPOS as the only option, this code no longer works.

I tried:

<?php echo esc_html( $order->get_billing_my_custom_field() ); ?> ,

but I keep getting this error: Fatal error: Uncaught Error: Call to undefined method

Automattic\WooCommerce\Admin\Overrides\Order::get...

Until now, I used this code to display a order custom field value inside a template:

<?php echo esc_html( get_post_meta( $order->get_id(), 'my_custom_field', true ) ); ?>

When enabling HPOS as the only option, this code no longer works.

I tried:

<?php echo esc_html( $order->get_billing_my_custom_field() ); ?> ,

but I keep getting this error: Fatal error: Uncaught Error: Call to undefined method

Automattic\WooCommerce\Admin\Overrides\Order::get...

Share Improve this question asked Sep 10, 2023 at 19:18 DanielDaniel 1
Add a comment  | 

1 Answer 1

Reset to default 0

Use $order->get_meta('my_custom_field') instead.

本文标签: phpDisplay WooCommerce Order Custom Field In Template (HPOS)