I have a checkbox for a custom user meta field in the billing address section of the checkout process. I'm trying to dynamically add a fee to the checkout total when the checkbox is checked, or in this case, == '1'.
My Attempt:
add_action( 'woocommerce_cart_calculate_fees','ups_yes_no_fee', 43, 1 );
function ups_yes_no_fee( $wc_cart ) {
global $woocommerce;
if($_POST['billing_ups_yn'] == '1'){
//echo 'checked';
$woocommerce->cart->add_fee( __('Own Account Shipping', 'woocommerce'), 20 );
}
}
It'll apply the fee if I remove the "if" statement so I'm guessing this is the wrong way to apply a fee based off of a checkout field. How can I accomplish this?