I'm trying to add a few radio options to my checkout page.
When a user selects a radio option, I want to automatically refresh the page and add a fee to the checkout page based on what was selected.
For example:
If you select "Option 1" it will add a fee of $10.
If you select "Option 2" it will add a fee of $20 etc.
Here's my code in the functions.php file:
add_action( 'woocommerce_cart_calculate_fees','calculate_extra_deliveryoptions' );
function calculate_extra_deliveryoptions() {
echo "<form action=\"\"><br/>";
echo "<input type=\"radio\" name=\"deliveryextras\" id=\"option1\" value=\"10\">Option 1 <br/>";
echo "<input type=\"radio\" name=\"deliveryextras\" id=\"option2\" value=\"20\">Option 2 <br/>";
echo "</form>";
WC()->cart->add_fee(__('A small fee', 'option'), 5);
}
I can't seem to figure out how to get the selected value, refresh the page and add the fee.