Membership Cart Drawer Upsell with Dynamically Calculated Cashback: Implementation Guide
File Structure
File
Purpose
Step 1: Create the Snippet
{%- comment -%}
Adjust this percentage to reflect your actual cashback offer.
{%- endcomment -%}
{% assign cashback_percentage = 20 %}
{% assign cashback_amount = cart.total_price | times: cashback_percentage | divided_by: 100 %}
<div class="drawer-membership-upsell">
<h3 class="drawer-upsell-heading">Become a Member</h3>
<p class="drawer-upsell-subheading">Join now to unlock your benefits</p>
<ul class="drawer-benefits">
{%- comment -%}
Customize the list of membership benefits below to reflect your actual offering.
These items are placeholder examples — replace them with your own benefits.
{%- endcomment -%}
<li>
<strong>{{ cashback_percentage }}% Cashback</strong>
{% if cart.item_count > 0 %}
<span class="drawer-cashback-amount">
({{ cashback_amount | money }} on today's order!)
</span>
{% endif %}
</li>
<li>Free Shipping</li>
<li>Exclusive Product Access</li>
<li>Member-Only Discounts</li>
<li>$10 Birthday Credit</li>
<li>Priority Support</li>
</ul>
<button
class="drawer-upsell-button"
data-membership-variant="REPLACE_WITH_VARIANT_ID" <!-- Replace with your membership product's variant ID -->
data-membership-selling-plan="REPLACE_WITH_SELLING_PLAN_ID"> <!-- Replace with your selling plan ID -->
Join Now for $10 Annually! <!-- Replace with your price & CTA -->
</button>
</div>
{%- comment -%}
Ensure this script is included so the JS functionality is loaded when the snippet renders.
{%- endcomment -%}
<script type="module" src="{{ 'membership-upsell.js' | asset_url }}"></script>
Step 2: Create the JavaScript File
Step 3: Add the Snippet to the Cart Drawer
Step 4: Style with CSS

Last updated
Was this helpful?
