This modification will change how your product prices are displayed for variant products. As of AC 7.0.5, variant products will show a zero amount for the price until a variant selection has been made. This is only mildly confusing if the shopper is on the product page, but horrible if they're browsing your categories. Nobody (who wants to stay in business) likes to show a zero price. Ever.
So I came up with a way to make the product price control show the range of prices possible for a given variant product. For example, your variant product has 5 choices priced from $9.95 all the way to $ 124.95. Out of the box, AC7 will always show this product with a zero price until a variant selection is made. This happens both in the category and product page displays. With my modification, prices will now display as a range i.e. "$ 9.95 - $ 124.95". That looks much more elegant than "$ 0.00".
Files to Modify
As always, time for the disclaimer. Back up any files you modify before you make changes to them. That way any damage done can be easily reverted to a working copy. With that said, let's make the change....
Edit the /ConLib/Utility/ProductPrice.ascx.cs user control file. Find this code:
Code: Select all
//SHOW THE PRICE
if (pcalc.AppliedSpecial != null && pcalc.AppliedSpecial.EndDate != DateTime.MinValue)
{
// SHOW THE BASE PRICE AND SPECIAL PRICE
RetailPrice1.Text = string.Format(_BasePriceFormat, basePriceWithVAT);
Price.Text = string.Format(_SpecialPriceFormat, priceWithVAT, pcalc.AppliedSpecial.EndDate);
}
else
{
Price.Text = string.Format(_PriceFormat, priceWithVAT);
}
Code: Select all
//SHOW THE PRICE
if (pcalc.AppliedSpecial != null && pcalc.AppliedSpecial.EndDate != DateTime.MinValue)
{
// SHOW THE BASE PRICE AND SPECIAL PRICE
RetailPrice1.Text = string.Format(_BasePriceFormat, basePriceWithVAT);
Price.Text = string.Format(_SpecialPriceFormat, priceWithVAT, pcalc.AppliedSpecial.EndDate);
}
else
{
Price.Text = string.Format(_PriceFormat, priceWithVAT);
}
// BEGIN MOD: AbleMods.com
// 8/10/2010
// Show range of prices for the price if variants are involved
if (_Product.Variants.Count > 0 && _OptionList == "")
{
// find only the available variants for this product
ProductVariantCollection _Variants = new ProductVariantCollection();
foreach (ProductVariant _Variant in _Product.Variants)
if (_Variant.Available)
_Variants.Add(_Variant);
// grab the lowest and highest prices in the collection
LSDecimal _LowestPrice = 0;
LSDecimal _HighestPrice = 0;
foreach (ProductVariant _Variant in _Variants)
{
if (_Variant.Price > _HighestPrice)
_HighestPrice = _Variant.Price;
if (_Variant.Price < _LowestPrice | _LowestPrice == 0)
_LowestPrice = _Variant.Price;
}
// error check - we should have at least 1 variant.
// if we don't, log it because we've got a product with NO available variants
// makes it kind of hard to buy it :)
if (_Variants.Count < 1)
{
ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Warn, "AbleMods", "Product <a href='/admin/products/editproduct.aspx?ProductId=" + _Product.ProductId + "'>" + _Product.Name + "</a> has no available variants for sale"));
Price.Text = "unavailable";
}
else
{
// Show the lowest price first
Price.Text = String.Format(_PriceFormat, _LowestPrice);
// if there is a range of prices available, show the high end on the price as well
if (_LowestPrice != _HighestPrice)
Price.Text += String.Format(" - " + _PriceFormat, _HighestPrice);
}
}
// don't show anything if it's a zero-price
if (Price.Text == "$0.00")
Price.Text = "";
// END MOD: AbleMods.com
You can see a working example of this modification on my site here: http://www.solunar.com/Rifles-C1125.asp ... %20ASC&p=3
The nice thing about this modification is the ProductPrice user control is referenced in many places. So all of them should be updated with this one modification.
Enjoy !