Account & Billing
Can I switch between pricing plans? (on Subbly)
Setting up Stripe
Setting up PayPal
Setting up Braintree (or PayPal through Braintree)
Setting up Auth.net
Setting up Apple Pay & Google Pay?
Setting up a specific billing time
How to connect a domain to your website?
Handling invoices
How do I set the currency for my store?
Country of trade setting
Timezone setup
Taxes
How do I export taxes on Subbly?
Can I grant access to more users to my account? (Teams app)
Can I manage the email notifications I receive?
How do I put my Subbly store and website offline?
How do I cancel my trial?
How do I cancel my account?
Preventing Customer's Cancellations
Checkout & Payments
Setting up the checkouts and customer portal on custom domain
Testing checkouts and customer portal
Setting up your branding
How do I remove Subbly branding from the checkout?
How to translate the checkout and the customer portal?
How do I add Terms & Conditions to the checkout?
Do my customers need to register to make a purchase?
Checkout & cart widget behavior
Setting up cart widget
How to enable 3DS confirmation step at checkout?
Setting up multicurrency
How to change the position of the currency symbol at the checkout?
Why are my checkouts not working?
Updating cart widget based on webpage actions
Altering cart widget functions by embedding Subbly Javascript
Website Builder
AI Website Builder
Getting Started
Welcome to Subbly's agentic builder!
Pricing, Costs, and Credits Explained
A Quick Tour of the Agentic Builder Interface
Core Features
How to Set up a Custom Domain
How to Revert to a Previous Version
Understanding the Different AI Models Available
Troubleshooting
Contacting Support
When to Start a New Chat
My Agent isn't Behaving as Expected: Common Issues and Fixes
Getting started with the AI Website Builder
AI Website Builder: General guidelines and best practices
Legacy Builder
Dashboard apps
Articles App
Logo maker app
Designer Tools: Overview
Fonts App
Pages App
Designer Tools: Layout
Designer Tools: Typography
SEO App
Domain App
Languages App
Designer Tools: UI Kit
Templates App
Media App
Pop-Ups App
Getting started with Dashboard and Apps
Site Settings App
Edit mode
Troubleshooting ''there is an update'' error
How to change the title for your website?
How to add a cookie consent banner to your Subbly site?
How to create a banner on the website builder?
How to submit your website to Google, Yandex, Bing or Yahoo?
How to embed Instagram feed to my website?
How to create anchor points on your website?
How to set up event tracking codes on your website?
Adding chatbot to your Subbly site
Adding visual effects to your website
Building a page from scratch with Subbly
How to add images and videos to your website?
How to add GIFs to your website?
Configuring SSL for your website
Desktop vs. Mobile versions of a website
Positioning of elements
Why my domain was labeled as HREFLANG?
How to add Trust Pilot reviews to your website?
How to build your own product layout?
Setting up Headers and Footers across pages
Managing visibility settings of Elements and Blocks
How to create a Blog?
How do customers leave a review for my products?
Getting Started with the Website Builder
Basics of the Edit Mode
How to publish the latest changes on your website?
Previewing your Subbly website
Adding and creating Blocks on your website
How to localize your website (create a multilingual website)?
Colors tool
Why do the products go to 404 page?
How to create product category filter (Website builder)
Elements
Icons element
Blank space element
Language Switcher Element
Image Slider element
Form element
Map element
Product/Products Element
Breadcrumb element
Account Element
Accordion element
Button/Product Button element
Sharing Buttons element
Logo element
Quotes element
Paragraph element
Custom HTML element
Search element
Region Switcher element
Divider element
Articles and Article Categories element
Follow Us element
Gallery element
Title element
Video element
Image element
Countdown element
Pages element
Products
Product builder wizard
What are subscriptions?
Ad-hoc subscriptions
Anchored subscriptions
Understanding cut-off dates
Incoherent subscriptions
Implications of using Anchored + Incoherent
Setting subscriptions to auto-expire
Membership subscriptions
Content feed (How to use Subbly as a paywall?)
How to set sequential subscriptions in Subbly?
Seasonal subscriptions
How does the pre-order setting work?
How to set up pre-paid subscriptions?
Setting up commitment period for your products
Setting up trial period for subscription products
How to set up shipping methods for my store?
Setting up Mondial Relay
How gifting works?
How to use gift vouchers?
How to create one-time products?
Using one time products as bundles
How do I edit my product price and billing settings?
Can I set my subscriptions to auto-cancel themselves?
How to create "Subscribe & Save" offers on Subbly?
How to unpublish a product?
Setting up funnels
Subscription add-ons
Fixed bundles
Customizable bundles
Subscribe and Save bundles
Setting up subscription products
Survey builder
Customers
How customers manage their subscription? (Customer portal)
Can I add customer's subscriptions manually?
Customer's Labels Explanation
How to switch the subscription product customer is subscribed to?
How to change renewal date for a customer?
How can I see my customers' preferences?
How to change the shipping address for a customer?
How customers change their password?
Can customers add products to their subscription?
How to process a refund for the customer?
How to reactivate customer's subscription
How does skipping/pausing work?
Handling customer email notifications through Subbly (Templated emails)
Account credit balance
How do I export my customer data from Subbly?
Why my customer wasn't charged?
How to cancel customer's subscription?
Event Logs
AI Author Bot (powered by AI)
Orders
Order Labels Explained
Handling Orders
How to filter orders?
Importing Orders
Can I create a test order?
How to create adhoc orders/charges?
How to add a tracking number for customer's order?
Why am I not seeing my orders?
Why my orders don't appear in my Shipstation admin?
Growth & Retention
Customer retention
How dunning tool works on Subbly?
Cancellation Offers (Cancellation Flow)
Cancellation Analytics
Churn Insights
Payment Failure Email
Upcoming Renewal Email
Predictive churn (powered by AI)
Growth tools
Automations FAQ
Automations recipes (use cases)
Coupons
Inventory Management
Handling out of stock
Using cart abandonment tool
Setting up lead forms and converting leads
Setting up the referral tool on Subbly
How to setup affiliate tracking through Subbly?
Adding conversion tracking to the checkouts
Analytics FAQ
Setting up Addons Upsell
AI Addon Bundle
Integrations & App Store
App store
Setting up Chartmogul
How to use other shipping services with Subbly?
Setting up Facebook CAPI & Pixel
Setting up Google Tag Manager
Setting up Google Analytics
Setting up ManyChat integration
Setting up Taxjar
Setting up Facebook Login
Setting up Google Auth
Setting up Mailchimp integration
Setting up Drip
Setting up HotJar integration
Setting up Flodesk (through Zapier)
Setting up Zendesk integration
Setting up Pirate Ship integration
Setting up Shipstation integration
How does the ShipStation integration work?
Setting up Bablic
Setting up Zapier
Setting up Klaviyo
Setting up Twilio integration
Setting up Intercom integration
Setting up SendGrid
Setting up Postmark
Setting up CartStack
How to edit checkout layout through Google Optimize?
Embed Subbly into external platform(s)
FAQs
FAQ about Subbly
What countries is Subbly available in?
How do I get help? (How to contact support)
What payment gateways are supported on Subbly?
Stripe vs. Paypal: Which one to use?
How much traffic can the Subbly servers handle?
Pricing plans, pricing structure and applicable transaction fees on Subbly
How and when do we charge VAT?
Does Subbly offer refunds?
Can I use Subbly for POS sales?
How can I migrate my customers from Stripe?
How can I migrate my customers from PayPal?
Does Subbly integrate with any accounting platform?
How to transfer domain between sites on Subbly?
Why doesn't Subbly have a marketplace?
Why my checkout redirects to a different product?
What shipping integrations do you provide?
When do I get paid?
Global metadata (Attributes and Tags)
How can I access my previous receipts/invoices?
How can I send emails to my customers?
Working with Subbly Experts
Migrating to Subbly
Getting started with Subbly Guide
- Subbly Help Center
- Checkout & Payments
- Updating cart widget based on webpage actions
Updating cart widget based on webpage actions
Updated
by Binu Francis
If you've wanted to change cart widget behavior based on how your customers interact with your pages - the cart widget now offers the flexibility to embed some nifty Javascript snippets into your website, and make that happen!
This part isn't exactly as straightforward as dragging and dropping elements in the website builder. It might require some technical know-how around browser events and how to use them as a trigger for making changes on the Subbly cart widget. Not to worry! We'll help you along they way with examples and explanations.
Guide on how to add and execute JS scripts when something happens on the page
- Determine the event to use as a trigger - First, you'll need to determine which event you want to trigger your script. Some common events include clicking a button, submitting a form, or scrolling down the page. Determine which event makes the most sense for your use case.
- Create the script - Once you've determined the event you want to listen in on and use as a trigger, you can then create a script that will execute and make changes to your cart widget. This script will include the code that listens in information from your browser event capturing your customers' potential actions, and also the part that calls the cart widget and asks it to make changes.
- Add the script to your HTML file - Based on what triggers you're using for the script, you'll have to either place the script/code snippet within the head section of your webpage before </head> tag, or within a button, in case you want to use the button to execute the code, or a combination of both - like in the example below:
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
// Add your script code here
}
</script>Here, for your script to work, you'll need both these snippets added to your page, only difference being their placement within your page. As you can see, the first snippet will need to be added as a button inside your pages' <body> section. The second snippet will need to be added as a script within the <head> section of your website.You can also write the script in an external Javascript file, and have it load with your page by adding it as a source in the <head> section like shown below:<head>
<script src="myscript.js"></script>
</head> - Execute the script - When the event you've chosen to use as a trigger occurs, the script you've created in step 3 will execute. If you're using an event listener, you can attach the listener to the appropriate element on your page. For example, if you want the script to be executed when the user scrolls down the page, you could use a script that looks somewhat like so:
<script>
window.addEventListener('scroll', function() {
// Add your script code here
});
</script> - Test the script - Once you've added the script and attached it to the appropriate event, test it to make sure it's working correctly. Trigger the event and check if script is executed as expected.
That pretty much sums up the process, broadly. This will help you understand what the scripts are supposed to do, and how they're supposed to be programmed.
Examples of cart widget functions that can be triggered by page events
- Apply coupon to cart widget when customer submits a form
If there's a coupon you want to be applied to customers' cart when they submit a form - say they subscribe to your newsletter, you can first create a coupon and have that added in the script below that will apply the code as soon as customer submits the form.We'll use the form submit event as the trigger for the script in this caseAdd the following script within the <head> section of your page -<script>
Once you've added the script to your page, test it by submitting an entry on the form, then adding a product to your cart after, to see if the discount from the coupon is actually getting applied.
function applyCoupon(email) {
// Replace YOUR_COUPON_CODE with your actual coupon code
window.subblyCart.applyCoupon(YOUR_COUPON_CODE);
}
// Add an event listener to the subscribe form
const form = document.querySelector('form');
form.addEventListener('submit', (event) => {
event.preventDefault();
const email = document.querySelector('input[name="email"]').value;
applyCoupon(email);
});
</script> - Switch between languages and currencies in cart widget when it is changed on websiteBefore you can change the language in Subbly cart, you need to configure the languages in Subbly admin. Ensure that the language options and short codes you use on the HTML selector element match those that you've set up on your Subbly account. By default Subbly uses 2-character ISO standard: en, fr, es, etc.To switch between different languages on your cart widget, you'll need a language selector on your page(that you probably will also be using to change the website content language) such as a drop down menu, or radio buttons.
This will be used by your customers to make the language selection inputs, and the webpage will detect which language is being selected, so it can then in turn be also set as your cart widget's language. Here's an example of how a language selector should be coded -<select id="languageSelector">
The value parameter within each of these options should have the same language short codes as the ones that are defined for corresponding languages set within your storefront translation settings.
<option value="en">English</option>
<option value="fr">Français</option>
<option value="es">Español</option>
</select>
Once your language selector is set up, you can then add the following script to the <head> section of your page to be executed when customers switch between languages, and have their cart widget language changed.<script>
document.getElementById('languageSelector').addEventListener('change', function() {
const language = this.value;
window.addEventListener('subbly-cart-initialized', () => {
subblyCart.setLanguage(language)
}
});
</script>Make Sure that selector ID as in our example languageSelector is pasted correctly inside the script. If you don’t know the element ID, you can use developer tools by clicking right button of the mouse on the element, and choosing Inspect element.Here, we're using the subblyCart.setLanguage() function to switch the language on the cart widget when the event listener detects a change in the selector language.
Once added and saved, test the script by visiting your webpage, and switching the language selector to a different language, and triggering the cart widget either through the cart toggle, or by adding a product to cart. Check if the cart widget loads up in the selected language.
Similarly, you can switch between different store currencies, and use the script with minor changes as following<script>
window.addEventListener('subbly-cart-initialized', () => {
subblyCart.setCurrency('USD')
}
</script>
Here, we're calling the setCurrency() method, which changes the currency for the cart widget, instead of setLanguage() in the previous example. You'll also have to add the selector for currency on your page to getElementById() inside the script. - Pre-appying coupons and currencies from URL parameters
Using this script, you can pre-apply coupons to the cart widget - with the coupon code being passed as a parameter in the URL of the page. For example, if you want customers to visit https://www.yourstorename.com/shop/?coupon=BLACKFRIDAY and automatically have BLACKFRIDAY coupon applied to their cart when they add a product to their cart from the above page, you can do that using the script below -<script>
/*
Set coupon from the visited page URL query parameters, i.e.
[https://my.store.com/?coupon=MY_COUPON](https://my.store.com/?coupon=MY_COUPON)
*/
window.addEventListener('subbly-cart-initialized', () => {
const couponCode = new URLSearchParams(window.location.search).get('coupon')
couponCode && subblyCart.applyCoupon(couponCode)
})
</script>
Similarly, you can also pre-apply, or set the cart widget currency based on 'currency' parameter being added in the URL<script>
/*
Set currency from the visited page URL query parameters, i.e.
[https://my.store.com/?currency=GBP]
*/
window.addEventListener('subbly-cart-initialized', () => {
const currency = new URLSearchParams(window.location.search).get('currency')
currency && subblyCart.setCurrency(currency)
})
</script>
- Pre-apply coupon code from parameters added to checkout links
If you want to automatically apply a coupon to customers' cart when they're directly checkout out with a product, with the coupon code being passed as a parameter to the checkout link(example, https://subbly.co/checkout/buy/2400/?coupon=BLACKFRIDAY), you can do that using the following script -<script>
window.addEventListener('subbly-cart-initialized', () => {
const links = document.querySelectorAll('[href*="/checkout/buy/"]') || []
links.forEach((link) => {
let couponCode = new URL(link.href).searchParams.get('coupon')
if (couponCode) {
link.addEventListener('click', () => {
subblyCart.applyCoupon(couponCode)
})
}
})
})
</script>
If you're facing any problems while setting up these scripts, please feel free to contact support for assistance.