Developer forum

Forum » Development » Association between order line for a product and a discount

Association between order line for a product and a discount


Reply
Hi there,

I have created a "Product Discount" that gives a 4 euro discount on products of a specific group. I need to subtract this discount from the product price when I submit an order into a backend system.

When I order one of those products and look at the cart, I see two OrderLine instances: one for the product, and one for the discount.

When I look at the product line, the OrderLineDiscountID is empty. When I look at the discount line, the OrderLineProductID is empty.

How can I determine the product in the order that the product discount applies to?

Imar

Replies

 
Nicolai Høeg Pedersen
Reply
Since more than one discount can be valid for an orderline, you find the discount on a specific product using OrderLine.Prouct.Discounts.
 
Reply
Ah, I see.

Where is that modelled in the database? For the export module I am using Entity Framework so I more or less recreated the Ecom api....

Imar
 
Nicolai Høeg Pedersen
Reply
Well - it is the extensibility that handles the discounts. So it is not in the database but a "real time" calculation of which discounts are applicable for the product right in that moment.

The persistence to the database is in the orderline table only.
 
Reply
Before your message edit, you mentioned the OrderLineParentID, but that once seems to be empty. is that why you removed it?

So, the only thing I have as an option is to reproduce discount calculation based on the XML in the SalesDiscountParameters column?

Or is there another option? Maybe hook into some extensibility event? Maybe I could recreate the Product Discount provider and "tag" each product with a product specific discount price?

Heavy stuff for a Friday afternoon.... ;-)

Imar

 
Nicolai Høeg Pedersen
Reply
OrderLineParentID is BOM products.

OrderLine.type defines if its a product or not.

But you can create either a orderline discount or an order discount.

Orderline discounts uses the CreateProductOrderline in the FindPricde method which links the discount to a product.

Order discounts uses the CreateAmountOrderline which is a discount on the order, and that is not linked to the original product...

Makes sense?
 
Reply
>> Makes sense?

Not quite. Is this a suggestion for a custom discount provider? Or can I do this from my order push tool? It doesn't run in a DW / user scope but from a command line.....

Imar
 
Nicolai Høeg Pedersen
Reply
Are you using a custom discount or a build in? And if using a build in, which one?

Otherwise provide the content of findprice.
 
Reply
I am using the built-in Product discount (first available discount). I assign a few groups and a discount value (either a percentage or a fixed amount)....

Imar

 

You must be logged in to post in the forum