1. Include our sample code in your checkout page
Copy the contents of our sweettooth-points-products-dropdown.html code sample and add it to the body of your checkout page.The code sample uses jQuery. If your site does not already include or use jQuery, you should uncomment the jQuery script at the top of the sample.
2. Add the dropdown to your checkout page
Add the following div to your checkout page where you’d like the points dropdown to appear.HTML
3. Customize the available rewards
Sometimes there are rewards offered through your program that don’t apply to the cart, such as Free Product rewards. You can hide specific Points Products from being shown in the dropdown menu by adding specific Points Product IDs to thehidePointsProductsIds variable in the code sample.
In order to find the IDs of points products that you want to hide, visit Smile Admin and navigate to your points program. Go to your rewards and select one that you wish to hide from the points products dropdown. When you select a reward, you will be able to find the corresponding ID of the points product in the address bar.
This ID can be added to the hidePointsProductsId variable in order to hide it from the dropdown.
4. Apply the discount code to your cart
In order for the dropdown to be functional, you will need to specify how the generated coupon code should be applied to the customer’s cart. The methodpurchasePointsProduct is triggered by the customer when the “Redeem” button is clicked. Within the callback of this method, you’ll have access to the discount code which can then be applied to the cart however you see fit. The code is available by referencing pointsProduct.fulfilled_reward.code.
The process for applying the discount code to your customer’s cart can be done via your cart’s API, or by a form field input simulated with JavaScript. To complete the setup of the dropdown, you’ll need to customize the contents of the applyDiscountCodeToCart function so that the generated code is applied to the customer’s cart.