Add products to a cart, then checkout all at once.
Add this script tag to your page:
<script src="https://js.tip4serv.com/tip4serv.min.js?v=1.0.21" data-store-id="YOUR_STORE_ID"></script>
Use tip4serv-add-cart-btn class to add items, and tip4serv-open-cart-btn to open checkout. Same data-* attributes as buy buttons.
Click products to add them to the cart, then open checkout. Try adding the same product twice — quantity stacks!
Subscription product
Chosen Quantity: 5
One-time product
<!-- Add to cart buttons -->
<button class="tip4serv-add-cart-btn" data-product="vip" onclick="this.textContent='Added to cart!'">
Add to Cart
</button>
<button class="tip4serv-add-cart-btn" data-product="50-coins" data-quantity="5" data-subscription="false" onclick="this.textContent='Added to cart!'">
Add to Cart
</button>
<button class="tip4serv-add-cart-btn" data-product="15-mystery-box-lvl-5" data-subscription="false" onclick="this.textContent='Added to cart!'">
Add to Cart
</button>
<!-- Open checkout with cart contents -->
<button class="tip4serv-open-cart-btn"
data-success-url="https://js.tip4serv.com/thank-you.html?return=https://js.tip4serv.com/demo-cart.html"
data-cancel-url="https://js.tip4serv.com/cancelled.html?return=https://js.tip4serv.com/demo-cart.html">
Open Checkout
</button>
Use Tip4Serv.Checkout.Cart.Add() to add products, Tip4Serv.Checkout.Cart.Open() to checkout, and Tip4Serv.Checkout.Cart.Clear() to empty the cart.
Add products via JS, then open cart with callbacks to handle results.
Subscription product
Chosen Quantity: 5
One-time product
// Add a subscription product
Tip4Serv.Checkout.Cart.Add({
product: "vip"
});
// Add with quantity (one-time)
Tip4Serv.Checkout.Cart.Add({
product: "50-coins",
quantity: 5,
subscription: false
});
// Add a one-time product
Tip4Serv.Checkout.Cart.Add({
product: "15-mystery-box-lvl-5",
subscription: false
});
// Open checkout with callbacks
Tip4Serv.Checkout.Cart.Open({
onSuccess: () => console.log("Paid! Cart cleared."),
onCancel: () => console.log("Cancelled")
});
// Clear cart manually
Tip4Serv.Checkout.Cart.Clear();