Subscription Product Upsell Incentive
An extra first-order discount for adding a product to the subscription.


This block reads live subscription data, so it only runs inside a real customer portal. The animation shows what subscribers see.
What it does
A limited-time offer card in the customer portal: one product, its first-order price and a live countdown. One click adds the product to the subscription as a recurring item and applies a discount code, so the subscriber gets an extra discount on their first order with it. The card only shows on active subscriptions that don't already include the product, and it hides itself when the countdown ends.
Why it exists
For subscription brands that want existing subscribers to add products as recurring items, not one-off add-ons. A first-order discount with a deadline is an easy yes, and every product added this way keeps shipping on future orders.
The code
Paste it as-is, or download subscription-product-upsell-incentive.html<!--
Skio portal custom extension - "Add to subscription, get an extra 10% off" upsell
Product: CONFIG.skioVariantId (the Skio ProductVariant id of the product to offer)
+ CONFIG.product (its title, image and price)
Discount: CONFIG.discountCode (10% off the first order only - set the code's recurring
limit to 1 order in Shopify, or it may keep applying)
Offer ends: CONFIG.offerEndsAt (countdown; the block hides itself after this)
Install (help.skio.com "Understanding custom extensions"):
Skio Dashboard > Storefront > Customer Portal > Branding tab > Layout >
Add custom extension > Add extension. Name it, paste this whole file into the
Code editor, Save, click + to add it to the layout, then reorder via
Back to customization. Some JS may not run in Preview mode - test on the live portal.
Uses the portal's injected helpers: fetchSkioAPI(query, variables) (runs as the
logged-in customer - no API token in this file) and
getNextActiveBillingSubscriptionId() / .
-->
<div class="skio-upsell" data-skio-upsell hidden>
<div class="skio-upsell__inner">
<div class="skio-upsell__media">
<img class="skio-upsell__img" alt="" loading="lazy" />
<span class="skio-upsell__badge">EXTRA 10% OFF</span>
</div>
<div class="skio-upsell__body">
<p class="skio-upsell__eyebrow">Limited-time offer</p>
<div class="skio-upsell__timer" role="timer" aria-live="off">
<span class="skio-upsell__timer-label">Offer ends in</span>
<span class="skio-upsell__units">
<span class="skio-upsell__unit"><b data-u="d">00</b><small>days</small></span>
<span class="skio-upsell__unit"><b data-u="h">00</b><small>hrs</small></span>
<span class="skio-upsell__unit"><b data-u="m">00</b><small>mins</small></span>
<span class="skio-upsell__unit"><b data-u="s">00</b><small>secs</small></span>
</span>
</div>
<h3 class="skio-upsell__title"></h3>
<p class="skio-upsell__copy">Add this to your subscription and get an <strong>extra 10% off your first order</strong>.</p>
<p class="skio-upsell__price">
<span class="skio-upsell__price-now"></span>
<span class="skio-upsell__price-note">first order, then <span class="skio-upsell__price-was"></span></span>
</p>
<button type="button" class="skio-upsell__btn">Add to subscription</button>
<p class="skio-upsell__msg" role="status" aria-live="polite"></p>
</div>
</div>
</div>
<style>
.skio-upsell { container-type: inline-size !important; margin: 16px 0 !important; font-family: inherit !important; }
.skio-upsell[hidden] { display: none !important; }
.skio-upsell__inner {
display: flex !important; gap: clamp(12px, 4cqw, 20px) !important; align-items: center !important;
padding: clamp(12px, 4cqw, 20px) !important; border: 1px solid #e5e7eb !important;
border-radius: 12px !important; background: #ffffff !important; color: #111827 !important;
}
.skio-upsell__media { position: relative !important; flex: none !important; width: clamp(88px, 26cqw, 140px) !important; }
.skio-upsell__img {
display: block !important; width: 100% !important; aspect-ratio: 1 / 1 !important;
object-fit: cover !important; border-radius: 8px !important; background: #f3f4f6 !important;
}
.skio-upsell__badge {
position: absolute !important; top: 6px !important; left: 6px !important;
background: #b91c1c !important; color: #ffffff !important; font-size: 11px !important;
font-weight: 700 !important; letter-spacing: .04em !important; padding: 3px 7px !important; border-radius: 999px !important;
}
.skio-upsell__body { flex: 1 1 auto !important; min-width: 0 !important; }
.skio-upsell__eyebrow {
margin: 0 0 4px !important; font-size: 12px !important; font-weight: 600 !important;
text-transform: uppercase !important; letter-spacing: .06em !important; color: #b91c1c !important;
}
.skio-upsell__timer {
display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 6px 10px !important;
margin: 0 0 10px !important; font-size: 12px !important; color: #374151 !important;
}
.skio-upsell__timer-label { font-weight: 600 !important; }
.skio-upsell__units { display: inline-flex !important; gap: 4px !important; }
.skio-upsell__unit {
display: inline-flex !important; flex-direction: column !important; align-items: center !important;
min-width: 40px !important; padding: 4px 6px !important; border-radius: 6px !important;
background: #fef2f2 !important; color: #991b1b !important; line-height: 1.1 !important;
}
.skio-upsell__unit b { font-size: 16px !important; font-weight: 700 !important; font-variant-numeric: tabular-nums !important; }
.skio-upsell__unit small { font-size: 10px !important; text-transform: uppercase !important; letter-spacing: .04em !important; }
.skio-upsell__title { margin: 0 0 4px !important; font-size: clamp(15px, 4.2cqw, 18px) !important; font-weight: 700 !important; line-height: 1.3 !important; color: #111827 !important; }
.skio-upsell__copy { margin: 0 0 8px !important; font-size: 14px !important; line-height: 1.4 !important; color: #374151 !important; }
.skio-upsell__price { margin: 0 0 12px !important; display: flex !important; gap: 8px !important; align-items: baseline !important; }
.skio-upsell__price:has(.skio-upsell__price-now:empty) { display: none !important; }
.skio-upsell__price-now { font-size: 16px !important; font-weight: 700 !important; color: #111827 !important; }
.skio-upsell__price-note { font-size: 13px !important; color: #4b5563 !important; }
.skio-upsell__price-was { font-weight: 600 !important; color: #4b5563 !important; }
.skio-upsell__btn {
display: inline-flex !important; align-items: center !important; justify-content: center !important;
min-height: 44px !important; padding: 0 20px !important; border: 0 !important; border-radius: 8px !important;
background: #111827 !important; color: #ffffff !important; font: inherit !important;
font-size: 15px !important; font-weight: 600 !important; cursor: pointer !important; transition: opacity .15s ease !important;
}
.skio-upsell__btn:hover { opacity: .88 !important; }
.skio-upsell__btn:focus-visible { outline: 3px solid #2563eb !important; outline-offset: 2px !important; }
.skio-upsell__btn[disabled] { opacity: .6 !important; cursor: default !important; }
.skio-upsell__msg { margin: 8px 0 0 !important; font-size: 13px !important; line-height: 1.4 !important; color: #374151 !important; }
.skio-upsell__msg:empty { display: none !important; }
.skio-upsell__msg--ok { color: #166534 !important; }
.skio-upsell__msg--err { color: #b91c1c !important; }
@container (max-width: 360px) {
.skio-upsell__inner { flex-direction: column !important; align-items: stretch !important; }
.skio-upsell__media { width: 100% !important; max-width: 220px !important; margin: 0 auto !important; }
.skio-upsell__btn { width: 100% !important; }
}
@media (prefers-reduced-motion: reduce) { .skio-upsell__btn { transition: none !important; } }
</style>
<script>
(function () {
var CONFIG = {
skioVariantId: '', // <-- Skio ProductVariant id of the product to offer
discountCode: '', // <-- a Shopify discount code from your store, e.g. 'EXTRA10'
discountPercent: 10,
// Countdown target. End of 28 Nov 2026, US Eastern. The offer hides itself after this.
offerEndsAt: '2026-11-28T23:59:59-05:00',
addAsOneTime: false, // false = recurring line; true = next order only
product: {
title: 'Your Product',
image: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'%3E%3Crect width='240' height='240' fill='%23F3F4F6'/%3E%3Crect x='100' y='62' width='40' height='22' rx='6' fill='%23111827'/%3E%3Crect x='82' y='82' width='76' height='132' rx='22' fill='%23CBD5E1'/%3E%3Crect x='96' y='122' width='48' height='40' rx='7' fill='%23FFFFFF'/%3E%3C/svg%3E", // sample image: swap for your product's image URL
price: 10.00,
currency: 'USD'
},
reloadAfterMs: 2500
};
var root = document.querySelector('[data-skio-upsell]');
if (!root || root.__init) return;
root.__init = true;
var $ = function (s) { return root.querySelector(s); };
var btn = $('.skio-upsell__btn'), msg = $('.skio-upsell__msg');
// ---- Portal helpers -------------------------------------------------------
function skioFetch() {
if (typeof fetchSkioAPI === 'function') return fetchSkioAPI; // injected into extension scope
if (typeof window.fetchSkioAPI === 'function') return window.fetchSkioAPI;
return null;
}
// Normalise fetchSkioAPI's result to `data`, throwing on GraphQL errors.
function gql(query, variables) {
var f = skioFetch();
if (!f) return Promise.reject(new Error('fetchSkioAPI not available'));
return Promise.resolve(f(query, variables)).then(function (res) {
if (res && res.errors && res.errors.length) {
throw new Error(res.errors.map(function (e) { return e.message; }).join('; '));
}
return res && res.data ? res.data : res;
});
}
function getSubscriptionId() {
// 1. A specific subscription page in the portal (SPA route)
var hit = location.href.match(/subscriptions\/([0-9a-f-]{36})/i);
if (hit) return hit[1];
// 2. Portal helper / template variable for the next subscription to bill
try {
if (typeof getNextActiveBillingSubscriptionId === 'function') {
var id = getNextActiveBillingSubscriptionId();
if (id) return id;
}
} catch (e) {}
var tpl = '';
return tpl.indexOf('{{') === -1 && tpl ? tpl : null;
}
// ---- UI -------------------------------------------------------------------
function money(n) {
try { return new Intl.NumberFormat(undefined, { style: 'currency', currency: CONFIG.product.currency }).format(n); }
catch (e) { return n.toFixed(2); }
}
function setMsg(text, kind) {
msg.textContent = text || '';
msg.className = 'skio-upsell__msg' + (kind ? ' skio-upsell__msg--' + kind : '');
}
(function renderProduct() {
var p = CONFIG.product;
$('.skio-upsell__title').textContent = p.title;
var img = $('.skio-upsell__img');
if (p.image) { img.src = p.image; img.alt = p.title; }
if (typeof p.price === 'number') {
$('.skio-upsell__price-now').textContent = money(Math.round(p.price * (100 - CONFIG.discountPercent)) / 100);
$('.skio-upsell__price-was').textContent = money(p.price);
}
})();
// ---- Countdown ------------------------------------------------------------
var endsAt = new Date(CONFIG.offerEndsAt).getTime();
function expired() { return !(endsAt > Date.now()); }
var timerEl = $('.skio-upsell__timer');
try {
timerEl.setAttribute('aria-label', 'Offer ends ' + new Date(endsAt).toLocaleDateString(undefined, { month: 'long', day: 'numeric', year: 'numeric' }));
} catch (e) {}
function pad(n) { return (n < 10 ? '0' : '') + n; }
function tick() {
var left = Math.max(0, Math.floor((endsAt - Date.now()) / 1000));
$('[data-u="d"]').textContent = pad(Math.floor(left / 86400));
$('[data-u="h"]').textContent = pad(Math.floor(left % 86400 / 3600));
$('[data-u="m"]').textContent = pad(Math.floor(left % 3600 / 60));
$('[data-u="s"]').textContent = pad(left % 60);
if (left === 0 && !root.__added) { root.hidden = true; }
}
tick();
var timer = setInterval(function () { tick(); if (expired()) clearInterval(timer); }, 1000);
// ---- Eligibility: active subscription that doesn't already have the item ----
var subscriptionId = null;
function doneKey(id) { return 'skio-upsell:' + CONFIG.skioVariantId + ':' + id; }
function isDone(id) { try { return !!localStorage.getItem(doneKey(id)); } catch (e) { return false; } }
function checkEligible(id) {
return gql(
'query UpsellCheck($id: uuid!) { SubscriptionByPk(id: $id) { id status SubscriptionLines(where: { removedAt: { _is_null: true } }) { productVariantId } } }',
{ id: id }
).then(function (d) {
var sub = d && d.SubscriptionByPk;
if (!sub) return false;
if (sub.status && sub.status !== 'ACTIVE') return false;
return !(sub.SubscriptionLines || []).some(function (l) { return l.productVariantId === CONFIG.skioVariantId; });
}).catch(function (e) {
console.warn('[skio-upsell] eligibility check failed, showing offer anyway', e);
return true;
});
}
function sync() {
var id = getSubscriptionId();
if (id === subscriptionId) return;
subscriptionId = id;
root.hidden = true;
btn.disabled = false;
btn.textContent = 'Add to subscription';
setMsg('');
if (!id || expired() || isDone(id) || !skioFetch()) return;
// Ships unconfigured: the offer stays hidden until skioVariantId and discountCode are set.
if (!CONFIG.skioVariantId || !CONFIG.discountCode) { console.warn('[skio-upsell] set CONFIG.skioVariantId and CONFIG.discountCode to show this offer'); return; }
checkEligible(id).then(function (ok) { if (ok && subscriptionId === id && !expired()) root.hidden = false; });
}
sync();
window.addEventListener('popstate', sync);
setInterval(sync, 1000); // cheap check; catches in-portal navigation between subscriptions
// ---- Add + discount -------------------------------------------------------
btn.addEventListener('click', function () {
var id = subscriptionId;
if (!id) return;
if (expired()) { setMsg('Sorry, this offer has ended.', 'err'); btn.disabled = true; return; }
btn.disabled = true;
btn.textContent = 'Adding\u2026';
setMsg('');
gql(
'mutation addSubscriptionLine($input: AddSubscriptionLineInput!) { addSubscriptionLine(input: $input) { ok } }',
{ input: {
subscriptionId: id,
variantId: CONFIG.skioVariantId,
quantity: 1,
upsell: CONFIG.addAsOneTime,
customAttributes: [{ key: '_source', value: 'portal-upsell' }]
} }
).then(function (d) {
if (!d || !d.addSubscriptionLine || !d.addSubscriptionLine.ok) throw new Error('addSubscriptionLine not ok');
root.__added = true; // keep the confirmation visible even if the timer hits zero
try { localStorage.setItem(doneKey(id), '1'); } catch (e) {}
btn.textContent = 'Added \u2713';
return gql(
'mutation applyDiscountCode($input: ApplyDiscountCodeInput!) { applyDiscountCode(input: $input) { ok message } }',
{ input: { subscriptionId: id, code: CONFIG.discountCode } }
).then(function (r) {
var res = r && r.applyDiscountCode;
if (!res || !res.ok) throw new Error((res && res.message) || 'applyDiscountCode not ok');
setMsg('Added to your subscription with an extra 10% off your first order. Updating your order\u2026', 'ok');
}).catch(function (e) {
console.warn('[skio-upsell] discount failed', e);
setMsg('Added to your subscription, but we couldn\u2019t apply your extra 10% first-order discount automatically. Please contact support and we\u2019ll sort it.', 'err');
}).then(function () {
// No documented in-portal refresh hook, so reload to show the new line + discount.
if (CONFIG.reloadAfterMs >= 0) setTimeout(function () { location.reload(); }, CONFIG.reloadAfterMs);
});
}).catch(function (e) {
console.warn('[skio-upsell] add failed', e);
btn.disabled = false;
btn.textContent = 'Add to subscription';
setMsg('Something went wrong adding this item. Please try again.', 'err');
});
});
})();
</script>
How to install
- Copy the code above, or download the .html file.
- Go to
Storefront→Customization→Blocks, then clickAdd block→Custom block. - Name it and paste the whole file into the code editor.
- Swap anything the file asks you to, like
[BRAND], product names or Quick Action IDs. The AI prompt below can walk you through it. - Save, drag it where you want it in the layout, then
Publish. Check it on a test subscription’s magic link with?forcePreview=true, since some scripts don’t run in Preview.
It ships unconfigured, so the card stays hidden until you fill in the CONFIG block: skioVariantId (the Skio ProductVariant id of the product to offer), discountCode, and the product's title, image URL and price (the image is a sample). Create one Shopify product discount code per offered product; if it should only cover the first order, set that limit in Shopify. Set offerEndsAt to your deal's end date: the card hides itself after it (the sample date is 28 Nov 2026). The 10% in the badge, copy and messages is written out, so change it there too if you change discountPercent. After a successful add the page reloads (reloadAfterMs) and the new line carries a _source: portal-upsell attribute. The discount code is applied client-side, so set usage and expiry limits on it in Shopify. It uses Skio's portal API (fetchSkioAPI), so it needs a Skio customer portal.
Customize it with AI
Paste this prompt into Claude Code or Codex. It asks for the code and your brand and product details, then writes a version for your store.
I want to add a custom extension from customizeyourportal.xyz to my subscription customer portal. Walk me through customizing it for my brand, then write the finished code. EXTENSION Name: Subscription Product Upsell Incentive (No. 19) Page: /blocks/subscription-product-upsell-incentive What it does: A limited-time offer card in the customer portal: one product, its first-order price and a live countdown. One click adds the product to the subscription as a recurring item and applies a discount code, so the subscriber gets an extra discount on their first order with it. The card only shows on active subscriptions that don't already include the product, and it hides itself when the countdown ends. My portal app: Skio WHAT THE BUILDER SAYS TO CUSTOMIZE It ships unconfigured, so the card stays hidden until you fill in the CONFIG block: skioVariantId (the Skio ProductVariant id of the product to offer), discountCode, and the product's title, image URL and price (the image is a sample). Create one Shopify product discount code per offered product; if it should only cover the first order, set that limit in Shopify. Set offerEndsAt to your deal's end date: the card hides itself after it (the sample date is 28 Nov 2026). The 10% in the badge, copy and messages is written out, so change it there too if you change discountPercent. After a successful add the page reloads (reloadAfterMs) and the new line carries a _source: portal-upsell attribute. The discount code is applied client-side, so set usage and expiry limits on it in Shopify. It uses Skio's portal API (fetchSkioAPI), so it needs a Skio customer portal. HOW TO WORK 1. Ask me to paste the full code (the "Copy code" button on the page) or to give you the path to the downloaded subscription-product-upsell-incentive.html. Wait until you have it. 2. Read the whole file. List every value that is specific to the original brand or needs my input: brand name and [PLACEHOLDERS], product and variant names or IDs, prices, discount codes and reward amounts, Quick Action IDs or tokens, store domains and API endpoints, colors, fonts, logos and images, and any copy that names the original brand, products or offers. Include everything in the builder's notes above. 3. Ask me for those values in one numbered list, with the current value next to each, so I can answer or say "keep". If you can open web pages, offer to pull my brand colors, fonts, logo and product names from my store's URL. 4. Don't invent stats, reviews, IDs, prices or claims. If I don't have a value, leave a clearly marked TODO in the code and tell me. 5. Write the customized version as subscription-product-upsell-incentive-<my-brand>.html. Change only what my brand needs. Keep the logic, behavior and structure the same, and keep it one self-contained file (HTML, <style> and <script>). 6. Finish with a short list of what you changed, any TODOs left, and these install steps for Skio: 1. Go to `Storefront` → `Customization` → `Blocks`, then click `Add block` → `Custom block`. 2. Name it and paste the whole file into the code editor. 3. Save, drag it where you want it in the layout, then `Publish`. Check it on a test subscription’s magic link with `?forcePreview=true`, since some scripts don’t run in Preview.
Blocks are shared as-is by the people who built them. Read the code before you add it to your portal, and test it with a test subscriber first.