Hi DW,
I trying to build a somewhat special logic regarding prices, and i'm having problems getting everything to work properly.
Intro
In Dynamicweb we have around 600 products and each of these products represent a mother product, which means that these products do not make much sense on their own, but combined with another information the are complete.
The additional information that is needed for a product to be complete, can be found in an external service that we hook up to on-the-fly and this service returns information about a batchnumber.
To find the correct price you need the productnumber from Dynamicweb, the Batchnumber from the external service and a customernumber.
When i have these 3 values i can ask another webservice for a price for this specific batch og products.
Example data
In Dynamicweb eCommerce
ProductID | ProductName |
P00123 | Product 1 |
P00456 | Product 2 |
In the webservice
ProductID | BatchNumber |
P00123 | B01 |
P00123 | B02 |
P00456 | B03 |
P00456 | B04 |
P00456 | B05 |
My issue is that the PriceProvider in Dynamicweb doesn't know about the BatchNumber since it's not part of the product. And at the moment the value only exists as an OrderLineFieldValue on my order.
I've solved the problem 50% by not using the priceprovider at all, but i'm having big problems getting the correct price rendered in my cart.
So far i have an OrderExtender that isn't working with this code:
if( RenderingState == TemplateExtenderRenderingState.Before ) { Order order = base.Order; order.AllowOverridePrices = true; foreach( OrderLine orderLine in order.OrderLines ) { /* OUTLET: Override unitprice with value from service*/ OrderLineFieldValue ofv = orderLine.get_OrderLineFieldValue( "batchnumber" ); string batchNumber = string.Empty; if( ofv != null && ofv.Value != null ) { batchNumber = ofv.Value; } if( batchNumber.Length > 0 ) { /* Ocerride unit price on outlet products */ PriceRaw pr = DataHelper.GetPriceFromService( orderLine.Product.Number, batchNumber, base.User.CustomerNumber, "1", Dynamicweb.eCommerce.Common.Context.Currency ); PriceCalculated pc = new PriceCalculated( orderLine.Product, pr ); orderLine.AllowOverridePrices = true; orderLine.SetUnitPrice( pc, true ); } } order.Save(); }