Better you check if the author of Booster for Woocommerce.
As I didn’t have any reply from Booster plugin support and I haven’t solve my problem yet, I’d like to ask something about a snippet that I got. It should supposedly hide woocommerce free shipping option when total (not subtotal) is under the woocommerce minimum amount (excluding the discount applied by the payment gateway then). The thing is that the snippet is not doing what it’s suppose to do, so I’d like to know what could be wrong with it. Thank you
/**
* @snippet Hide free shipping if under minimum amount
*/
add_filter( ‘woocommerce_package_rates’, hide_free_shipping, 10, 2 );
function hide_free_shipping($rates, $package) {
// Get Min Amount from Woo Settings
$free_shipping_settings = get_option( ‘woocommerce_free_shipping_settings’ );
$min_amount = $free_shipping_settings[‘min_amount’];
// Get Cart Total
$current = WC()->cart->cart_contents_total;
// If Total < Min Amount hide free shipping
if ( $current < $min_amount ) {
unset( $rates[‘free_shipping’] );
}
return $rates;
}
Hey taysabr,
That snippet will only work before WooCommerce 2.6. It needs to be adapted to work with the new shipping zones, similar to this snippet: https://mikejolley.com/2016/06/17/woocommerce-hide-shipping-rates-when-free-shipping-is-available/
If you aren’t sure how to do this, then you can find some help from a developer at one of these sources:
– http://jobs.wordpress.net/
– https://codeable.io/
Thanks for your reply Caleb.
If somebody already has the snippet adaption to new woocommerce 2.6 and could share, I would appreciate!
The ‘free_shipping’ will just be named something, e.g. free_shipping:instance_id. You could var_Dump() the array to see what code is there if you need to find out the ID.
Hi Mike!
I’m glad for your reply, but I’m not a coder, so unfortunately I can’t understand what you mean.
I can’t find any plugin that could calculate the discount before the shipping costs calculation, so I think it’s an issue related to woocommerce, isn’t it?
Thanks again!
^ caleb suggested some resources for hiring devs if you want something custom.
What is the instance ID for your flat rate shipping https://dl.dropboxusercontent.com/s/1a3vkub4lypumt9/2016-06-22%20at%2015.25.png?dl=0
Ok Mike, thank you very much!!
Yes Mike, I have two shipping zones that are using free shipping, the id’s are 1 and 4, but I’m not sure what to do with them.
In your snippet, change ‘free_shipping’ to ‘free_shipping:1’
That one inside the brackets, right? It didn’t work 🙁
Wait a minute, that snippet is pointless. The free shipping method itself has an option to set min amount.
Yes, free shipping has an option to set minimun amount. It happens that woocommerce shipping calculation is based on “subtotal” (I think). And the snippet is based on “cart_contents_total”. I’m just looking for something that can calculate shipping cost considering a discount applied on payment gateway (what woocommerce is not doing itself).
Ex: minimun amount to get free shipping is set to $250
Subtotal is $275
Payment gateway discount: – 25.7
Total: $247.5
It shouldn’t show free shipping in this case, but it does.