example_schema.json

Imagine a merchant has a Shopify store with a complex rewards program. They want to create a new metafield for their customers, orders, and products. They can do this by creating a Schema file.

[
  {
    "name": "Rewards Balance",
    "description": "The current balance of the customer's rewards points",
    "namespace": "rewards",
    "key": "balance",
    "type": "number_integer",
    "ownerType": "CUSTOMER"	
  },
  {
    "name": "Total Points Earned",
    "description": "The total points earned by the customer in this order",
    "namespace": "rewards",
    "key": "total_points_earned",
    "type": "number_integer",
    "ownerType": "ORDER"
  },	
  {
    "name": "Points Multiplier",
    "description": "The multiplier applied to the points earned when the customer purchases this product",
    "namespace": "rewards",
    "key": "points_multiplier",
    "type": "number_decimal",
    "ownerType": "PRODUCT"
  }	
]

The above JSON file defines three example Metafields:

  • Rewards Balancerewards.balance
    • Customer-Level Integer Metafield
  • Total Points Earnedrewards.total_points_earned
    • Order-Level Integer Metafield
  • Points Multiplierrewards.points_multiplier
    • Product-Level Decimal Metafield

In this example, the rewards.balance Customer-Level Integer Metafield would contain the customer’s current reward balance.

The rewards.total_points_earned Order-Level Integer Metafield would contain the total points earned by the customer.

And the rewards.points_multiplier Product-Level Decimal Metafield would contain the multiplier for the customer’s reward points when they purchase that product.