Skip to main content

How to create conditional banner

By using conditions, you can configure dynamic banner behavior and display it only when specific criteria are met. The banner can also be used on any pages of the site using the widget.

Let's look at an example of adding a banner to the cart page, for example, to offer free shipping to increase the average cart value.

Campaigns dashboard

Conditional banner for cart page

To create a conditional banner, follow these steps.

1. Create placeholder for cart page

Create new Placeholder using these data:

  • General Information tab
    • Internal name: Cross Page / Before Content
    • Display mode: Rotator
  • Position tab
    • Use predefined position: No
    • Position: default/top.container/-/
  • Advanced tab
    • Identifier: before-content
    • Additional CSS: .mst-banner__placeholder-before-content {margin-bottom: 5px; height: 20px;}
note

The banner depends on sales conditions and will be loaded using JavaScript. To avoid layout shifts (CLS) and reduce the banner's impact on page speed, it is recommended to set a fixed height. In our example, we use: height: 20px;.

Save changes.


2. Create banner for cart page

Navigate to the Banner section and create a new banner named Left to Free Shipping. Assign it to the appropriate store view and choose which customer groups can view it.

In the Placeholder field, select Cross Page / Before Content.

In the Conditions section, add two conditions that will check the cart subtotal in real time:

If ALL  of these conditions are TRUE :
Subtotal equals or greater than 30
Subtotal less than 100

With these conditions, the extension will check the cart subtotal when the page is refreshed and display the banner only if both conditions are met.

In the Content section, create the banner content. You can use an image, text, or a combination of both.

example
<div style="background: #f75200; padding: 1rem; color: #fff; text-align: center; border-radius: 2px;">
You have ordered <strong>{{var cartSubtotal|raw }}</strong>, add <strong>{{var freeShippingLeft|raw }}</strong> now for free shipping!
</div>

Please note, the banner includes two (variables)[/configuration/variables/] that display the current cart subtotal:

  1. {{var cartSubtotal|raw}}

and the remaining amount needed for free shipping:

  1. {{var freeShippingLeft|raw}}.

Additionally, you can create a new banner with a condition like Subtotal equals or greater than 30 and content such as:

<div style="background: #f75200; padding: 1rem; color: #fff; text-align: center; border-radius: 2px;">
You have ordered <strong>{{var cartSubtotal|raw}}</strong>. You now qualify for free shipping!
</div>

To let the customer know that they qualify for free shipping.