How to hide lblPrice if price = £0.00

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
Hi

I have some products with price varient attributes - there is no base price for these items so the displayed price is

£0.00

this appears in 3 places where i would prefer it not to

productbox1.ascx
productbox2.ascx
ProductPrice.ascx

now, on the nop sponsorship program page, the price is invisible - just the attribute list with price varients - thats what i would like to acheive on ProductPrice.ascx


and on
productbox1.ascx and productbox2.ascx I would like to just hide the price if the value is 0.00

i guess something like:


else
{
                if (finalPriceWithoutDiscount == 0);
                {
                    lblPrice.Visible = false;
                }
}

placed just above just above the existing


                else
                {
                    lblOldPrice.Visible = false;
                    lblPrice.Visible = false;
                    btnAddToCart.Visible = false;
                }
            }
        }


but i need guidence on how to implement it exactly - any help appreciated !!
.
14 years ago
Almost spot on Hayden!

But, you cant put it there as it will not reference the finalPriceWithoutDiscount

Where I would put it is:

if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero)
                        {
                            lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice);
                            lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                        }
                        else
                        {
                            lblOldPrice.Visible = false;

                            if (finalPriceWithoutDiscount == 0)
                            {
                                lblPrice.Visible = false;
                            }


                            lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                        }

                        btnAddToCart.Visible = (!productVariant.DisableBuyButton);
                    }


Check and I think this will work..

mike..
14 years ago
thanks mike, achieved just what i wanted !

with regards to doing the same in ProductPrice.ascx

i managed to hide it but would you say here is the best place for it : (in bold)

                if (phDiscount.Visible || phOldPrice.Visible)
                {
                    lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
                }

//
            if (finalPriceWithoutDiscount == 0)
            {
                lblPriceValue.Visible = false;
            }

//
            }

            else
                this.Visible = false;
        }


i tried putting it further up the page - after line 77 - the price disappeared but the 'your price:' (related to discounts) was rendered
14 years ago
Is this gonna hide the "Add to  Cart" button too if the price is 0 ?
I'm trying to set it up so it's like a catalog, not a shopping cart just yet...

thanks
14 years ago
Hi,

Haydie,

What you could do is this ProductPrice.ascx

<asp:Panel runat="server" ID="pnlHidePrice">
<asp:PlaceHolder runat="server" ID="phOldPrice">
    <%=GetLocaleResourceString("Products.OldPrice")%>&nbsp;
    <asp:Label ID="lblOldPrice" runat="server" CssClass="oldProductPrice" />
</asp:PlaceHolder>
<br />
<asp:Label ID="lblPrice" runat="server" Visible="false" />
<asp:Label ID="lblPriceValue" runat="server" CssClass="productPrice" />
<asp:PlaceHolder runat="server" ID="phDiscount">
    <br />
    <%=GetLocaleResourceString("Products.FinalPriceWithDiscount")%>&nbsp;&nbsp;
    <asp:Label ID="lblFinalPriceWithDiscount" runat="server" CssClass="productPrice" />
</asp:PlaceHolder>
</asp:Panel>

and in the ProductPrice.acx.cs

 if (phDiscount.Visible || phOldPrice.Visible)
{
        lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
}

if (finalPriceWithoutDiscount == 0)
{
        pnlHidePrice.Visible = false;
}
}
else
    this.Visible = false;


This will hide all price labels..

tlp560

This will not hide your add to cart button, but you can set a catalog by going to administration

Then select Catalog > Products > Manage Products now select your product to be displayed as catalog,

and then goto Product Variant(SKU) tab and select the product, then select Disable Buy button..

Hope this helps..

mike..
14 years ago
thanks for that, the page makes more sense to potential customers now.

cheers,
hayden
14 years ago
Thank you very much.
6 years ago
where is the location of this file productprice.ascx in 3.8
6 years ago
rose wrote:
where is the location of this file productprice.ascx in 3.8

Hi,

Look for _ProductPrice.cshtml in Product catalog. Please note, you should not do any modification at main views folder. You should copy that file to your theme (if do not support this item).

Regards,
Tomasz
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.