function add_extra_discount( $cart ) { ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

        if($('table.shop_table.shop_table_responsive').find('.cart-discount').length !== 0){
            $('#shipping_method > li').not('#shipping_method > li:first-child').hide();

<?php }
add_action( 'woocommerce_cart_calculate_fees', 'add_extra_discount' );

This is what my code looks like. But We have to reload to hide the shipping options. Can we do it without reloading the page??

Thanks for the help in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.