Shopify / slate

Slate is a toolkit for developing Shopify themes. It's designed to assist your workflow and speed up the process of developing, testing, and deploying themes.
https://shopify.github.io/slate
MIT License
1.28k stars 364 forks source link

Using onFormOptionChange() in templates/product.js #1051

Open josefarrugia opened 4 years ago

josefarrugia commented 4 years ago

Hi there,

How do I go about using the onFormOptionChange() method found in sections/product.js inside templates/product.js or another file (example: components/collapse.js)?

Essentially, I want to manually trigger a renderPrice(), renderImages(), renderComparePrice, renderSubmitButton and so on when event happens – clicking on a button.

adamrasheed commented 4 years ago

I made this helper function to get the product data for a product by inputting the variantId:

getVariantObject(variantId) {
    // eslint-disable-next-line eqeqeq
    return this.product.variants.find(({ id }) => id == variantId);
  }

I add this data as the event parameter and it seems to work.