Developer forum

Forum » Development » Using Product Custom fields in Price provider

Using Product Custom fields in Price provider


Reply

I have completed a working discount provider.

But now the customer wants to have a special price added in using a custom field.

How can i access that custom field from the price provider ?

/Lars


Replies

 
Reply

Assuming that p is your product object:


foreach (Dynamicweb.eCommerce.Products.ProductFieldValue f in p.ProductFieldValues)
{
    if (f.ProductField.Name == "MyCustomField")
    {
        f.Value = "";
    }
}

 

Custom fields on an order or orderline is the same story. Only the naming is different:

 

Dynamicweb.eCommerce.Orders.OrderFieldValue

Dynamicweb.eCommerce.Orders.OrderLineFieldValue

 

 
Jon Lennryd
Reply

Using dw version 19.2.4.3, I found that the ProductFieldValues object is null if you create your product via the Product.Create(); function.

Workaround is to set all your data, Save the product, and re-load it with the new Product( ID );
After the reload, the product.ProductFieldValues is defined.

This a bug is, no? :)
 

 

 

You must be logged in to post in the forum