Unset Shipping Methods based on weight in woocommerce
₹600-1500 INR
Pagado a la entrega
I am using the following function to enable weight based shipping in woocommerce. For example- when the total weight in the cart is less than, 15.84, the flat_rate:5 shipping method should be activated and the other methods are getting unset.
However, I have to write all the methods getting unset individually. How to change the unset command to unset all shipping methods which are not flat_rate:5,6,8 and so on?
add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 );
function bbloomer_woocommerce_tiered_shipping( $rates, $package ) {
if ( WC()->cart->cart_contents_weight < 1 ) {
if ( isset( $rates['flat_rate:5'] ) ) unset( $rates['flat_rate:6'], $rates['flat_rate:8'] );
} elseif ( WC()->cart->cart_contents_weight < 5 ) {
if ( isset( $rates['flat_rate:6'] ) ) unset( $rates['flat_rate:5'], $rates['flat_rate:8'] );
} else {
if ( isset( $rates['flat_rate:8'] ) ) unset( $rates['flat_rate:5'], $rates['flat_rate:6'] );
}
return $rates;
}
Nº del proyecto: #18566362
Sobre el proyecto
Adjudicado a:
Hi, Hope you are all well. I have 6 years experience with wordpress,codeigniter,custom php , jQuery ect. I have completed lots of website and fixed lots of issues. I can work now for you. Please come on chat we ca Más