Page 1 of 1

Replace add to cart button with "call to order" text

Posted: Mon Nov 24, 2008 10:42 am
by tntmjr
When disabling purchase on a product it removes the add to cart button - how can i replace the now missing button with some text like "Call to Order"

I found this code but i'm not sure how to tell it to out put text.

private void HideAddToBasket()
{
AddToBasketButton.Visible = false;
AddToWishlistButton.Visible = false;
rowQuantity.Visible = false;

}

private void ShowAddToBasket()
{
AddToBasketButton.Visible = true;
AddToWishlistButton.Visible = true;
rowQuantity.Visible = true;

Re: Replace add to cart button with "call to order" text

Posted: Mon Nov 24, 2008 11:04 am
by mazhar
Very easy. Edit the ConLib/BuyProductDialog.ascx file and locate the following line of code

Code: Select all

<asp:LinkButton ID="AddToBasketButton" runat="server" SkinID="Button" Visible="true" OnClick="AddToBasketButton_Click" Text="Add to Basket" EnableViewState="false" ValidationGroup="AddToBasket"></asp:LinkButton>
and make it look like

Code: Select all

<asp:LinkButton ID="AddToBasketButton" runat="server" SkinID="Button" Visible="true" OnClick="AddToBasketButton_Click" Text="Add to Basket" EnableViewState="false" ValidationGroup="AddToBasket"></asp:LinkButton>
                    <asp:Label ID="CallToOrderLabel" runat="server" Text="Call to order" Visible="false"></asp:Label>
Now edit the ConLib/BuyProductDialog.ascx.cs file and in the HideAddToBasket function add the following line of code so it should look like as below

Code: Select all

private void HideAddToBasket()
    {
        AddToBasketButton.Visible = false;
        AddToWishlistButton.Visible = false;
        rowQuantity.Visible = false;
        CallToOrderLabel.Visible = true;
    }

Re: Replace add to cart button with "call to order" text

Posted: Mon Nov 24, 2008 11:56 am
by tntmjr
Thanks for the quick response.

However, the new text shows up all the time and we only want it to appear when there is no button. Am I missing something??

Here is what I have so far:

Code: Select all

<asp:LinkButton ID="AddToBasketButton" runat="server" SkinID="Button" Visible="true" OnClick="AddToBasketButton_Click" Text="Add to Basket" EnableViewState="false" ValidationGroup="AddToBasket"></asp:LinkButton>                    
                    <br />
<span style="color:red; font-weight:bold"> <asp:Label ID="CallToOrderLabel" runat="server" Text="Call To Place Order" Visible="false"></asp:Label></span>
and on the .cs page:

Code: Select all

 private void HideAddToBasket()
    {
        AddToBasketButton.Visible = false;
        AddToWishlistButton.Visible = false;
        rowQuantity.Visible = false;
		CallToOrderLabel.Visible = true;
    }

    private void ShowAddToBasket()
    {
        AddToBasketButton.Visible = true;
        AddToWishlistButton.Visible = true;
        rowQuantity.Visible = true;
    }

Re: Replace add to cart button with "call to order" text

Posted: Mon Nov 24, 2008 2:14 pm
by tntmjr
I found elsewhere in the code the function hideaddtobasket is called again. Which means we have set the visibility of my new CallToOrderLabel in both functions to reinforce it. Here is what I came up with.

On the buyproductdialog.ascx.cs page:

Code: Select all

 private void HideAddToBasket()
    {
      if (_Product.DisablePurchase) {
			CallToOrderLabel.Visible = true;
		}
		AddToBasketButton.Visible = false;
        AddToWishlistButton.Visible = false;
        rowQuantity.Visible = false;
	
    }

    private void ShowAddToBasket()
    {
        CallToOrderLabel.Visible = false;
        AddToBasketButton.Visible = true;
        AddToWishlistButton.Visible = true;
        rowQuantity.Visible = true;
    }
Thanks Again Mazhar for your help!!!

Thanks also go to Misty (AppX/FFG) for setting me straight.

Re: Replace add to cart button with "call to order" text

Posted: Tue Nov 25, 2008 4:52 am
by mazhar
nice job :D