• Resolved luigistefano

    (@luigistefano)


    Hello!

    The shippping method depends on the adress of the costumer. So after filling in the zip code they can select local pick up or shipping to home. But even when they select local pick up in the shopping cart it says: Lockal pick up: send to (costumer adres). So its a bit confusing for the costumer. How can i hide this?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @luigistefano ,

    This is actually a great idea to remove the shipping option when you have selected the Local Pickup option.

    I found a code that almost did what you needed. I have modified it to suit your need and work it for both the cart and checkout page. Use this code in your theme’s functions.php file or via code snippet plugin

    add_action( 'woocommerce_after_checkout_form', 'custom_disable_shipping_local_pickup' );
    add_action( 'woocommerce_cart_totals_after_shipping', 'custom_disable_shipping_local_pickup' );
      
    function custom_disable_shipping_local_pickup( $available_gateways ) {
        
       // Part 1: Hide shipping based on the static choice @ Cart
       // Note: "#customer_details .col-2" strictly depends on your theme
     
       $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('.woocommerce-shipping-destination,.woocommerce-shipping-calculator,#customer_details .col-2').fadeOut();
          </script>
       <?php  
       } 
     
       // Part 2: Hide shipping based on the dynamic choice @ Checkout
       // Note: "#customer_details .col-2" strictly depends on your theme
     
       ?>
          <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('.woocommerce-shipping-destination,.woocommerce-shipping-calculator,#customer_details .col-2').fadeOut();
                   } else {
                   jQuery('.woocommerce-shipping-destination,.woocommerce-shipping-calculator,#customer_details .col-2').fadeIn();
                }
             });
          </script>
       <?php 
    }

    I hope this information helps.

    Thank you ??

    Thread Starter luigistefano

    (@luigistefano)

    Wow awesome thx for helping me. Ill try it out and let u know if it worked

    Thread Starter luigistefano

    (@luigistefano)

    @rur165 I am a bit late but i finally tried to implement it. It seems to work very good. The ‘send to’ is gone when the costumers selects local pick up. Awesome! thx for the help. ??

    Hello @luigistefano ,

    Thanks for your update.

    I am happy to know that the solution worked as expected.

    Cheers ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘hide text in shopping cart’ is closed to new replies.