Yeah that did the trick alright. Out of the box, the shopping cart page will automatically display a string resource about the order needs to be more than __X__ amount, if the cart is currently under that, and the Checkout button is hidden. SWEET.
So to summarize...if you want to set a minimum amount on the order
subtotal (as there is a different setting for order total after shipping, tax, etc.):
1) Make changes to MiniShoppingCartBoxControl.ascx.cs, as bfranklin825 so kindly documented. Make a few extra mods so that it works with 1.9. (small API changes)
2) Go into the admin area and update the Order.MinOrderSubtotalAmount setting to whatever you want the minimum to be.
So maybe someone in the future will want to see the code mods from #1? Sure, but with the disclaimer that I took the shortest path approach to solve the problem (aka hacked through). I'm sure there are some things I didn't consider, and some API things that are better approaches, of which I am currently ignorant.
protected override void OnPreRender(EventArgs e)
{
if (this.SettingManager.GetSettingValueBoolean("Common.ShowMiniShoppingCart"))
{
var shoppingCart = this.ShoppingCartService.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
if (shoppingCart.TotalProducts == 0)
{
phCheckoutInfo.Visible = false;
lShoppingCart.Text = GetLocaleResourceString("MiniShoppingCartBox.NoItems");
lvCart.Visible = false;
}
else
{
// ###############################################
// ### Changing code according to below URL to create minimum order
// ### feature. Having to take some license, since the nopCommerce
// ### source code has changed since the forum post was published:
// ### Check out bfranklin825's post here: http://bit.ly/kq7ski
string orderSubTotal = GetOrderSubtotal(shoppingCart);
// ### This can return a string if "order is calculated during checkout".
// ### Also, I'm not worrying about checking the minimum with discounts
// ### applied. There's some usable info in the forum post to help
// ### if that's part of your requirements
decimal parsedSubTotal;
if (! Decimal.TryParse(orderSubTotal, out parsedSubTotal))
{
// ### "Calculated during checkout". You may want to do something else
// ### here besides defaulting to 0.00. Or use bfranklin825's
// ### protected decimal GetComparableSubTotal(ShoppingCart shoppingcart)
// ### method listed at:
// ### http://bit.ly/kq7ski
parsedSubTotal = decimal.Zero;
}
if (parsedSubTotal < OrderService.MinOrderSubtotalAmount)
{
phCheckoutInfo.Visible = false;
}
else
{
phCheckoutInfo.Visible = true;
}
// ### Need to comment out the below so above will work
// phCheckoutInfo.Visible = true;
// ###############################################
if (shoppingCart.TotalProducts == 1)
{
//lShoppingCart.Text = string.Format(GetLocaleResourceString("MiniShoppingCartBox.OneItemText"), string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), GetLocaleResourceString("MiniShoppingCartBox.OneItem")));
lShoppingCart.Text = string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), GetLocaleResourceString("MiniShoppingCartBox.OneItem"));
}
else
{
//lShoppingCart.Text = string.Format(GetLocaleResourceString("MiniShoppingCartBox.SeveralItemsText"), string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), string.Format(GetLocaleResourceString("MiniShoppingCartBox.SeveralItems"), shoppingCart.TotalProducts)));
lShoppingCart.Text = string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), string.Format(GetLocaleResourceString("MiniShoppingCartBox.SeveralItems"), shoppingCart.TotalProducts));
}
//lblOrderSubtotal.Text = GetLocaleResourceString("MiniShoppingCartBox.OrderSubtotal", GetOrderSubtotal(shoppingCart));
if (this.SettingManager.GetSettingValueBoolean("Display.ItemsInMiniShoppingCart", false))
{
lvCart.Visible = true;
lvCart.DataSource = shoppingCart;
lvCart.DataBind();
}
else
{
lvCart.Visible = false;
}
}
}
else
{
this.Visible = false;
}
}