Get variant by chosen options

Tomasz Czado asked on July 19, 2015 20:13

Hi everyone.

Let's say, that I have two option category in my product (with below options for each of them):

  • Operating system:
    • iOS
    • Android
  • Device:
    • Phone
    • Tablet
    • Laptop

And I have only one variant: iOS + Phone.

How can I check, if for selected options product contains variant? What API method's should I use? I need it to perform come custom functionality.

For example:

  • user select: Android + Tablet - return null
  • user select: iOS + Phone- return SKUInfo

Recent Answers


Virgil Carroll answered on July 19, 2015 22:26

Are you wanting to check the item on the detail page before submission or are you wanting to check it in the Shopping Cart? If you want to check it on the page, you will need to access the Ecommerce API > Product Helper > IsOptionAllowed

Otherwise in the ShoppingCart, check out the ShoppingCartInfoProvider on the EcommerceProvider API

0 votesVote for this answer Mark as a Correct answer

Tomasz Czado answered on July 19, 2015 23:03

I have two drop downs with options category. After selecting values in both of drop downs i want to check, if product has generated variant with both of selected options so than I can take SKUID for this variant.

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on July 19, 2015 23:38

so you want to do this when the product is being submitted to the ShoppingCart correct? Then you need to look at the ShoppingCartInfo Provider and override the SetShoppingCartItemInternal method to take a look at the options that are being sent and change the SKU information if needed.

0 votesVote for this answer Mark as a Correct answer

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