Posted on 24/01/2019 21:58:43
HI Adrian
There are a number of methods on the discountservice that could come ind handy - it is currently friend though, but thats an easy fix.
I will also be happy to give you an API call that gets you what you want. But how should it work?
Say you have a discount that works on voucher X, but only for orders over 500 with product Y in it. Would an API call return nothing until the order and product criteria is met? And what happens if you later do things on the order that will change which discounts are available?
The DiscountProvider class (which is not a real provider, but the discount matrix calculater) also have a number of methods that can validate if criterias for the discount are met, i.e. like these:
CheckValidTime(discount, orderTime)
CheckOrderContext(discount, orderContextId)
CheckUser(discount, _user)
CheckUserGroup(discount, _user)
CheckCustomerNumber(discount, _user)
CheckCurrency(discount, currency)
CheckProductsAndProductGroups(discount, products)
CheckLanguage(discount, languageId)
CheckShop(discount)
CheckCountry(discount)
CheckShipping(discount, shippingId)
CheckPayment(discount, paymentId)
CheckProductQuantities(orderDiscount, productQuantityRelation)
CheckTotalPrice(orderDiscount, totalPrice)
CheckOrderFields(orderDiscount, order)
CheckProductFields(orderDiscount, orderline)
Using any combinations of these, and other criterias as well - if other discounts are applied etc, will have an impact on which discounts are valid.
The bottom line is that it is relatively complicated wether a discount can be applied or not. It would be easy to give you a list, but you would probably find it 'buggy' in one scenario or another.
So let me understand the need in the above context, and I'll be happy to provide the API needed.
BR Nicolai