Created
November 26, 2020 08:35
-
-
Save praveencs87/0b837ddb3b2932317c3b4f8e27cd700c to your computer and use it in GitHub Desktop.
Hide Shipping Section in checkout page when local pickup is selected - woocommerce | webinwordpress.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_after_checkout_form', 'webinwp_hide_shipping' ); | |
// Disable Shipping form section in Checkout page | |
function webinwp_hide_shipping( $available_gateways ) { | |
// NB: "#customer_details .col-2" based on your theme html attributes | |
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); | |
$chosen_shipping = $chosen_methods[0]; | |
if ( 0 === strpos( $chosen_shipping, 'local_pickup' ) ) { | |
?> | |
<script type="text/javascript"> | |
jQuery('#customer_details .col-2').fadeOut(); | |
</script> | |
<?php | |
} | |
// NB: "#customer_details .col-2" based on your theme html attributes | |
?> | |
<script type="text/javascript"> | |
jQuery('form.checkout').on('change','input[name^="shipping_method"]',function() { | |
var val = jQuery( this ).val(); | |
if (val.match("^local_pickup")) { | |
jQuery('#customer_details .col-2').fadeOut(); | |
} else { | |
jQuery('#customer_details .col-2').fadeIn(); | |
} | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment