This is one way to produce a table based size chart in Shopify leveraging Metafields, Locales and some basic Liquid. The data for product size charts (metafields) are applied via an ERP I developed so for example sake I have created a Flems which allows folks to generate the JSON for each product.
The example size_charts.liquid
is assumed to be a snippet. The measurements
variable is passed in via render tag arguments within a section - For example, let's say your section is called product_information.liquid
- then you would include the snippet like this:
{% render 'size_charts', measurements: product.metafields.data.measurements.value %}
Visit this flems
This approach requires entries to be populated into locales. The attached en.json
snippet is an extract I apply for one of our brands.
In order to get the most from the otherwise poor performance of Shopify stores, we apply some additional logic using Global metafields. See the snippet at global_metafields.json
which is used to describe key values.
The product_example_metafield.json
snippet is the output result and used to render the size charts.
For some additonal context I have included a minimal example of a stimulus controller which is responsible for switching between metric and imperial sizing. This is totally optional.
bare in mind that some internal logic exists in the component, like
customer.session.countryCode
which is an internal data reference to customers that automaticaly loads the location, so omit that.
The size charts are responsive and use different naming conventions in different screen sizes.