Page 1 of 1

Add to cart product with options

Posted: Sat May 28, 2011 1:34 pm
by peterstolz
I have a need to add to cart from an external entity a product that has options.

http://wiki.ablecommerce.com/index.php/ ... nal_entity
I found the wiki article above, however it states that products with options can't be added.

if (product.HasChoices)
{
//CANT ADD DIRECTLY TO BASKET, SEND TO MORE INFO
Response.Redirect(product.NavigateUrl);
}

Can this be done?

Re: Add to cart product with options

Posted: Mon May 30, 2011 2:54 am
by 31somber
I have the same problem, anyone can help us out? Thanks in advance.

Re: Add to cart product with options

Posted: Tue May 31, 2011 2:04 pm
by compunerdy
Me 3.. would love to see this option.

Re: Add to cart product with options

Posted: Wed Jun 01, 2011 12:25 pm
by triplw
You can use this code:

Code: Select all

  BasketItem basketItem = BasketItemDataSource.CreateForProduct(_ProductId, (short)tempQuantity, optionList, AlwaysConvert.ToList(",", _SelectedKitProducts));
You would have to do the validation to make sure all options have been selected.

Re: Add to cart product with options

Posted: Wed Jun 01, 2011 1:54 pm
by compunerdy
If you are hard coding URL links then I suppose you would not need to verify it. Where would you use this code?

Re: Add to cart product with options

Posted: Thu Jun 02, 2011 12:04 pm
by triplw
It's looking for
1) the product Id
2) quantity
3) a string of 8 comma separated numbers to know what options are selected. For example, if your product had 2 options the the string would be something like: 12,35,0,0,0,0,0,0
4) kit products selected

The hard part is figuring out what numbers are assigned to the different options. You could see it in the database tables: ac_products, ac_productvariants and ac_productoptions.