WC_Post_Data::update_post_metadata PHP Method

update_post_metadata() public static method

Ensure floats are correctly converted to strings based on PHP locale.
public static update_post_metadata ( null $check, integer $object_id, string $meta_key, mixed $meta_value, mixed $prev_value ) : null | boolean
$check null
$object_id integer
$meta_key string
$meta_value mixed
$prev_value mixed
return null | boolean
    public static function update_post_metadata($check, $object_id, $meta_key, $meta_value, $prev_value)
    {
        if (!empty($meta_value) && is_float($meta_value) && in_array(get_post_type($object_id), array_merge(wc_get_order_types(), array('shop_coupon', 'product', 'product_variation')))) {
            // Convert float to string
            $meta_value = wc_float_to_string($meta_value);
            // Update meta value with new string
            update_metadata('post', $object_id, $meta_key, $meta_value, $prev_value);
            // Return
            return true;
        }
        return $check;
    }