Change Shopping cart warning message

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
n8thanael
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Mon May 10, 2010 5:22 pm

Change Shopping cart warning message

Post by n8thanael » Thu Jun 10, 2010 11:41 am

How do I access/modify the shopping cart message: "The quantity of item (item) exceeds the available stock (quantity). The quantity has been reduced to quantity available."

User avatar
s_ismail
Commander (CMDR)
Commander (CMDR)
Posts: 162
Joined: Mon Nov 09, 2009 12:20 am
Contact:

Re: Change Shopping cart warning message

Post by s_ismail » Fri Jun 11, 2010 6:01 am

Locate this code in 'basket.ascx.cs'

Code: Select all

  protected void UpdateButton_Click(object sender, EventArgs e)
    {
        BasketHelper.SaveBasket(BasketGrid);
        BindBasketGrid();
    }

    protected void CheckoutButton_Click(object sender, EventArgs e)
    {
        BasketHelper.SaveBasket(BasketGrid);
        List<string> basketMessages;
        bool basketValid = Token.Instance.User.Basket.Validate(out basketMessages);
        if (basketValid) Response.Redirect(NavigationHelper.GetCheckoutUrl());
        else Session["BasketMessage"] = basketMessages;
    }
Replace with this code

Code: Select all

protected void UpdateButton_Click(object sender, EventArgs e)
    {
        BasketHelper.SaveBasket(BasketGrid);
        BindBasketGrid();
        List<string> basketMessages=new List<string>();
        UpdateMessage(basketMessages);
    }

    protected void CheckoutButton_Click(object sender, EventArgs e)
    {
        BasketHelper.SaveBasket(BasketGrid);
        List<string> basketMessages;
        bool basketValid = Token.Instance.User.Basket.Validate(out basketMessages);
        if (basketValid) Response.Redirect(NavigationHelper.GetCheckoutUrl());
        else Session["BasketMessage"] = basketMessages;
        UpdateMessage(basketMessages);
    }


    protected void UpdateMessage(List<string> basketMessages)
    {
        if (basketMessages.Count <= 0)
            Token.Instance.User.Basket.Validate(out basketMessages);
        foreach (string mesg in basketMessages)
        {
            if (mesg.Contains("The quantity has been reduced to quantity available"))
            {
                basketMessages.Remove(mesg);
                string CustomMessage ="Your quantity exceeds from available inventory.";
                basketMessages.Add(CustomMessage);
                Session["BasketMessage"] = basketMessages;
                break;
            }
        }
    }

n8thanael
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Mon May 10, 2010 5:22 pm

Re: Change Shopping cart warning message

Post by n8thanael » Fri Jun 11, 2010 9:24 am

Thanks! I appreciate the time you've taken to come up with a solution for a hack like me. You've got the skills I don't, But I'm learning :-). I did notice a bug though, if you could point me in the right direction, when I've got more than 1 items in my cart that have a quantity higher then I have in stock, the new message only replaces one of those - the old message that is generated remains.

User avatar
s_ismail
Commander (CMDR)
Commander (CMDR)
Posts: 162
Joined: Mon Nov 09, 2009 12:20 am
Contact:

Re: Change Shopping cart warning message

Post by s_ismail » Sat Jun 12, 2010 6:35 am

Sorry i don't understand about what you are talking , i need more detail to clarify what you want to modify.:(

User avatar
mfreeze
Commodore (COMO)
Commodore (COMO)
Posts: 421
Joined: Mon Jan 24, 2005 2:07 pm
Location: Washington, NJ
Contact:

Re: Change Shopping cart warning message

Post by mfreeze » Mon Aug 16, 2010 9:25 am

I put the following code in basket.aspx.cs on release 7.0.3 and it isn't working. The message stays the same as the original. Any idea what might be wrong?

Code: Select all

    protected void KeepShoppingButton_Click(object sender, EventArgs e)
    {
        Response.Redirect(NavigationHelper.GetLastShoppingUrl());
    }

    protected void UpdateMessage(List<string> basketMessages)
    {
        if (basketMessages.Count <= 0)
            Token.Instance.User.Basket.Validate(out basketMessages);
        foreach (string mesg in basketMessages)
        {
            if (mesg.Contains("The quantity has been reduced to quantity available."))
            {
                basketMessages.Remove(mesg);
                string CustomMessage ="The quantity has been reduced to quantity available. We may still be able to fill you entire order....please call us at 1-800-458-1948 or e-mail service@officeplayground.com..";
                basketMessages.Add(CustomMessage);
                Session["BasketMessage"] = basketMessages;
                break;
            }
        }
    }
Mary E Freeze

Freeze Frame Graphics
Web Hosting and Design, ASP and CFMX Development

http://www.ffgraphics.com

Post Reply