You’re absolutely right; the goal is to dynamically show a line item property that pulls a variant’s metafield value. I followed the steps you mentioned and successfully got the metafield value to show in the cart, but I ran into a problem with dynamic updates. Here’s what I did and where I’m stuck:
What Works So Far:
1.Confirmed the Variant Metafield Works
I successfully displayed the metafield value on the page (statically).
2.Confirmed Line Item Properties Work
I added the following hidden input inside the product form in PageFly:
This correctly passes the metafield value to the cart.
The Issue:
The first time a variant is selected, the correct Workshop Konumu (location) metafield value is stored and sent to the cart.
But when a new variant is selected, the form doesn’t update dynamically. Instead, it keeps the previous location value in the hidden input.
This means that the cart always receives the first selected variant’s metafield value, rather than updating it with each selection change.
Possible Causes (Based on Your Advice)
The input is inside the form, so it should be properly associated.
The issue seems to be that PageFly does not dynamically update the input’s value when the variant selection changes.
This might be due to how PageFly handles forms—perhaps it’s not fully re-rendering the input when a new selection is made.
What I Need Help With:
How can I force the hidden input’s value to update dynamically each time a variant is selected, ensuring that the cart receives the latest metafield value?
Would adding an event listener in JavaScript that updates the input value when a new variant is selected be the best approach?
Thanks for any insights!