Hi there,
I have a project where the remote ERP determines if a product can be sold to the currently selected ship to country. For example, it can be that a customer can see / order a product when they ship to country X but not when they ship it to country Y. My intent is to use a PriceProvider for this as it has all the functionality to reach out to an ERP when displaying a single product or a list of products.
I am stuck with applying the information to the product in the user's context. In other words, I am missing functionality like we have in a TemplateExtender to add new tags so I can do something like this in my PriceProvider:
something.SetTag("CanOrderCurrentProduct", GetValueFromXmlResponse());
where GetValueFromXmlResponse
returns true or false depending on the response from the ERP. With this code, in my template I could then do:
if (GetBoolean("CanOrderCurrentProduct"))
{
// Show add to cart button
}
else
{ <p>Sorry, this product can't be shipped to your current shipping country.</p>
}
Inside the (standard) PriceProvider I see code like this:
public virtual void FillProductValues(ProductInfo productInfo, Product product, double quantity)
{
double? newStock = (double?)productInfo["Stock"];
if (newStock.HasValue && Helpers.IsDifferentStock(product.Stock, newStock.Value))
{
product.Stock = newStock.Value;
Services.Products.Save(product);
productInfo["Stock"] = null;
}
...
}
Thanks!
Imar