Created
May 3, 2020 20:23
-
-
Save ajboni/8fcfb17ad75f70f7522978bd27f8ed04 to your computer and use it in GitHub Desktop.
Wordpress / Woocommerce - Hide Shipping Fields and address selector for Local Pickup in Cart Page
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
/** | |
* @snippet Hide Shipping Fields and address selector for Local Pickup in Cart Page | |
* @author Alexis Boni | |
* @testedwith WooCommerce 5.4 - OceanWP theme. | |
*/ | |
do_action('woocommerce_after_shipping_rate', $method, $index); | |
// define the woocommerce_after_shipping_rate callback | |
function action_woocommerce_after_shipping_rate($method, $index) | |
{ | |
// make action magic happen here... | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
// Class names might change depending on your theme. | |
var val = jQuery("input[name='shipping_method[0]']:checked").val() | |
if (val.match("^local_pickup")) { | |
jQuery('.woocommerce-shipping-destination, .woocommerce-shipping-calculator').fadeOut(); | |
} else { | |
jQuery('.woocommerce-shipping-destination, .woocommerce-shipping-calculator').fadeIn(); | |
} | |
}); | |
</script> | |
<?php | |
}; | |
// add the action | |
add_action('woocommerce_after_shipping_rate', 'action_woocommerce_after_shipping_rate', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment