Free Shipping and Fixed Price's two in the checkout page
Posted by:
bilalhizardere
Mar 22, 2019 at 08:50 (6 year ago)
Hello everyone. I have a free shipping system for purchases over 100 $. 2 options appear on the checkout page for a payment that is normally $ 150. Fixed price and free shipping. But i used the php codes below and system change otomatically.
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 );
Thanks to these php codes, the only free shipping option on the payment page for purchases over $ 100 seems to be selected and automatically. But now, with a purchase of $ 150, there are still two options.
Can you offer a solution for this? Is there any other method you know?
THX
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 );
Thanks to these php codes, the only free shipping option on the payment page for purchases over $ 100 seems to be selected and automatically. But now, with a purchase of $ 150, there are still two options.
Can you offer a solution for this? Is there any other method you know?
THX