• jospo

    (@jospo)


    Hi Jeroen,

    It would be great to add a possibility to hide only some of the shipping methods.

    My use case:
    – I am using COD for payments and Free shipping or Local Pickup for shipping.

    If I hide other shipping methods, I don’t know if the customer wants to use Local Pickup or Free Local Shipping. If I don’t hide other shipping methods, customer can see also original Local Shipping (which is not free) and needs to manually select Free Shipping. Some customers forget and we need to manually correct the order to get them free shipping.

    Thanks!
    Petr

    https://www.ads-software.com/plugins/woocommerce-advanced-free-shipping/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi Petr,

    Thanks for the suggestion!

    If I understand correctly you don’t want to hide local shipping when free is available?
    I’ve got a code snippet that can help with that, if you put this in your themes functions.php it should work (haven’t tested it recently, please use ftp)

    global $woocommerce;
    if ( version_compare( $woocommerce->version, '2.1', '<' ) ) :
    	add_filter( 'woocommerce_available_shipping_methods', 'wafs_custom_hide_shipping' );
    else :
    	add_filter( 'woocommerce_package_rates', 'wafs_custom_hide_shipping' );
    endif;
    
    function wafs_custom_hide_shipping( $available_methods ) {
    
    	if ( isset( $available_methods['advanced_free_shipping'] ) && isset( $available_methods['local_pickup'] ) ) :
    		$new_methods = array(
    			'advanced_free_shipping' => $available_methods['advanced_free_shipping'],
    			'local_pickup' => $available_methods['local_pickup'],
    		);
    		return $new_methods;
    	endif;
    
    	if ( isset( $available_methods['free_shipping'] ) && isset( $available_methods['local_pickup'] ) ) :
    		$new_methods = array(
          'advanced_free_shipping' => $available_methods['advanced_free_shipping'],
    			'local_pickup' => $available_methods['local_pickup'],
    		);
    		return $new_methods;
    	endif;
    
    	return $available_methods;
    }

    That should work for now at least, as for the feature request itself; I like the idea. I will put it on the idea list and give it a good thought on if I will add it, and if so, how it would work.

    Let me know how that snippet works out (if you use it ??

    Cheers,
    Jeroen

    Hi Jeroen!

    I’ve recently bought your plugin and it’s great, thanks ??

    but i have same problem as Petr – i tried to put code you posted to functions.php but unfortunately nothing happens. can you please look at that? ??

    maybe i just didn’t understand it really – but when i create two “free shipping methods” with same condition – i can see only one of them at checkout page? because that’s what it does to me. i hoped for this – i say “hide all other shipping methods when free is available” – and – when free shipping is available show all shipping methods (if condition is ok
    ) i created inside of your plugin – and customer will choose one.

    Thank you!

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi Kraava,

    Thanks for supporting ??

    If I understand correctly, you want to display two (or more) free shipping methods?
    (since the code above should display free shipping and local pickup)

    Could you maybe contact me through https://www.jeroensormani.com/contact to get in touch for this?

    Thanks!

    Jeroen Sormani

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Suggestion for hiding other shipping methods’ is closed to new replies.