Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    For example changing:

    if ( 'free_shipping' === $rate->method_id ) {

    to

    if ( 'free_shipping' === $rate->method_id ||  'local_pickup' === $rate->method_id ) {

    and removing the break; would work.

    Thread Starter silenx

    (@silenx)

    Is working but not as expeted:
    example: i have the free shipping at 50$, flat rate and local pickup.
    With the code snippet under 50$ i only have local pickup, and flat rate is hide.
    If order is over 50$ is working as expeted, showing free ship and local pickup.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    O right. Well in that case you’d have to ‘unset’ flat rate instead. But you need to know the instance ID/method ID so you can unset the right one.

    It will be something like:

    function my_hide_shipping_when_free_is_available( $rates ) {
    	foreach ( $rates as $rate_id => $rate ) {
    		if ( 'free_shipping' === $rate->method_id ) {
    			unset( $rates['flat_rate:1'] );
    			break;
    		}
    	}
    	return $rates;
    }

    You just need to find what flat_rate:1 should be.

    Thread Starter silenx

    (@silenx)

    Thank you, is working. ( in my case is 5 the istance id ).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WC 2.6: Keep local pickup with free shipping snippet’ is closed to new replies.