Don't convert zero values to empty string
PHP's empty() function returns true for 0, 0.00, "0.00" and other 0 variants. That means woocommerce_process_shop_order_meta() will convert item meta with a 0.00 or similar value to an empty string, which can break things that expect a float or number. This commit fixes that.
This commit is contained in:
parent
547ea85451
commit
cf240d96a3
|
@ -882,11 +882,12 @@ function woocommerce_process_shop_order_meta( $post_id, $post ) {
|
|||
$meta_values = isset( $_POST['meta_value'] ) ? $_POST['meta_value'] : array();
|
||||
|
||||
foreach ( $meta_keys as $id => $meta_key ) {
|
||||
$meta_value = ( empty( $meta_values[ $id ] ) && ! is_numeric( $meta_values[ $id ] ) ) ? '' : $meta_values[ $id ];
|
||||
$wpdb->update(
|
||||
$wpdb->prefix . "woocommerce_order_itemmeta",
|
||||
array(
|
||||
'meta_key' => $meta_key,
|
||||
'meta_value' => empty( $meta_values[ $id ] ) ? '' : $meta_values[ $id ]
|
||||
'meta_value' => $meta_value
|
||||
),
|
||||
array( 'meta_id' => $id ),
|
||||
array( '%s', '%s' ),
|
||||
|
|
Loading…
Reference in New Issue