Developer Documentation (Methods/Events/CSS Selectors)
JavaScript API reference for Oxify Cart: global methods to open, close, and add items to the slide cart, plus events and CSS selectors.
Lightweight, global helpers for opening/closing the slide cart and adding items programmatically. These functions are injected on the storefront once Oxify Cart is installed and enabled.
Getting Started
Once Oxify Cart is installed on your Shopify store, the public API becomes available on the global window object on storefront pages.
Prerequisites
- Active Oxify Cart installation on your Shopify store
- Basic understanding of JavaScript
- Familiarity with Shopify theme structure
Feature Detection (Important)
Always check that the functions exist before calling them. This prevents errors if the app is disabled or a script hasnβt loaded yet.
Best Practices
- Check for API availability before calling (see Feature Detection).
- Handle failed add-to-cart attempts gracefully (network issues, invalid variant IDs, etc.).
- Use event listeners from your theme (e.g., re-render cart badge after add) where applicable.
- Test across multiple devices and browsers; verify behavior with other cart apps present.
Browser Compatibility
The IA Cart Public API supports modern browsers:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Note: Implement feature detection before using these APIs to ensure compatibility across browsers and versions.
API Reference
window.openIACartDrawer()
Summary
Programmatically opens the Oxify Cart slide cart. Useful when your theme or another app overrides default open behavior.
Type
() => void
Example
if (typeof window.openIACartDrawer === "function") {
window.openIACartDrawer();
}
window.closeIACartDrawer()
Summary
Programmatically closes the IA Cart slide cart. Useful when another app intercepts default close behavior.
Type
() => void
Example
if (typeof window.closeIACartDrawer === "function") {
window.closeIACartDrawer();
}
window.addItemsToIACartDrawer(listOfItems: any)
Summary
Adds one or more line items to the cart. When used together with openIACartDrawer(), the drawer will open and show the updated cart contents.
Type
(listOfItems: Array<{ id: number; quantity: number; selling_plan?: number }>) => void
Parameters
Name
Type
Required
Description
id
number
Yes
The variant ID to add.
quantity
number
Yes
Quantity to add for this variant.
selling_plan
number
No
Optional Shopify selling plan ID for subscriptions.
Example
β
Usage Examples
Open the cart from a custom button
Add a single variant (with optional subscription)
Add multiple line items at once
Troubleshooting & FAQs
The functions are undefined.
- Ensure Oxify Cart is installed and enabled on the published theme.
- Verify the storefront is not blocking third-party scripts (content security policy/ad blockers).
- Use feature detection and optionally delay your call until DOMContentLoaded.
Items didnβt appear in the cart, or the wrong item was added.
- Confirm youβre passing variant IDs (not product IDs).
- Make sure the selling_plan ID is valid for that variant (if used).
- Check quantity is a positive integer.
Another cart app conflicts with opening/closing.
- Prefer calling window.openIACartDrawer() and window.closeIACartDrawer() directly from your custom triggers to override theme/app intercepts.
- Avoid binding duplicate click handlers on the same element.
Type Definitions
type IACartLineItem = {
id: number; // Variant ID
quantity: number; // > 0
selling_plan?: number; // Optional subscription selling plan ID
};