Page 1 of 1

Text instead of price on product page when using variants

Posted: Tue Jun 30, 2009 10:40 pm
by flattmatt
Hi
I couldn't find this anywhere-not sure what to search for - please correct me if I'm wrong.
I have many products, mostly with two variants on the same product. All my products start at $0.00, because most products have a variant of either $39 or $45 or something like that (some $10, and $15, etc...)
So I set the initial product price to $0.00 and use the Variant functions to Modify the price by the full amount. Problem is, when you go to the actual product page, the price is $0.00 to start with - which is rather misleading. I have set the header in the drop down to say "Choose Format", but if the price could begin as something like that, and then once a format is chosen, show me the actual price, that would be perfect.
I am using a Show Product 1 page.

Any help would be greatly appreciated!

Re: Text instead of price on product page when using variants

Posted: Wed Jul 01, 2009 6:34 am
by William M
I don't like to start at 0.00. For one thing, it looks kind of silly as you said.

If I know the small size is going to be $20.00, I start the product at $20.00 and the small choice is $0.00, the medium choice is $10.00 more, and the large choice is $20.00 more. Bumping or dropping the price a few dollars later is simpler this way too, only one price to change.

Starting at a positive number allows you to run a sale without the product showing a negative until a choice is made. -$5.00. Now, that looks REALLY dumb - and it looks like bad math when the base still shows $0.00 (instead of -$5.00) but the choice that should add $10.00 only adds $5.00. Much better when a $10.00 item shows the $5.00 sale as $5.00.

Re: Text instead of price on product page when using variants

Posted: Wed Jul 01, 2009 6:40 am
by mazhar
Edit ConLib/Utility/ProductPrice.ascx.cs file and locate following code line in Page_PreRender method

Code: Select all

Price.Text = string.Format(_PriceFormat, priceWithVAT);
and replace it with

Code: Select all

if (priceWithVAT != 0)
                            Price.Text = string.Format(_PriceFormat, priceWithVAT);
                        else
                        {
                            if (_Product.Variants.Count > 0 && _Product.Price == 0)
                                Price.Text = "Choose Format...";
                        }

Re: Text instead of price on product page when using variants

Posted: Wed Jul 01, 2009 6:58 am
by jmestep
When you have your products at a 0 price, they get rejected by GoogleBase feed, so you need to consider that also.

Re: Text instead of price on product page when using variants

Posted: Wed Jul 01, 2009 7:27 pm
by KreftB
Thanks for the code script...this is what some of us were looking for. I added a few additional parameters and ran across a new issue that I'm having trouble with...

The code I'm using to control the price appearance is:

Code: Select all

if (_Product.Variants.Count > 0)
     Price.Text = "As Low As:" + string.Format(_PriceFormat, priceWithVAT);
   else
      {
         if (_Product.Variants.Count == 0)
                 Price.Text = string.Format(_PriceFormat, priceWithVAT);
      }
For variants, the code is doing what I need it do; however, on the "Buy Product Page", the text is carrying over and displaying as "Our Price: As Low As:" <price>.

In short, I need some assistance removing the phrase "As Low As" from this page only:"

Thanks in advance for your assistance.

Ben K
http://www.animalloft.com

Re: Text instead of price on product page when using variants

Posted: Thu Jul 02, 2009 10:16 am
by mazhar
Our Price label is inside BuyProductDialog control so you need to put something in that control to hide it when no variant is selected.

Re: Text instead of price on product page when using variants

Posted: Thu Jul 02, 2009 3:26 pm
by KreftB
Thanks for posting back...I don't want to hide the "Our Price" label...I want to have the space show only the numeric price, not the text that I added in my code. In other words, I don't want the custom code to be applied to this page, but I do want it to be applied to the Featured Products conlib and the Category Grid pages.

Any suggestions? I'm still learning the AbleCommerce files.

Thanks,

Ben K
http://www.animalloft.com

Re: Text instead of price on product page when using variants

Posted: Fri Jul 03, 2009 5:53 am
by jmestep
You could make a customized copy of the Utility/ProductPrice and use it instead

Re: Text instead of price on product page when using variants

Posted: Fri Jul 03, 2009 8:26 am
by KreftB
Thanks...That makes complete sense...Worked perfectly!

In addition, I constructed a conditional statement that shows the price label text as "As Low As" at page load but changes to "Our Price" when a variant is selected.

Exactly what I wanted!

Thanks again,

Ben K
http://www.animalloft.com

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 11:55 am
by flattmatt

Code: Select all

Price.Text = string.Format(_PriceFormat, priceWithVAT);
and replace it with

Code: Select all

