selectCallback in Shopify.SelectOptions is always returning `null`

Highlighted
New Member
5 0 0

Can someone explain how `Shopify.SelectOptions` works?

 

`selectCallback` sets `variant` equal to `null` on all my option selections besides the initial call. On the initial call, it logs the variant with the first color and size.

 

const productJson = JSON.parse($(`#${id}`).attr('data-product'));

new Shopify.OptionSelectors(id, {
    product: productJson,
    onVariantSelected: selectCallback,
});

const selectCallback = (variant, select, options) => {
    console.log(variant) // `null`
}

 

 

0 Likes