Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 08:34
Show Gist options
  • Save bradleysa/09aba0102d729a2544d05c19eafeb898 to your computer and use it in GitHub Desktop.
Save bradleysa/09aba0102d729a2544d05c19eafeb898 to your computer and use it in GitHub Desktop.
WC: Force Shipping Calculator
/**
* Force the shipping calculator to display on cart, even when Local Pickup Plus is selected.
*/
function sv_force_display_of_shipping_calculator() {
?>
<script type="text/javascript">
if ( undefined !== window.jQuery ) {
jQuery(function ($) {
function show_shipping_calculator() {
$( '.woocommerce-shipping-totals' ).each(function(index, el) {
if ( $( el ).find( 'input.shipping_method:checked' ).val() === 'local_pickup_plus' || $( el ).find( 'input:hidden.shipping_method' ).val() === 'local_pickup_plus' ) {
$( el ).find( '.woocommerce-shipping-calculator' ).show();
}
});
}
$( document ).on( 'updated_cart_totals', function() { show_shipping_calculator() } );
show_shipping_calculator();
});
}
</script>
<?php
}
add_action( 'wp_footer', 'sv_force_display_of_shipping_calculator' );
/** Courtesy of SkyVerge Support on 4/15/22 **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment