Automattic\WooCommerce\Utilities

OrderUtil::get_post_or_object_meta()public staticWC 1.0

Gets value of a meta key from WC_Data object if passed, otherwise from the post object. This helper function support backward compatibility for meta box functions, when moving from posts based store to custom tables.

Method of the class: OrderUtil{}

No Hooks.

Return

Array|Mixed|String. Value of the meta key.

Usage

$result = OrderUtil::get_post_or_object_meta( ?WP_Post $post, ?\WC_Data $data, $key, $single );
?WP_Post $post (required)
-
?\WC_Data $data (required)
-
$key(string) (required)
Key to fetch metadata for.
$single(true|false) (required)
Whether metadata is single.

OrderUtil::get_post_or_object_meta() code WC 7.1.0

public static function get_post_or_object_meta( ?WP_Post $post, ?\WC_Data $data, string $key, bool $single ) {
	return wc_get_container()->get( COTMigrationUtil::class )->get_post_or_object_meta( $post, $data, $key, $single );
}