1

I tried to add a checkbox for a pick-up shipping method, so when the method is chosen, the tickbox appears and need to be validated but when the other shipping method is chosen, I want it to disappear. Currently, it's not getting validation, neither it disappears when the other option is chosen (major problem).

Based on Add a checkbox below a specific shipping method in WooCommerce 3 answer, this is the code I'm using:

add_action( 'woocommerce_after_shipping_rate', 'checkout_shipping_additional_field', 20, 2 );
function checkout_shipping_additional_field( $method, $index )
{
    if( $method->get_id() == 'pickup-location-method' ){
        echo '<br>
        <input type="checkbox" name="shipping_custom_1" id="shipping_custom_1" value="1" class="shipping_method shipping_custom_1">
        <label for="shipping_custom_1">I confirm that I'll attend the delivery.</label>';
    }
}

Unfortunately, my limited knowledge doesn't allow me to progress with this code further. Could you help me with this, please?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • @LoicTheAztec The shipping id is correct, as the option does appear when I click on the shipping method. The issue is to make it disappear when I choose the other shipping method (instead of staying static). – Webadmin Carib Sep 29 '20 at 11:59
  • So this requires jquery to show hide this checkbox depending on the selected shipping method. – LoicTheAztec Sep 29 '20 at 19:07

0 Answers0