Posted on 23/02/2015 01:27:14
Hi Imar,
It can be done, but it's a little involved. I would, however, not recommend that you call into base.FindPrice
as this method will simply return null
. Instead you should call the relevant FindPrice
overload in PriceManager
while maintaining a variable that you initiated the call. That way your provider returns null
when it's asked for a price in your call stack.
Something like this:
var itemsEntryName = "PriceCallInvokedFromMe";
// Check to see whether this price request is initiated from this provider
if (HttpContext.Current.Items.Contains(itemsEntryName))
return null; // Secondary price calculation initiated from this price provider -- returning null to go to the next provider
HttpContext.Current.Items[itemsEntryName] = true;
// Get price from another price provider -- chain always ends with system price if no other price is found
var price = Dynamicweb.eCommerce.Prices.PriceManager.FindPrice(product); // Maybe one of the other overloads is better?
// TODO: Manipulate the price according to the requirements
// Remember to remove the tracking variable from the Items collection in case other price calculations are needed in this HTTP request
HttpContext.Current.Items.Remove(itemsEntryName);
// Return the newly found and manipulated price as if it were my own
return price;
- Jeppe