Page 1 of 1
Hiding certain shipping options depending on basket total
Posted: Tue Nov 08, 2011 2:49 pm
by Intelliflex
I have a client that would like to hide the UPS shipping once an order is over $100. Currently, the Free Shipping is showing on the dropdown, but so is the UPS and some customers are choosing the UPS shipping which is a charge and they are missing the Free shipping.
So in a nutshell, the UPS shipping should be a choice when the order is below $100, and the Free Shipping should be the only choice when the order is $100 or more.
Thoughts?
Thanks!
Re: Hiding certain shipping options depending on basket total
Posted: Tue Nov 08, 2011 3:20 pm
by david-ebt
Take a look at the ShipmentList_ItemDataBound function in the Conlib\OnePageCheckout.ascx.cs file.
You can get the product total at the top of that function or set it to a boolean:
Code: Select all
bool useUPS = _Basket.Items.TotalProductPrice() < AlwaysConvert.ToDecimal("100.00");
then inside the foreach loop add a check before adding the UPS shipping method. Something like this:
Code: Select all
foreach (ShipRateQuote quote in rateQuotes)
{
LSDecimal totalRate = TaxHelper.GetShopPrice(quote.TotalRate, quote.ShipMethod.TaxCodeId, null, new TaxAddress(shipment.Address));
string formattedRate = totalRate.ToString("ulc");
string methodName = (totalRate > 0) ? quote.Name + ": " + formattedRate : quote.Name;
if (quote.Name.Contains("UPS")) {
if (useUPS) {
localQuotes.Add(new LocalShipRateQuote(quote.ShipMethodId, methodName, formattedRate));
}
}
else {
localQuotes.Add(new LocalShipRateQuote(quote.ShipMethodId, methodName, formattedRate));
}
}
If you're using the shipping estimator on the basket page you'll want to do the same thing there.