How can I pass coupon directly to the checkout page, without the users having to enter it manually?
Scope
How to pass coupon id on the checkout URL?
Problem statement
How to pass coupon id on the checkout URL?
Solution
The following sections cover how to pass a coupon ID in the checkout URL and how to create a checkout URL with a coupon applied.
V2 checkout (drop-in script)
You can include a coupon code in the checkout script so that it is automatically applied. It can be done similarly to the example mentioned in the "Add-on customizations" section in this document. The script code to include coupons is mentioned below.
var cbInstance = Chargebee.getInstance();
var link = document.querySelectorAll("[data-cb-type=checkout]")[0];
var product = cbInstance.getProduct(link);
product.addCoupon("COUPON NAME");
Latest Product Catalog (V3) — payment link with coupon
Was this article helpful?