Woocommerce Free Shipping
-
Hi,
I have 3 different “Flat Rate Shipping” and 3 the same “Free shipping” in one Zone.
I’ve found in Woocommerce documentation a code, when the “Free shipping” or “Local pick-up” are avaible, than do not show “Flat Rate Shipping”. But when I put that code, it is showing just 1 possibility of “Free shipping” and I want to show all 3 “Free shipping” possibilities.The snippet I put is:
function hide_shipping_when_free_is_available( $rates, $package ) { $new_rates = array(); foreach ( $rates as $rate_id => $rate ) { // Only modify rates if free_shipping is present. if ( 'free_shipping' === $rate->method_id ) { $new_rates[ $rate_id ] = $rate; break; } } if ( ! empty( $new_rates ) ) { //Save local pickup if it's present. foreach ( $rates as $rate_id => $rate ) { if ('local_pickup' === $rate->method_id ) { $new_rates[ $rate_id ] = $rate; break; } } return $new_rates; } return $rates; } add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 10, 2 );
Thank you for help,
DanyloThe page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Woocommerce Free Shipping’ is closed to new replies.