Adjusting Prices / Manipulating Orderlines #610
-
Hi, I have a use case where I need to add a free product to the cart - a gift. But I am having trouble setting the product prices / the orderlines total to 0. The price should only be 0, when it is being added from a certain endpoint / context. I can see there is some way to make price adjustments, but I am unsure how to implement it in this use case, as it seems the price adjustments would be used across the website. Any suggestions on how to solve this issue ? 🙂 Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Please share the code of what you've tried. Generally speaking, you have a couple of options. A price adjuster is one, and with this you'd probably use the order reference in the args to work out if the adjustment should apply. Another option is an order line calculator which can work out the unit price for an order line. This would probably have to do a similar thing though of using the passed in args to figure out if a discount applies. Without knowing what you've tried though it's hard to suggest if/where you are going wrong. |
Beta Was this translation helpful? Give feedback.
When you are within a price adjuster you are part of a calculation flow and so prices are net yet updated on the order. You need to access orderline prices from the order calculation state (which is available in the args) https://docs.umbraco.com/umbraco-commerce/key-concepts/order-calculation-state but yes, it should be a Price adjustment.