• Resolved MikePepper80

    (@kellylouise007)


    Hi, can anyone help with my Free Shipping issue…

    We have 4 shipping options, Free, 2nd Class, Next Day and Collection… Free Shipping kicks in once the order is over £30, which is does. However, if the value of the order is changed in at the ‘cart’ or two products are added, say £16 each (£32) then the ‘2nd Class’ is always the default, and customers are paying for postage, resulting in refunds etc…

    I’ve checked the order within Woo settings, FOC is at the top (see image);

    https://ibb.co/7NhnNTT

    Not sure where else to look?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • You’ll need a snippet:

    // hide 2nd class if free shipping is available
    add_filter( 'woocommerce_package_rates', 'custom_package_rates', 100 );
    function custom_package_rates( $rates ) {
      $has_free = false;
      foreach ( $rates as $rate_id => $rate ) {
        if ( 'free_shipping' === $rate->method_id ) {
          $has_free = true;
        }
        if ( $has_free & '2nd Class' == $rate->label ) {
          unset( $rates[$rate_id] );
        }
      }  
      return  $rates;
    }

    The code assumes free is the first one, and the label for 2nd Class must match exactly what was used in shipping setup.

    Thread Starter MikePepper80

    (@kellylouise007)

    Great! Thanks… Looks like this has done the job!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    That’s wonderful ??

    Thank you @lorro for your great response.

    I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Free Shipping’ is closed to new replies.