Does exactly the opposite
-
Hi guys, I have had this plugin installed quite successfully on one site, wanted to install it on another site today, i have flat rate shipping classes for all products, but over a certain amount, free shipping. If i install the plugin now, it ONLY shows free shipping, as opposed to flat rate, and free shipping only when a threshold is reached. I had to update woocommerce today on the first site, was prompted to, and since then, your plugin doesn’t work there either, it does exactly the same thing – only shows FREE SHIPPING. Using the code that Woocommerce provides to insert into the php file doesn’t work either. Please can you check to see what is going on and let us know? It is a small train smash obviously. Two sites affected. My shipping zones are properly set up, no errors, no conflicts in plugins, nothing like that, so not sure what is going on. For you to check what woocommerce suggests as code, here it is sorry for the formatting, but i am sure you will be able to figure it out.
/**
- 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;
break;
}
}
return ! empty( $free ) ? $free : $rates;
}
add_filter( ‘woocommerce_package_rates’, ‘my_hide_shipping_when_free_is_available’, 100 );
- You must be logged in to reply to this topic.