Hello, guys! I am finding the solution on what I am trying to view on my cart page. Can you visit the site for what I am wanted to do? I running the codes via staging site before moving to production if it is good and working.
HERE https://staging1.oree.co/product/board/
Try to place order/s and view cart. I wanted that, placed order below $175 only Standard shipping and Express delivery will be display (like what is displaying now is good). And if the placed order is $175 and above, It only display’s Free shipping.
The code that I’ve used is working well but I wanted that Express delivery will also be display and since It already defaults on free shipping on order/s above $175 and if the customer/s wants to have it deliver as Express delivery. I want also to display that button of Express delivery. Hope you can help me with this.
Here is the code:
/**
* woocommerce_package_rates is a 2.1+ hook
*/
add_filter( ‘woocommerce_package_rates’, ‘hide_shipping_when_free_is_available’, 10, 2 );
/**
* Hide shipping rates when free shipping is available
*
* @param array $rates Array of rates found for the package
* @param array $package The package array/object being shipped
* @return array of modified rates
*/
function hide_shipping_when_free_is_available( $rates, $package ) {
// Only modify rates if free_shipping is present
if ( isset( $rates[‘free_shipping:5’] ) ) {
// To unset a single rate/method, do the following. This example unsets flat_rate shipping
unset( $rates[‘flat_rate:6’] );
// To unset all methods except for free_shipping, do the following
$free_shipping = $rates[‘free_shipping:5’];
$rates = array();
$rates[‘free_shipping:5’] = $free_shipping;
}
return $rates;
}
Best,
Billy
Attachments:
You must be
logged in to view attached files.