I don't know what I'm doing wrong here. I've created a custom field for products, ID is "extra_fee".
The function I'm using is:
add_action( 'woocommerce_cart_calculate_fees', 'wpf_wc_add_cart_fee' );
if ( ! function_exists( 'wpf_wc_add_cart_fee' ) ) {
function wpf_wc_add_cart_fee( $cart ) {
$name = 'Extra fee: ';
$amount = rwmb_meta( 'extra_fee' );
$taxable = true;
$tax_class = 'reduced';
$cart->add_fee( $name, $amount, $taxable, $tax_class );
}
}
If a create a $value and assign it to rwmb_meta( 'extra_fee' ) before assigning it to the amount, the result is the same, it shows 0. The function works fine because if I change rwmb_meta( 'extra_fee' ) to a number, it shows it properly.
Thank you!