Shopify themes and metafields
This page is for a developer working on a Shopify theme, or on the API against a connected Shopify store. Connecting the store is in Connecting Shopify.
Sync order and matching. The backfill syncs products, then customers, then orders,
through the same pipeline as a CSV import. Products, variants and customers match on their
Shopify ID first (externalId on the record, the numeric form), then on handle or email.
Look a record up, update it or delete it by its Shopify ID with /products/{id} or
/customers/{id}, which take a Shopify ID as well as Meisei's own (add by=externalId to
say which). With several stores connected, externalIds lists each store's ID and those
routes take the store's site as ?site=.
Metafield mappings store values as text (structured values are serialized), merge into
metadata rather than replacing it, can't target connector keys such as shopifySku,
and read up to 50 metafields per record. You can filter on mapped metadata, for
example on metadata.lifecycleStage.
Shopper identity. Wishlists and a member's own balance need a signature. On Shopify the app answers for the signed-in shopper through the app proxy on the store's own domain, so the theme never sees the signing secret. A shopper Meisei hasn't synced yet is looked up in Shopify once and remembered. Product slugs are Shopify handles.
Ratings as product metafields. Meisei fills these on the first sync and updates them whenever a review is published, edited or removed. A product that has never had a published review has no metafield. Meisei also writes Shopify's standard pair, which themes such as Dawn read for the stars on product cards, and which Shopify's own product feeds pick up. If another reviews app also writes the standard pair, whichever wrote last wins, so switch the other app's off.
Loyalty as customer metafields. Meisei updates these within moments of a change. A member with no
tier has no loyalty_tier metafield. Liquid only exposes the signed-in customer's record.
The theme as a shop metafield. shop.metafields.meisei.widget_theme holds
{ css, version }, the same stylesheet /widgets/theme.css serves for the site the store
syncs into. The Meisei embed prints it into a <style>, so a Shopify page never requests
it. Meisei rewrites it when that site's appearance is saved, and once a day.