How to add muti items to basket?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
danny
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Tue Jan 12, 2010 6:58 pm

How to add muti items to basket?

Post by danny » Wed Jan 20, 2010 10:12 pm

Hello.

I need to be able to add multiple products to a basket in on shot. (at ProductDetail.)

Basket basket = Token.Instance.User.Basket;

BasketItem basketItem1 = BasketItemDataSource.CreateForProduct(_ProductId, (short)tempQuantity, optionList, null);
basketItem1.BasketId = basket.BasketId;

BasketItem basketItem2 = BasketItemDataSource.CreateForProduct(_ProductId, (short)tempQuantity, optionList, null);
basketItem2.BasketId = basket.BasketId;

basket.Items.Add(basketItem1);
basket.Items.Add(basketItem2);

basket.Save();

List<string> basketMessages;

if (!basket.Validate(out basketMessages))
{
Session.Add("BasketMessage", basketMessages);
Response.Redirect(NavigationHelper.GetBasketUrl());
}

If I use Validate() function, only add one item to basket.
other items is removed with "The item is out of stock. It has been removed from the basket." message. (at Basket)

If I don't use Validate() function, add all items to basekt.

I'm afraid that don't use validate() function.

Please help me.
Thank you.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: How to add muti items to basket?

Post by jmestep » Thu Jan 21, 2010 8:38 am

You could look at CategoryGridPage3 -- it allows adding of more than one item with one add to cart button. You could adapt that code to your purpose.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to add muti items to basket?

Post by mazhar » Thu Jan 21, 2010 9:21 am

If you don't want the customer to enter any number of quantity and want to restrict him to a specific number then simply go to Edit Product page and set MinQuantity and MaxQuantity . For example if you want customer must always purchase 5 items of this product then min/max should be set to 5.

danny
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Tue Jan 12, 2010 6:58 pm

Re: How to add muti items to basket?

Post by danny » Thu Jan 21, 2010 1:55 pm

I want to add product(multi options) to Basket in one shot. not multi product.

I'm sorry for confusing.

Thank you.

Post Reply