Hello, Shopify Dev Community,
I’m having trouble getting my variant descriptions to update dynamically when a customer selects a different variant on my product page. The descriptions are stored as variant-level metafields, and while they change after refreshing the page, they don’t update automatically when a variant is selected.
Important Note: I have zero experience with coding or Shopify development, and ChatGPT has guided me through the process so far. I’m hoping for a simple, step-by-step solution that I can follow.
What I’ve Done So Far:
- Created a variant metafield under Settings > Custom Data > Variants
- Name:
Variant Description
- Type:
Rich text
- Namespace & Key:
custom.variant_description
- Populated the metafields for each product variant with unique descriptions.
- Added a Custom Liquid block under the Variant Picker in my theme, using:
<div id="variant-description">
{{ product.selected_or_first_available_variant.metafields.custom.variant_description.value }}
</div>
- Tried JavaScript solutions to detect variant selection and update the description dynamically, including:
- Listening for
variant:change
events. - Fetching the product JSON and updating the description.
- Checked for conflicts with my theme’s default variant selection logic.
Current Issue:
- The description only changes when the page is refreshed but not when selecting a different variant.
- I need the description to update instantly when a new variant is selected.
- Since I have no coding experience, I’d appreciate a clear, beginner-friendly solution that I can implement.
I’d really appreciate any help! Thank you.