A German medical products seller needs to assign variant-specific metafields (like PZN pharma codes, UDI, or medical registration numbers) to different packaging units of products such as COVID-19 rapid tests. This is required for legally compliant healthcare product listings.
Technical Challenge:
Shopify doesn’t natively support flexible variant-specific metafields in the desired way
The goal is to display unique identifiers per variant without full page reloads for better user experience
Proposed Solution:
Use JavaScript with Shopify’s AJAX API, React-based product pages, or headless Hydrogen
Implement a variant selector event listener that dynamically updates displayed metafields
Store all variant metafields in a JSON object within Liquid templates
Use JavaScript logic to fetch and display the correct PZN/identifier when users switch between variants
Implementation Steps:
Expose variant metafields in Liquid (preferably in HTML placeholders)
Add JS listener for variant selection changes
Retrieve selected variant ID and fetch corresponding metafield
Update display div with variant-specific data or show default if not found
A tutorial video from Shopify developer “Jan the Man” was recommended as a reference resource.
Status: Discussion remains open; no implementation has been confirmed yet.
Summarized with AI on October 27.
AI used: claude-sonnet-4-5-20250929.
we sell medical products in Germany. Many of our products, such as COVID-19 rapid tests, come in different packaging units (e.g., 1-piece, 5-pack, 20-pack) and also have variant-specific identifiers, such as PZN (German pharma code), UDI, or other medical registration numbers.
Currently, Shopify does not allow us to assign metafields per variant in a flexible way. However, this is crucial for legally compliant and informative product listings in the healthcare sector.
I’m looking for a way to implement variant-specific metafields in Shopify, so I can assign a unique PZN (or similar) to each variant of a product.
And “metafields per variant in a flexible way” - can you explain what you mean by that? Like when a user is eyeballing the Covid product on the PDP and they click between variants causing different details to appear as a single line text (like a certain PZN per variant) depending on the variant chosen?
One issue here is that you want to update the variant change without needing a full pagereload in order to provide a better UX. You would need something like Shopify’s AJAX API, a React-based PDP, or headless Hydrogen for that. Or code it into the Liquid with some JS like variantSelector.addEventListener(“change”, function () {updateSKU(this.value);
In other words, it will require a bit of coding where you need to expose all variant metafields in the Liquid, preferably inside an HTML placeholder, and some JavaScript logic (like an IF/ELSE via object lookup). Steps:
JS listens for changes in the variant selected by the user.
JS retrieves the selected variant ID.
Runs a fetch for the corresponding PZN metafield in the allVariantMetafields JSON object.
If metafield found for that variant, it updates the PZN in the
.
If the metafield not found, it shows the default description.