Validate Discount Codes
When a customer applies a discount code during checkout, it is important to validate the discount code before applying it. You have two options for providing discount codes with Bold Checkout — you can either use the out-of-the-box functionality to provide and validate discount codes, or you can use a plugin to provide custom discount functionality.
This page covers both methods for providing and validating discounts.
If your store is on Magento 1 or Adobe Commerce, you cannot use Bold Checkout validate discount codes. You must manage and validate discount codes through the Magento 1 or Adobe Commerce admin or a third-party integration.
Use Bold-provided discounts
To use Bold-provided discount functionality, ensure that discounts are enabled within the Bold Checkout app. To find these settings, click Payment Options in the left-hand menu, then Discount codes. Once enabled, you can create and configure discounts.
To validate discounts through the Checkout Frontend API, you can use either of the following endpoints:
- Validate Discount Code — This endpoint enables you to check whether a discount code is valid without applying it to the order.
- Add Discount Code — This endpoint performs all the same steps of the Validate Discount Code endpoint and applies the discount to the order if valid.
The discount code is also validated for a final time when you call the Process Order endpoint.
Components of validation
When you call the Validate Discount Code endpoint, Bold verifies the following:
- The store must have discounts enabled within the Bold Checkout app.
- The order cannot have more than one discount.
- The discount code must exist on the store.
- The discount must not be already applied to the order.
- If the discount code has defined start and end dates, the time the discount was applied must fall between those dates.
- If the discount has a use limit (for example, if the first 100 customers get a discount), ensure the limit is not reached.
- If the discount has a use-per-customer limit (for example, if the discount can only be used five times per customer), ensure the limit is not reached.
There are some scenarios in which you need to validate a discount code more than once, especially if the customer information changes.
For example, if a customer first uses an email that indicates they are eligible for a discount, and the customer changes their email, you must re-validate the discount to ensure it still applies.