Created
April 22, 2022 08:34
-
-
Save bradleysa/09aba0102d729a2544d05c19eafeb898 to your computer and use it in GitHub Desktop.
WC: Force Shipping Calculator
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
/** | |
* 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