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 |
| Product url | /products/bicycle-helmet |
| Product title | Bicycle helmet |
| Promotion title | Black Friday Sale |
| Discount code or title | WELCOME10 |
| ISO code of the active currency | CAD |
| Formatted compare at price of the product | $30.00 |
| Compare at price of the product in cents | 3000 |
| Formatted price of the product after the discount is applied | $18.00 |
| Price of the product after the discount is applied in cents | 1800 |
| Formatted price of the product before the discount is applied | $20.00 |
| Price of the product before the discount is applied in cents | 2000 |
| 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 |
| 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>"
}
}
}
}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.