WC_Post_Data::update_order_item_metadata()public staticWC 1.0

Ensure floats are correctly converted to strings based on PHP locale.

{} It's a method of the class: WC_Post_Data{}

No Hooks.




$result = WC_Post_Data::update_order_item_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value );
$check(null) (required)
Whether to allow updating metadata for the given type.
$object_id(int) (required)
Object ID.
$meta_key(string) (required)
Meta key.
$meta_value(mixed) (required)
Meta value. Must be serializable if non-scalar.
$prev_value(mixed) (required)
If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.

Code of WC_Post_Data::update_order_item_metadata() WC 6.7.0

public static function update_order_item_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
	if ( ! empty( $meta_value ) && is_float( $meta_value ) ) {

		// Convert float to string.
		$meta_value = wc_float_to_string( $meta_value );

		// Update meta value with new string.
		update_metadata( 'order_item', $object_id, $meta_key, $meta_value, $prev_value );

		return true;
	return $check;