Skip to content

Instantly share code, notes, and snippets.

@maxkostinevich
Last active July 16, 2020 21:35
Show Gist options
  • Save maxkostinevich/a5c94f635a7848fcba03767feb3711ab to your computer and use it in GitHub Desktop.
Save maxkostinevich/a5c94f635a7848fcba03767feb3711ab to your computer and use it in GitHub Desktop.
WooCommerce - How to change available package rates depending on cart total
<?php
// Change available package rates depending on cart total
function shipping_method_on_cart_total( $rates, $package ) {
$cart_total = WC()->cart->total;
$condition_price = 1000.00;
if( $cart_total > $condition_price ) {
unset( $rates['free_shipping'] ); // Remove free shipping
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'shipping_method_on_cart_total', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment