Add to cart product with options

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
peterstolz
Ensign (ENS)
Ensign (ENS)
Posts: 5
Joined: Sun Nov 22, 2009 7:56 pm

Add to cart product with options

Post by peterstolz » Sat May 28, 2011 1:34 pm

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?

31somber
Ensign (ENS)
Ensign (ENS)
Posts: 1
Joined: Fri May 27, 2011 6:20 am
Contact:

Re: Add to cart product with options

Post by 31somber » Mon May 30, 2011 2:54 am

I have the same problem, anyone can help us out? Thanks in advance.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: Add to cart product with options

Post by compunerdy » Tue May 31, 2011 2:04 pm

Me 3.. would love to see this option.

User avatar
triplw
Commander (CMDR)
Commander (CMDR)
Posts: 144
Joined: Sat Jan 12, 2008 5:34 pm
Contact:

Re: Add to cart product with options

Post by triplw » Wed Jun 01, 2011 12:25 pm

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.

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: Add to cart product with options

Post by compunerdy » Wed Jun 01, 2011 1:54 pm

If you are hard coding URL links then I suppose you would not need to verify it. Where would you use this code?

User avatar
triplw
Commander (CMDR)
Commander (CMDR)
Posts: 144
Joined: Sat Jan 12, 2008 5:34 pm
Contact:

Re: Add to cart product with options

Post by triplw » Thu Jun 02, 2011 12:04 pm

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.

Post Reply