How to retrieve color and size from Wix Stores products collection

Hi there,

I’m trying to have my selection tags autopopulate depending on what product options (color, size, etc.) are available in the dataset. I have seen that others are able to assign selection tags their values by using the following code, but the example does not go deep enough into the results in order to demonstrate accessing the product options:

$w.onReady(function () { 
    wixData.query(productsDatabaseName)
    .find({appOptions: {
        // Include product variants in the query. Default is `false`.
        includeVariants: true
        }
    })
    .then((results) => {
        console.log(results.items);
        let options = []
        options = results.items.map(item => {
            return {
                label: item,
                value: item
            }
        })
        coloursForTags = options;

Any help on this would be very much appreciated.

Many thanks!

About Wix-Stores (Products)…

// Query all products
wixData.query("Stores/Products")
  .find()
  .then((results) => {
    // handle the results
  });

// Query all products, including variants and hidden products (optional)
wixData.query("Stores/Products")
  .find({
    appOptions: {
      // Include product variants in the query. Default is `false`.
      includeVariants: true,
      // Include hidden products in the query. Default is `false`.
      includeHiddenProducts: true
    }
  })
  .then((results) => {
    // handle the results
  });

Hi,

thanks for the response but it doesn’t address how I would access the product options specifically in order to assign them to my selection tags. Where you state to “handle the results” is what I’m needing to understand.

Thanks again