ResourcePicker Selecting Variants when resourceType is set to Product?

Solved
AppBuilder
Tourist
11 1 0

My goal is to select Variants from ResourcePicker React Component

I have set resourceType to "Product" instead of "ProductVariant" because you can set showVariants to true.

Doing it this way is a lot more organized because the variants are nested under each Product.

I am having trouble accessing the Variant IDs

 

handleSelection = (resources) => {
    const idsFromResources = resources.selection.map((product) =>
      product.variants.map((variant) => variant.id)
    );
    this.setState({ open: false });
    console.log(idsFromResources);
  };

 

Javascript Console ArrayJavascript Console Array

How do I extract all the variant IDs from my current code? I am so close. I am new to development

0 Likes
AppBuilder
Tourist
11 1 0

This is an accepted solution.

[Solved]

0 Likes
tommydev
Tourist
6 0 0

Did you find a way to select the variants in the ResourcePicker(with products)?

0 Likes