We Build Shopify Apps

Montreal-based Shopify experts cooking some Shopify apps.

Show the gift popup only in the Cart page

By default, once customers deserve a free gift, the popup from our Automatic Discount app will show right away, once rules are met of course. That means it can show in the product page, after an item is added to cart, for example. This happens in store using a drawer aka ajax cart, or when the customer isn't automatically redirect to the cart page after he or she adds an item to cart.

If you prefer to make sure that the gift popup is only displayed in the cart page, simply do these 2 steps.

Step 1: add a "Custom JS function" rule in our app.

Inside the same condition that triggers the discount, click on "add rule" and select "Custom JS Function".

gift popup in cart on shopify

Then, you will define a global function (javascript) to make it pop ONLY on the cart page. See step 2 below.

Step 2: Add this snippet of code in your theme.liquid file:

Define a global javascript function somewhere in your theme.liquid. If this function returns TRUE, the rule will be considered completed, anything else and it will be considered incomplete. See example of a function named _tbn_is_on_cart_page below:

window['_tbn_is_on_cart_page'] = function ({ cart, smart_cart, rule, customer }){
    return window.location.pathname.indexOf("/cart")>=0

Step 3: Test it.

gift popup in cart

Get In Touch

Tabarnapp's mission is to help you get the most of each visit on your Shopify store.

E: support@tabarnapp.com