if (priceWithVAT != 0)
                            Price.Text = string.Format(_PriceFormat, priceWithVAT);
                        else
                        {
                            if (_Product.Variants.Count > 0 && _Product.Price == 0)
                                Price.Text = "Choose Format...";
                        }
I tried this, and it seems simple enough - but it generates this error on my category listing pages and search pages:


[[ConLib:Custom/CategoryGridPage4]] c:\websites\Able70_new2\ConLib\Utility\ProductPrice.ascx.cs(244): error CS1502: The best overloaded method match for 'CommerceBuilder.Orders.BasketItemDataSource.CreateForProduct(int, short, string, string)' has some invalid arguments

I can't even get past that to view a product

Here's what the code looks like:

Code: Select all

  protected void Page_PreRender(object sender, EventArgs e)
    {
        if (_Product != null)
        {
            if (!_Product.UseVariablePrice)
            {
                // UPDATE THE INCLUDED KITPRODUCTS (Included-Hidden and Included-Shown)
                if (_SelectedKitProducts == null || _SelectedKitProducts.Count == 0) UpdateIncludedKitOptions();
                ProductCalculator pcalc = ProductCalculator.LoadForProduct(_Product.ProductId, 1, _OptionList, _SelectedKitProducts);
                //IF REQUIRED MAKE ADJUSTMENTS TO DISPLAYED PRICE TO INCLUDE VAT
                LSDecimal basePriceWithVAT = TaxHelper.GetShopPrice(_Product.Price, _Product.TaxCodeId);
                LSDecimal priceWithVAT = TaxHelper.GetShopPrice(pcalc.Price, _Product.TaxCodeId);
                LSDecimal msrpWithVAT = TaxHelper.GetShopPrice(_Product.MSRP, _Product.TaxCodeId);
                if (!_Product.HidePrice)
                {
                    //PRICE IS VISIBLE, NO POPUP
                    phPricePopup.Visible = false;
                    //SHOW RETAIL PRICE IF INDICATED
                    if (_ShowRetailPrice && _Product.MSRP > 0 && !_Product.UseVariablePrice)
                    {
                        RetailPrice1.Text = string.Format(_RetailPriceFormat, _Product.MSRP);
                    }
                    else RetailPrice1.Text = string.Empty;
                    //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
                    {
                        if (priceWithVAT != 0)
                            Price.Text = string.Format(_PriceFormat, priceWithVAT);
                        else
                        {
                            if (_Product.Variants.Count > 0 && _Product.Price == 0)
                                Price.Text = "Choose Format...";
                        }
                    }
                }
                else
I don't think you need more than that.

Thanks!

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 12:30 pm
by jmestep
You might be using code from a different build. Some of those things changed.

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 12:34 pm
by flattmatt
My build info is:
PLATFORM: ASP.NET
VERSION: 7.0.3
BUILD: 12458

Any ideas there?

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 1:54 pm
by flattmatt
To make things even worse, when I upload my backup file with the original code, the error is still there!

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 4:14 pm
by jmestep
I tested the code and it worked fine on product, category and search pages.
Is this what your code in the ProductPrice.ascx.cs is showing? That code did change in 7.0.3

Code: Select all

            //USE VALUES FROM VS, CURRENT PROPERTIES MAY NOT BE CORRECT
            BasketItem basketItem = BasketItemDataSource.CreateForProduct(_AddProductId, 1, _AddOptionList, AlwaysConvert.ToList(",", _AddKitProducts));


Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 4:28 pm
by flattmatt
Nope, it shows this:

Code: Select all

 //USE VALUES FROM VS, CURRENT PROPERTIES MAY NOT BE CORRECT
            BasketItem basketItem = BasketItemDataSource.CreateForProduct(_AddProductId, 1, _AddOptionList, _AddKitProducts);
            if (basketItem != null)

Re: Text instead of price on product page when using variants

Posted: Tue Jul 07, 2009 4:36 pm
by flattmatt
It also returns this in a product page where the price should be:

Code: Select all

[[ConLib:BuyProductDialog]] c:\websites\Able70_new2\ConLib\Utility\ProductPrice.ascx.cs(244): error CS1502: The best overloaded method match for 'CommerceBuilder.Orders.BasketItemDataSource.CreateForProduct(int, short, string, string)' has some invalid arguments 
What is baffling me, is all I did was change that line of code from above - got the error - uploaded my backup file that I had just duplicated, and I still get this error - it's the same file that was there before. We even compared it to several backup files and line for line it's identical!

Re: Text instead of price on product page when using variants

Posted: Wed Jul 08, 2009 7:21 am
by flattmatt
We got it fixed - installed the file from the latest build and it corrected the problem, and the code for the text instead of price worked.
Thanks for all the input and help!