Hiding certain shipping options depending on basket total

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
Intelliflex
Lieutenant (LT)
Lieutenant (LT)
Posts: 78
Joined: Tue Feb 17, 2004 7:51 pm

Hiding certain shipping options depending on basket total

Post by Intelliflex » Tue Nov 08, 2011 2:49 pm

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!
Dave

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Hiding certain shipping options depending on basket total

Post by david-ebt » Tue Nov 08, 2011 3:20 pm

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.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

Post Reply