Posted on 21/11/2018 14:16:16
Hi Morten
I have now simplified the provider and it looks like this:
public class DebugLoggingLiveERPPriceProvider : PriceProvider
{
public override PriceRaw FindPrice(Product product, double quantity, string variantId, Currency currency, string unitId, User user)
{
// Get the price from the DefaultPriceProvider
DefaultPriceProvider defaultProvider = new DefaultPriceProvider();
PriceRaw rawPrice = defaultProvider.FindPrice(product, quantity, variantId, currency, unitId, user);
if (user != null && user.CustomerNumber == "A")
{
rawPrice.Price = 111;
return rawPrice;
}
if (user != null && user.CustomerNumber == "B")
{
rawPrice.Price = 222;
return rawPrice;
} else
{
rawPrice.Price = 333;
return rawPrice;
}
}
}
As you see from the code I have 2 users. The strange thing I have discovered now is that the provider is only called one time for each product, causing other users to see the price of the first user that browsed the product (across users in the same browser, and across computers)!
Example:
User A logs in and browses product 1. The price is 111. I log out user A and log in as user B (in the same browser session), browse product 1 and the price is still 111 (here I expected 222).
The interesting part now is that a completely different person on a completely different computer can browse product 1 (without logging in) and the price is still 111 (here I expected 333).
I can also confirm that if the user that is not logged in browses a product that hasn't been displayed before, this user and all other users get the price 333.
The site is hosted in Azure.
With this simplified priceprovider without any caching I would expect the FindPrice method to be called on every product that is displayed to every user, i.e. a lot of times....
Any tips?
Regards
Espen