I have created a custom field in the user profile, now I need to call the value of that field into the WooCommerce cart as a discount.
This is the function to add a custom fee in the cart:
add_action('woocommerce_cart_calculate_fees' , 'add_custom_fees');
$descuentototal = get_the_author_meta( 'descuento', $user_id );
function add_custom_fees( WC_Cart $cart ){
if( $descuentototal < 1 ){
return;
}
// Calculate the amount to reduce
$cart->add_fee( 'Discount: ', -$descuentototal);
}
But can't manage to get the value of 'descuento'.
How could I do it?
Thanks.