I'm working on a feature that needs to determine whether a discount or voucher code has been applied to the current cart or order. While the order calculation itself functions as expected, I want to implement a true/false validation that provides a clear explanation if the voucher code isn't applied.
Single-use voucher code
We have a voucher code that can only be used once per user. I need to display a message when a user tries to reuse the code, informing them that it has already been redeemed. Currently, the API we are using only checks if the voucher exists and is active (Dynamicweb.Ecommerce.Orders.SalesDiscounts.PromoCodeChecker.CheckOrderPromoCode(vouchercode)) but does not verify whether the user has previously used it.
Multiple discounts logic
We have set up multiple order discounts and configured the system in the Advanced Settings to apply only the highest-value discount. If a user enters a voucher code, and a higher-value discount is already applied to the order, I want to show a message explaining that the voucher wasn't applied because a better discount is already in place.
How can I implement checks to handle these two scenarios? Any advice or suggestions would be appreciated.
BR,
John