Developer forum

Forum » Development » Priceprovider FindPrice and Order.BeforePriceCalculation

Priceprovider FindPrice and Order.BeforePriceCalculation

Thomas Larsen
Reply

What notification can I use, if I want to prepare the prices on products that exist in the current cart, before my custom PriceProvider FindPrice is called?

I have tried with Dynamicweb.Notifications.eCommerce.Order.BeforePriceCalculation, but this is activated after the FindPrice.

This has been tested on a clean wrap solution with only a custom FindPrice and a BeforePriceCalculation notification

dw_2016-03-02_18-20-10.png

Replies

 
Nicolai Høeg Pedersen
Reply

Pageloaded or cartloaded notification is early in the process and loads the cart. Try one of those....

 
Thomas Larsen
Reply

Added both and then the result was the following

[3/2/2016 8:37:25 PM]:    FindPrice - ProductID: PROD11, Quantity: 5
[3/2/2016 8:37:25 PM]:    BeforePriceCalculation - CartID: CART1911
[3/2/2016 8:37:25 PM]:    FindPrice - ProductID: PROD11, Quantity: 1
[3/2/2016 8:37:25 PM]:    BeforePriceCalculation - CartID: CART1911
[3/2/2016 8:37:25 PM]:    CartLoaded - CartID: CART1911
[3/2/2016 8:37:25 PM]:    PageLoaded - CartID: CART1911

 
Nicolai Høeg Pedersen
Reply

Hm - it is kind of the hen and egg problem. The pageloaded notification loads the cart - and loading the cart invokes the findprice.

Notifications.Standard.Page.DeviceDetected is broadcastet earlier than pageloaded.

What are you trying to achieve? Maybe there is another way. And why do you need to prep the price before the findprice is executed. You could when that is hit first time do what you need to do.

Nicolai

 
Thomas Larsen
Reply

I can set that, but what are the purpose of the Order.BeforePriceCalculation noticication, if it is not invoked before any price calculation is done in the cart?

The reason why I’m trying to prep the prices is that the price calculation is done by the ERP system webservice. And the performance is much better when I make one call with all the products instead of making multiple calls with one product.

But you right, I could make the first FindPrice prep all the products in the cart. I would work, but it is not pretty...

 
Nicolai Høeg Pedersen
Reply

Hi Thomas

Order.BeforePriceCalculation is related to the calculation of Order.Price. Findprice is related to products - so when the cart loads, it loads the products (which finds the products price) and then the order total is being calculated.

If you have a product list page using the catalog, you have a PreparePrices method on your price provider that will pass you a list of all the products being rendered right now. That is made for the purpose of looking up all the prices all at one time.

In the PreparePrices method, you can then collect all the products that are passed to the method, and also find products in the cart, and then send all the data to your ERP and do one calculation.

BR Nicolai

 

You must be logged in to post in the forum