How to add product options to a product?

Charlie Bodnar-Horvath asked on July 3, 2017 07:00

I'm trying to do this with code and I feel the API documentation is not helpful at all!

This page is effectively useless. I've added categories to the product, I've made sure the product is allowed, i've used the SKUAllowedOptionInfoProvider to add the option to the product and it still doesn't show up in the shopping cart. I tried adding it using using ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID,1, productOptions);

But still nothing happens, I just get the original product. I even hardcode the SKUID's into the product options list and still there's nothing.

I just want an simple method to add an existing product option to an existing product. I can do it with the WYSIWYG editor(I get a prompt to select options before it's added to the cart) but for some reason it doesn't work when I create the order with code.

Thanks in advance for your help. I've spent almost 2 days on this and I'm at my wits end.

Correct Answer

Trevor Fayas answered on July 5, 2017 19:28

Hey Charlie,

Can you clarify a little more? Are you trying to...

  1. Add a newly created Variant to an existing product dynamically.
  2. Add an existing Variant to the cart
  3. Add a category object to your product

It sounds like #3 is what you are trying to do, in which case it should help to know that an added product category has it's own SKUID, and when added to the cart it should set the ShoppingCartSKU's SkuID to it, and the [CartItemParentGuid] to the main product it's being added to.

And in there, to the ShoppingCartItemInfo cartItem, set the cartItem.CartItemParentGUID to the parent's cart item guid.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Charlie Bodnar-Horvath answered on July 6, 2017 06:11

Hi Trevor, it was #3. I apologize for writing such a poor question, I was a bit frustrated at the time and should have provided some code examples to clarify things. Thanks for your answer.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.