I need to set up a custom product price after calculation. I am doing the code below and it is working well but it just get the first digit from the whole number
add_filter('woocommerce_add_cart_item_data','wdm_add_item_data',1,10);
function wdm_add_item_data($cart_item_data, $product_id) {
global $woocommerce;
$new_value = array();
$new_value['_custom_options'] = '678';
if(empty($cart_item_data)) {
return $new_value;
} else {
return array_merge($cart_item_data, $new_value);
}
}
For that being said, the custom price is just set 6, which should rather be 678. It is so weird, can anybody know why and how to fix it? Thanks a lot.