Developer forum

Forum » Ecommerce - Standard features » Live prices mismatch on add to cart request

Live prices mismatch on add to cart request

Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi there,

We are using live prices and we subscribe the CartLoaded and OrderLineAdded notifications. There issue I am pursuing is when we add quantity of one previously added product the minicart counter/price is not up to date.
The reason behind this is the add to cart response has the correct number of products but the previous cart total price.

Add to cart request:
https://dev-ska.mydwsite2.com/Default.aspx?ID=6308&Quantity=6&redirect=false&getproductinfo=true&ProductID=100139&cartcmd=add&feedtype=Counter

  • CartLoaded notification
    • before force recalculate: 25.62
    • after force recalculate: 25.62
  • OrderLineAdded notification
    • before force order recalculate: 51.24
    • after force order recalculate: 51.24

We can see that prices above are correct even without the recalculate but the response will be 25.62 and not 51.24 as it would be expected. 

Next mini cart load request
https://dev-ska.mydwsite2.com/Default.aspx?ID=6308

  • CartLoaded notification
    • before force order recalculate: 25.62
    • after force order recalculate: 51.24

Here the price is displayed correctly, but is too late since the mini cart counter was already updated, creating a mismatch between counter and the mini cart panel info.

Without the redirect=false on the add to cart request this works since it performs a new mini cart load request, but Rapido is not built that way.
Here's a screencast to help visualize the issue - https://www.screencast.com/t/w0wz1Zqm9hP

I am not sure where to look further, could it be that template tags are generated right after the OrderLoaded notification? Any and all thoughts are appreciated.

Thanks!
BR, Mario


Replies

 
Nicolai Pedersen
Reply

Hi Mario

CartLoaded runs very early in the page lifecycle before any other actions on the cart and order objects are handled. So that is the state in the begining of the lifecycle. So you have to tap in later in the cycle to do your calculations.

BR Nicolai

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Nicolai,

 

We are doing that, we have a few notifications subscribed, like Line.Added, Line.Increased, etc. In my example in the add to cart request the Line.Added notification has the correct value even without our calculations but the template on the frontend shows the wrong value. Then, on the CartLoaded (mini cart request) we see the old value which I would assume it should be updated already but it is not. I also tried to save the order object and did a SetCart but it didn't work.

 

BR, Mario

 
Nicolai Pedersen
Reply

Show us your code and what you do with  CartLoaded and OrderLineAdded.

Maybe some of that logic should be in a price provider?

BR Nicolai

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

This is a custom version of LiveIntegration, but we are using a price provider.

CartLoaded and OrderlineAdded will both call CheckOrderPrices in IntegrationNotificationSubscriberBase.cs. I have attached the files.

BR, Mario

 
Nicolai Pedersen
Reply

.cs files cannot be downloaded here... So please zip.

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Ooopss.. Wasn't aware of that.

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi Nicolai,

Just checking if you have any input on this?

Thanks!

BR, Mario

 
Nicolai Pedersen
Reply

Hi Mario

No - I cannot without debugging it... Sorry.

BR Nicolai

 

You must be logged in to post in the forum