Dynamic pricing schema
If you're new to working with JSON, we recommend that you contact us to integrate with your theme.
Abra uses a JSON schema to configure your Abra blocks. You can change your global schema to integrate better with your theme and create richer online store experiences for buyers.
These customizations will apply to every promotion.
Getting started
Before changing your JSON schema, we recommend that you:
Create a backup of your schema
Validate your changes in a JSON validator
To change your schema, go to the "Settings" page and then select "Edit JSON file". You'll see a default schema in the code editor.
At any point, you can revert to the latest default for your theme by clicking "Revert to default".
The schema uses the outline shown below. You can replace the capitalized placeholders with the values found in the table under the example.
{
"schema": {
"TEMPLATE": {
"BLOCK_ID": {
"type": "BLOCK_TYPE",
"PROPERTY_NAME": "PROPERTY_VALUE"
}
}
}
}
Name | Description |
| all | index | product | product.alternative | collection | collection.alternative | cart |
| The identifier for the block. This can be anything that helps you identify what the block does |
| The type for the block |
| The name of the property you're customizing within the block |
| The value of the property you're customizing within the block |
Example
A promotion using a popup block in the schema.
{
"schema" {
"all" {
"dd1627cb-428e-4b7d-bc05-dd96cc6cb50a": {
"type": "popup",
"persistentState": true,
"states": [
{
"state": "DEFAULT",
"text": "20% APPLIED"
}
]
}
}
}
}
Blocks
Blocks are the pieces nested within the template in your schema. There are 3 types of blocks:
Object block - dynamically access an object and update some HTML
Element block - render elements and customize block content from your promotion
Method block - manipulate different parts of your storefront with these helpers
Product object block
Only applies when the product is eligible for the active promotion.
The product
block allows you to replace a block of HTML with new HTML. You have access to the product context in the new HTML.
Block properties
Name | Description |
| product |
| (optional) The DOM selector for the element wrapping the product. This element must contain an |
| The DOM selector for the element you're changing |
| The HTML template to render after the promotion is activated |
|
|
Liquid variables
Name | Description | Example |
| The active promotion title | WELCOME10 |
| The product url | /products/bicycle-helmet |
| The product title | Bicycle helmet |
| The ISO code of the active currency | CAD |
| The formatted compare at price of the product | $30.00 |
| The compare at price of the product in cents | 3000 |
| The formatted price of the product after the discount is applied | $18.00 |
| The price of the product after the discount is applied in cents | 1800 |
| The formatted price of the product before the discount is applied | $20.00 |
| The price of the product before the discount is applied in cents | 2000 |
| The formatted dollar amount discounted from the product after the discount is applied. It'll use the "compare at" pricing if there's a "compare at" variable | $2.00 |
| The formatted percentage discounted from the product after the discount is applied. It'll use the "compare at" pricing if there's a "compare at" variable | 10% |
Selected variant and selling plan liquid variables
When using the above liquid variables to update the product price, it is recommend to use them in conjunction with selected variant and selling plan liquid variables to show the price of a specified product variant.
Name | Description |
| Use for selected variant prices |
| Use for selected selling plan prices |
| Use for selected selling plan or selected variant prices |
Example: Product template
Change your product detail template .price
element to include the final price and a slashed compare at price.
{
"schema": {
"all": {
"main-product-price": {
"type": "product",
"selector": ".price",
"html": "<div class=\"price\"><div class=\"price--sale\">{{ selected_variant.final_price }}</div><div class=\"price--regular\"><s>{{ selected_variant.compare_at_price }}</s></div></div>"
}
}
}
}
Example: Collection template
Change your collection template product card .price
element to include the final price and a slashed compare at price.
{
"schema": {
"all": {
"collection-product-price": {
"type": "product",
"container": ".product-card",
"selector": ".product-card .price",
"html": "<div class=\"price\"><div class=\"price--sale\">{{ selected_variant.final_price }}</div><div class=\"price--regular\"><s>{{ selected_variant.compare_at_price }}</s></div></div>"
}
}
}
}
Cart object block
Only apply when an item within the cart is eligible for the active promotion.
The cart
block allows you to replace a block of HTML with new HTML. You have access to the cart context in the new HTML.
Block properties
Name | Description |
| cart |
| The DOM selector for the element you're changing |
| The HTML template to render after the promotion is activated |
| (optional) The JavaScript event name. The event must be dispatched on |
Liquid variables
Name | Description | Example |
| The promotion code | WELCOME10 |
| The formatted compare at subtotal price of the cart | $30.00 |
| The ISO code of the active currency | CAD |
| The formatted subtotal price of the cart after the promotion is activated | $18.00 |
| The formatted subtotal price of the cart before the promotion is activated | $20.00 |
| Alias for | $18.00 |
| The formatted dollar amount of all discounts for the promotion. It'll use the "compare at" pricing if the cart block has a | $2.00 |
| The formatted percentage of all discounts for the promotion. It'll use the "compare at" pricing if the cart block has a | 10% |
Example
Update the subtotal of your cart drawer and add the total discount
{
"schema": {
"all": {
"cart-drawer-subtotal": {
"type": "cart",
"selector": "#CartDrawer .cart-drawer__footer .totals__subtotal-value",
"html": "<p class=\"totals__subtotal-value\">{{ final_subtotal_price }} (-{{ total_discount }})</p>"
}
}
}
}
Cart item object block
Only apply when the item is eligible for the active promotion.
The cart-item
block allows you to replace a block of HTML with new HTML. You have access to the cart item context in the new HTML.
Block properties
Name | Description |
| cart-item |
| The DOM selector for the cart items. This selector must select exactly the same number of items in cart. |
| The DOM selector for the element you're changing |
| The HTML template to render after the promotion is activated |
| (optional) The JavaScript event name. The event must be dispatched on |
Liquid variables
Name | Description | Example |
| The promotion code | WELCOME10 |
| The formatted compare at line price before the promotion is applied | $40.00 |
| The formatted compare at price before the promotion is applied | $20.00 |
| The ISO code of the active currency | CAD |
| The formatted line price after the promotion is applied | $36.00 |
| The formatted price after the promotion is applied | $18.00 |
| The formatted line price before the promotion is applied | $40.00 |
| The formatted price before the promotion is applied | $20.00 |
| The cart item quantity | 2 |
| The formatted price discounted from the cart item with the promotion. It'll use the "compare at" pricing if there's a "compare at" variable | $4.00 |
| The formatted price discounted from the cart item including quantity with the promotion. It'll use the "compare at" pricing if there's a "compare at" variable | $8.00 |
| The product url | /products/bicycle-helmet |
Example
Change your cart item to show the final price and slash the original price
{
"schema": {
"cart": {
"cart-item-pricing": {
"type": "cart-item",
"item": "#cart .cart-item",
"selector": "div.product-option",
"html": "<div class=\"product-option\">{{ final_price }} <div class=\"cart-item--regular-price\">{{ original_price }}</div></div>"
}
}
}
}
Announcement bar element block
The announcement-bar
block allows you to show and update the content of your announcement bar.
Block properties
Name | Description |
| announcement-bar |
| Whether the default state is persistent or not |
| The announcement bar's content by state |
| (optional) The JavaScript event name. The event must be dispatched on |
Block state properties
A block state allows you to show different content based on the state of the promotion and discount.
Name | Description |
| (optional) discount | gift | percentage |
| The name of the state: DEFAULT| PROGRESS_ZERO | PROGRESS_ONE | PROGRESS_OTHER | SUCCESS |
| The announcement bar's text content |
Liquid variables
Name | Description | Example |
| The promotion code | WELCOME10 |
| The ISO code of the active currency | CAD |
| The value of a discount used in the promotion | 10% |
Example
Showing an announcement bar with a gift icon and some text.
{
"schema": {
"all": {
"gift-announcement-bar": {
"type": "announcement-bar",
"persistentState": true,
"states": [
{
"icon": "gift",
"state": "DEFAULT",
"text": "FREE GIFT ON ORDERS OVER $50"
}
]
}
}
}
}
Banner element block
The banner
block allows you to show and update the content of your banner.
Block properties
Name | Description |
| banner |
| The identifier for the banner. This must match the identifier in Shopify's Theme Editor. |
| Whether the default state is persistent or not. |
| The banner's content by state. |
| (optional) The JavaScript event name. The event must be dispatched on |
Block state properties
A block state allows you to show different content based on the state of the promotion and discount.
Name | Description |
| (optional) discount | gift | percentage |
| The name of the state: DEFAULT| PROGRESS_ZERO | PROGRESS_ONE | PROGRESS_OTHER | SUCCESS |
| The banner's text content. |
Liquid variables
Name | Description | Example |
| The promotion code | WELCOME10 |
| The ISO code of the active currency | CAD |
| The value of a discount used in the promotion | 10% |
| (Gift with purchase banner) Minimum spend amount or quantity of items that need to be added to cart to get the free gift | $20.00 |
| (Gift with purchase banner) Amount or quantity remaining to be added to cart to get the free gift | $15.00 |
Example
Showing a banner with a discount icon and some text.
{
"schema": {
"all": {
"gift-banner": {
"type": "banner",
"name": "default",
"persistentState": true,
"states": [
{
"icon": "discount",
"state": "DEFAULT",
"text": "FREE GIFT ON ORDERS OVER $50"
}
]
}
}
}
}
Popup element block
The popup
block allows you to show and update the content of your popup.
Block properties
Name | Description |
| popup |
| Whether the default state is persistent or not. |
| The popup's content by state. |
| (optional) The JavaScript event name. The event must be dispatched on |
Block state properties
A block state allows you to show different content based on the state of the promotion and discount.
Name | Description |
| (optional) discount | gift | percentage |
| The name of the state: DEFAULT| PROGRESS_ZERO | PROGRESS_ONE | PROGRESS_OTHER | SUCCESS |
| The popup's text content |
Liquid variables
Name | Description | Example |
| The promotion code | WELCOME10 |
| The ISO code of the active currency | CAD |
| The value of a discount used in the promotion | 10% |
Example
Showing a popup with some text
{
"schema": {
"all": {
"custom-popup": {
"type": "popup",
"persistentState": true,
"states": [
{
"state": "DEFAULT",
"text": "{{ code }} APPLIED"
}
]
}
}
}
}
Hide method block
The hide
block allows you to hide an element when the promotion is active.
Block properties
Name | Description |
| hide |
| The DOM selector for the target element |
Example
Hiding your footer element.
{
"schema": {
"all": {
"hide-footer": {
"type": "hide",
"selector": ".footer"
}
}
}
}
Add class method block
The add-class
block allows you to add a class to an element when the promotion is active.
Block properties
Name | Description |
| add-class |
| The DOM selector for the target element |
| The CSS class - do not include a |
Example
Adding a vip-customer
class to the body element.
{
"schema": {
"all": {
"vip-customer-style": {
"type": "add-class",
"selector": "body",
"value": "vip-customer"
}
}
}
}
Remove class method block
The remove-class
block allows you to remove a class to an element when the promotion is active.
Block properties
Name | Description |
| remove-class |
| The DOM selector for the target element |
| The CSS class - do not include a |
Example
Removing a hidden
class from a navigation item.
{
"schema": {
"all": {
"show-special-nav-item": {
"type": "remove-class",
"selector": ".nav .nav-item--vip",
"value": "hidden"
}
}
}
}
Theme examples
See our GitHub repository for more examples.