How do I add an entry counter to the cart drawer?
Quick answer
Shopify doesn't support app blocks in cart drawers, so the Giveaway Ninja counter is a Liquid snippet. Download it, upload it to your theme's Snippets folder, then add one render line with your Giveaway ID to your cart drawer file, usually sections/cart-drawer.liquid. The counter updates as shoppers add or remove items.
This snippet shows order entries right in your cart drawer, giving customers real-time feedback as they shop.
Why is coding needed? Shopify doesn't currently offer a way to add app blocks to a cart drawer. There are also many third-party cart drawer apps, and the setup can differ slightly depending on your theme or cart app. You'll need basic coding skills to set this up.
Important notes
- This snippet needs the Giveaway Ninja app to be installed and active on your store
- We strongly recommend backing up your theme before making changes
- It's tested with Shopify's default cart drawer. Third-party cart apps may need adjustments
- Test thoroughly in preview mode before publishing changes to your live theme
Download the snippet file
Download the ready-to-use snippet file:
Download giveaway-cart-drawer-entries.zip
Step 1: upload the snippet to your theme
First, download and extract the zip file using the link above.
- Download the zip file and extract it to get the
giveaway-cart-drawer-entries.liquidfile - Go to Online Store > Themes > Actions > Edit Code
- In the left sidebar, find the Snippets folder
- Right-click the Snippets folder
- Select Upload file from the menu
- Choose the extracted
giveaway-cart-drawer-entries.liquidfile - The file uploads to your theme automatically
That's it! The snippet is ready to use in your theme.
Step 2: add the snippet to the cart drawer
-
Find your cart drawer file. Common locations:
sections/cart-drawer.liquid(Dawn and most modern themes)snippets/cart-drawer.liquid(older themes)sections/main-cart-footer.liquid(some themes)
- Add this line where you want the entry counter to appear (usually after the cart items, before the checkout button):
{% render 'giveaway-cart-drawer-entries', giveaway_id: 'YOUR_GIVEAWAY_ID' %}Important: replace YOUR_GIVEAWAY_ID with your actual Giveaway ID from the Giveaway Ninja dashboard.
Step 3: get your Giveaway ID
- Log in to your Giveaway Ninja dashboard
- Open your active giveaway in the Campaign editor
- Click GIVEAWAY and copy the Giveaway ID from the Giveaway Details section
- Paste it into the render tag above
Example placement (Dawn theme)
In sections/cart-drawer.liquid, add the snippet like this:
<div class="cart-drawer__footer">
{% render 'giveaway-cart-drawer-entries', giveaway_id: 'abc123xyz' %} <!-- ADD THIS -->
<div class="cart-drawer__footer-content">
<!-- existing checkout button code -->
</div>
</div>Customization options
The snippet supports these parameters to customize its behavior and appearance.
Available parameters:
giveaway_id: required. Your Giveaway Ninja Giveaway IDentries_label: text shown when earning entries. Use the{entries}placeholder. Default: "You're earning {entries} giveaway entries!"no_entries_label: text shown when no entries are earned. Default: "Add items to earn giveaway entries"min_order_not_reached_label: text shown when the minimum order value isn't met. Use the{value}placeholder. Default: "No entries, minimum order required: ${value}"loading_label: text shown while calculating. Default: "Calculating entries..."icon_emoji: icon or emoji to display. Default: "🎟️"hide_when_expired: hide the badge if the giveaway has expired. Default: falseshow_multiplier: show the time booster multiplier badge. Default: true
Example: basic customization
{% render 'giveaway-cart-drawer-entries',
giveaway_id: 'YOUR_ID',
entries_label: 'You have {entries} tickets!',
no_entries_label: 'Add items to get tickets'
%}Example: full customization with all options
{% render 'giveaway-cart-drawer-entries',
giveaway_id: 'YOUR_ID',
entries_label: '🎉 Earning {entries} entries with this order!',
no_entries_label: 'Add qualifying items to earn entries',
min_order_not_reached_label: 'Minimum purchase of ${value} required for entries',
loading_label: 'Loading...',
icon_emoji: '🎫',
hide_when_expired: true,
show_multiplier: true
%}Example: hide when the giveaway ends
{% render 'giveaway-cart-drawer-entries',
giveaway_id: 'YOUR_ID',
hide_when_expired: true
%}Example: custom minimum order message
{% render 'giveaway-cart-drawer-entries',
giveaway_id: 'YOUR_ID',
min_order_not_reached_label: 'Spend ${value} or more to earn giveaway entries!'
%}Change colors: open the snippet file and edit the CSS in the <style> section:
.giveaway-cart-drawer-wrapper {
background: linear-gradient(135deg, #YOUR_COLOR 0%, #YOUR_COLOR 100%);
border-color: #YOUR_COLOR; /* Border color */
}
.giveaway-cart-drawer-text {
color: #YOUR_COLOR; /* Text color */
}
.giveaway-multiplier-value {
color: #YOUR_COLOR; /* Multiplier badge color */
}Testing checklist
Before publishing to your live theme:
- Add an item to the cart and check the entry counter appears
- Change the item quantity. The counter should update automatically
- Remove an item. The counter should go down
- If you use a minimum order value: check the badge shows the minimum order message when the cart total is below the threshold
- If you use a minimum order value: add items until the minimum is reached and check the badge switches to showing entries
- Test time multipliers if configured. The multiplier badge should appear
- Test on a mobile device. It should display correctly
- Check the browser console for errors (press F12)
- Check the entry count matches your giveaway rules
- Test the cart drawer opening after adding a product from the product page
Troubleshooting
Why doesn't the cart drawer counter appear?
- Check the snippet was saved correctly
- Check you added the render tag to your cart drawer file
- Make sure you replaced
YOUR_GIVEAWAY_IDwith your actual ID - Make sure the Giveaway Ninja app is installed and active
Why is the counter stuck on "Calculating entries..."?
- This happens when the Giveaway Ninja main script loads after the cart drawer opens
- The latest version (in the download) handles this automatically by retrying when the cart drawer opens
- Make sure you're using the latest version of the snippet
- Check the browser console for the "[GiveawayNinja Cart Drawer] Access token now available" message
Why doesn't the counter update when the cart changes?
- Clear your browser cache
- Check the browser console for JavaScript errors
- The snippet listens for several cart events, so most themes are supported
- Some themes may need extra configuration. Contact support
Why does the counter show the wrong number of entries?
- Check your Giveaway ID is correct
- Check your giveaway rules in the dashboard
- The counter uses your actual giveaway settings (multipliers, minimum order and so on)
- If you use a minimum order value, make sure it's configured correctly in your giveaway settings
Why isn't the minimum order message showing?
- Make sure "Enable Minimum Order Value" is checked in your giveaway settings
- The minimum order value must be greater than 0
- The counter uses the "calculation base" (order subtotal or total, depending on your settings)
- Check the browser console for the API response to see the minimum order values
Cleanup after the giveaway
Once your giveaway ends, remove the entry counter:
- Go back to your cart drawer file
- Remove the
{% render 'giveaway-cart-drawer-entries'... %}line - (Optional) Delete the snippet from the Snippets folder
- Save and publish
Complete snippet code reference
The complete snippet file (about 630 lines, around 16 KB) includes all the functionality in this guide:
- Real-time entry calculation using the Giveaway Ninja API
- Automatic cart change detection
- Support for minimum order requirements
- Time multiplier display
- Error handling that won't break your cart drawer
- Dynamic cart drawer support
- Fully customizable labels and styling
Download the complete snippet code
No cart drawer? Use the giveaway entry counter for the Shopify cart page instead.
People also ask
Does it work with third-party cart drawer apps?
It's tested with Shopify's default cart drawer. Third-party cart apps may need small changes. If that's not an option, add a giveaway entry counter to the Shopify cart page.
Why is the counter stuck on "Calculating entries..."?
The main script loaded after the drawer opened. Download the latest snippet, which retries automatically, and check the console for other errors. See why a JavaScript error can stop your giveaway loading.
Can the counter show a minimum order message?
Yes. Turn on Enable Minimum Order Value in your giveaway, then set min_order_not_reached_label in the render tag. See how the minimum order value works.
What should I do when the giveaway ends?
Remove the render line from your cart drawer file, or set hide_when_expired: true. Then draw your giveaway winners.
Still stuck?
Our support team is available 24/7 and always replies. Send us a message and we'll help you sort it out.