EZ Exporter: Reference Shopify Metafields in Custom Fields and Calculated Fields

We've recently pushed an update to EZ Exporter to allow our users to reference Shopify Metafields in the Custom Fields and Calculated Fields sections of the app.

EZ Exporter has supported exporting metafields for a long time now, but it was limited to mapping each metafield value to a custom column in their CSV/Excel exports.

With this update, users of our app can extend that functionality by allowing them to combine the metafield values with other built-in Shopify field values or manipulate them using formulas.

For example, a store owner might attach a metafield to a product variant to store a special discount amount in a metafield namespace called "global" and a metafield key called "special_discount_amount" that varies by variant. The store owner might then want to generate a custom report with a column that automatically subtracts that metafield value from the variant's price.

This can be done in the app using a Calculated Field formula like this:

{{ variants.price }} - float({{ variants.metafields.global.special_discount_amount }})

Another example is for generating custom product feeds to use in another platform. A store owner might want to generate a custom CSV product feed for Google Shopping where the product name column includes the product's condition, which is stored in a product metafield under a namespace called "google_shopping" and key called "condition".

This can be added in a Custom Field like this:

{{ title }} - {{ metafields.google_shopping.condition }} Condition!

Back in late 2018, Shopify has also introduced a new json_string data type for metafields. We've seen some apps utilize this feature and store custom fields as JSON data instead of using separate metafield keys. There may be cases where you just want to pull one value from the JSON data instead of exporting the entire thing. This is also now possible as our Calculated Fields feature supports functions that can parse that data like this:

get_attribute_value({{ metafields.customer_fields.data }}, "shirt_size")

Depending on the type of export, the fields to reference could vary slightly. For example, order exports can involve other resources such as the product, product variant, and customer so each of those types of data will have its own prefix.

Below is a list of the different types of metafields that can be referenced for each type of data export:

Order Export

  • Order Metafields: {{ metafields.<namespace>.<key> }}
  • Product Metafields: {{ line_items.product.metafields.<namespace>.<key> }}
  • Variant Metafields: {{ line_items.variant.metafields.<namespace>.<key> }}
  • Customer Metafields: {{ customer.metafields.<namespace>.<key> }}

Draft Order Export

  • Draft Order Metafields: {{ metafields.<namespace>.<key> }}
  • Product Metafields: {{ line_items.product.metafields.<namespace>.<key> }}
  • Variant Metafields: {{ line_items.variant.metafields.<namespace>.<key> }}
  • Customer Metafields: {{ customer.metafields.<namespace>.<key> }}

Product Export

  • Product Metafields: {{ metafields.<namespace>.<key> }}
  • Variant Metafields: {{ variants.metafields.<namespace>.<key> }}

Customer Export

  • Customer Metafields: {{ metafields.<namespace>.<key> }}

Collection Export

  • Collection Metafields: {{ metafields.<namespace>.<key> }}

Since this is a bit of an advanced feature, please don't hesitate to contact us if you need any assistance!


Related Posts:


Tags: ez exporter, advanced features, shopify data export, custom csv exports, shopify metafields, custom excel exports