I'm building a shop based on WooCommerce. I need to add an extra checkbox on the checkout page called Shipping Insurance. Once the field is checked, i need to add an extra $3 to the Order Total. I was able to add a fixed fee this way:
function woo_add_cart_fee() {
global $woocommerce;
$woocommerce->cart->add_fee( __('Shipping Insurance', 'woocommerce'), 3 );
}
add_action( 'woocommerce_before_calculate_totals', 'woo_add_cart_fee' );
The problem is that this will add a fixed $3 to the order total, so its not optional. Any idea how to proceed with this issue?