Developer forum

Forum » Development » PriceProvider PreparePrices quantity is lagging

PriceProvider PreparePrices quantity is lagging

Remi Muller
Reply

See screencast: http://screencast.com/t/M2r5A4CiHGC

In this cast you can see that when i update to a new quantity in the cart i am getting the previous quantity in the PreparePrices method.
 

To be able to prepare the correct price i need the new quantity. Can this please be fixed?


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Remi

We need to look into this to find out what the issue is. Will assign the task to a developer today and get back to you.

Nicolai

 
Remi Muller
Reply

Any update? You are able to reproduce?

 
Nicolai Høeg Pedersen
Reply

Hi Remi

Yes, i've had a developer look at this issue and trying to reproduce with no success. He gets the right quantity in the prepareprices when called.

I think we need your source code if we have to look any further into this.

Nicolai

 
Remi Muller
Reply

I tried making a proof of concept on the solutionset with version 8.4.1.15.

I am having different results but not good. This is driving me nuts.

1. First FindPrice is called and then 
2. PreparePrices(Dictionary<Product, double> Products) with correct quantities but this is too late!

What is happening here?

Used the following dummy code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dynamicweb.eCommerce.Prices;
using Dynamicweb.eCommerce.Products;

namespace DummyPriceProvider
{
    public class DummyPriceProvider :  PriceProvider
    {
        public override PriceRaw FindPrice(Product Product, double Quantity, string VariantID, Dynamicweb.eCommerce.International.Currency Currency, string UnitID, Dynamicweb.Frontend.Extranet User)
        {
            return null;//base.FindPrice(Product, Quantity, VariantID, Currency, UnitID, User);
        }
        public override void PreparePrices(Dictionary<Product, double> Products)
        {
            //base.PreparePrices(Products);
            foreach (var item in Products)
            {
                var val = item.Value;
            }
        }
        public override void PreparePrices(ProductCollection Products)
        {
            
            foreach (var item in Products)
            {
                var val = item.Name;
            }
        }
    }
}
 
 
Nicolai Høeg Pedersen
Reply

Hi Remi

Do you use the cartcmd=updateorderlines to update the cart?

This command does not trigger the prepareprices with the right quantity. If you change to using cartcmd=add or addmulti, the prepare prices are called with the right amount.

You can also in the prepareprices, check how many is in the cart by checking the orderline collection on eCommerce.Common.Context.Cart property.

Attached a pirate 8.4.1.* Dynamicweb.dll with an extra call to PreparePrices when using cartcmld=updateorderlines. Let me know if it fixes the issue.

BR Nicolai

 
Remi Muller
Reply

There is some progress.

In the customer implementation i was missing the CartCmd: updateorderlines in the ajax cart update. Cart update still works but PriceProvider is behaving differently.

 

But now i have the same problem as with the solutionset.

1. First FindPrice is fired and then 
2. PreparePrices(Dictionary<Product, double> Products) with correct quantities but this is too late.

 

Can you reproduce the incorrect order of FindPrice en PreparePrices?

 
Remi Muller
Reply

Missed your post will try the add, addmulti or the pirate dll ;)

Looks like you are on the problem :)

 

 
Remi Muller
Reply

I tried the pirate dll with the following result:

1. First FindPrice is fired and then 
2. PreparePrices(Dictionary<Product, double> Products)
3. PreparePrices(Dictionary<Product, double> Products) 

There is an extra call to PreparePrices now but still too late :(

 
Remi Muller
Reply

Hi Nicolai. Are you able to reproduce the incorrect order? Can this be fixed?

 
Remi Muller
Reply

Hi Nicolai,

Can someone of DW reproduce the incorrect order of execution for findprice en prepare prices? 

It is not a big problem but should be fixed.

 
Remi Muller
Reply

Has someone of dw taken a look at this and made a fix?

 
Nicolai Høeg Pedersen
Reply

Hi Remi

Sorry - we will look into it again during today.

Nicolai

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Remi,

I have identified the issue and a fix has been implemented. It will be released with the next round of hotfixes (8.4.1.20 or 8.5.0.2 depending on which version you use). We will let you know when the downloads are available.

- Jeppe

Votes for this answer: 1
 
Kristian Kirkholt
Reply

Hi Remi

The problem regarding #15815 "PreparePrices is not invoked before FindPrice" has been resolved in version 8.4.1.20

You are able to find this build in the download section:

http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards

Dynamicweb Support

Kristian Kirkholt

 

You must be logged in to post in the forum