How to get the items related to a promotion in a scriptablecart?
Hello everyone, first question and a little challenging!
I am working with one ScriptableCart, depending on the price of the item, I request to an external service to obtain the taxes and apply them to the lineItem.
Everything was fine, until the promotions appeared.
They aren’t stored on the lineItem, they only appear as a separate line on the order that only has some data, such as the promotionId and its discount, but not to which product it is being applied.
In frontend, SCA processes it well with the LiveOrder.Model, but in the ScriptableCart I don’t have the discount applied to the lineItem, so I don’t have the real amount.
One possibility, which I want to avoid because of loading times each time the cart is modified, would be to search all promotions to this order and obtain the product ID to which it is applied and then apply the discount manually to the lineTotal.
Do you know any other more effective way? I would like to be able to get the nlapiGetContext data in the ScriptableCart, but it doesn’t work. Any suggestions?
Thank you very much
Promotions/Discounts in NS are applied either on body level(using DISCOUNT ITEM field) or on the line item level, but I don’t think there’s a way to identify to which product they are applied to as they are applied to the whole order in NS. If there’s only one item on the transaction then it’s simple to know that the discount is applied only to that item amount but with multiple items you can’t know. Does that answer your question?