Make shipping option always available even when free shipping is provided
-
Hi everyone, can someone please give me a hand with the following? I would like to alter the following code so that flat_rate:17 is also included in the list when free shipping is available.
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 'free_shipping' === $rate->method_id ) {
$free[ $rate_id ] = $rate;
$free_shipping = true;
}
if ( $free_shipping == true && 'local_pickup:21' === $rate->id ) {
$free[ $rate_id ] = $rate;
}
}
return ! empty( $free ) ? $free : $rates;
}
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );
- The topic ‘Make shipping option always available even when free shipping is provided’ is closed to new replies.