# Product detail event

* Selecting variant from variant picker of Smind

This event is fired whenever a user has changed the variant in a product selector, either in a product page, featured product section or quick view and quick add section

<table data-header-hidden><thead><tr><th>Event</th><th>Detail</th></tr></thead><tbody><tr><td><code>variant:change</code></td><td><pre><code>detail: {variant}
</code></pre></td></tr></tbody></table>

\
variant: Is an object variant of Shopify (<https://shopify.dev/docs/api/liquid/objects/variant>)

The "change variant" event will be listened to by other components to update related elements such as product price, inventory status, SKU, add to cart button, and checkout.

Example usage:

```
document.addEventListener('variant:change', ({ detail: event }) => {
    try{
        const variant = event.variant;
        const variantId = event.variant?.id;
        console.log(variant);
        console.log(variantId);
    } catch (error) {
        console.log('error: ', error)
    }
});
```

* Changing the product variant without using Smind’s variant picker.

If you're replacing the variant selection using Smind’s variant picker with a third-party solution, please make sure to dispatch an event after selecting a variant so that other components can listen for the variant change.

The variant change event must be named **"variant:change"** and must include a **variant object** with the same structure as Shopify's default variant object. (<https://shopify.dev/docs/api/liquid/objects/variant>)

Example usage:

```
container.dispatchEvent(new CustomEvent("variant:change", {
    detail: {
      variant
    },
    bubbles: true
  }));
```

<table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><pre><code>container
</code></pre></td><td>The section container that includes the variant picker</td></tr><tr><td><pre><code>variant
</code></pre></td><td>Object variant that selected</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.smind.io/dev/product-detail-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
