Page 1 of 1

How to add muti items to basket?

Posted: Wed Jan 20, 2010 10:12 pm
by danny
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.

Re: How to add muti items to basket?

Posted: Thu Jan 21, 2010 8:38 am
by jmestep
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.

Re: How to add muti items to basket?

Posted: Thu Jan 21, 2010 9:21 am
by mazhar
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.

Re: How to add muti items to basket?

Posted: Thu Jan 21, 2010 1:55 pm
by danny
I want to add product(multi options) to Basket in one shot. not multi product.

I'm sorry for confusing.

Thank you.