Hello, this is Dave!
I’m using woocommerce and i wat to make something with the free shipping methods, because woocmmerce shows the “free shipping” and the “standar shipping” when a minimum quantity is reached in a purchase.
What I want is for the “standard shipping” to disappear when that happens and woocommerce docs that is possible whith a code that you must to add in the functions.php. I haven’t a child theme and don’t want to use if i can use an “element hook”
This is the documentation:
https://docs.woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/#
And this is the woocommerce code. Can i use this code with a element hook?
/**
* 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 );