Dynamicweb 8 Documentation
FindPrice(Product,Double) Method
Example 

The product.
The quantity.
Finds the price.
Syntax
'Declaration
 
Public Overloads Shared Function FindPrice( _ 
   ByVal Product As Product, _ 
   ByVal Quantity As Double _ 
) As Object
public static object FindPrice( 
   Product Product,
   double Quantity 
)

Parameters

Product
The product.
Quantity
The quantity.
Example
class MyPage : System.Web.UI.Page
{
    private Dynamicweb.eCommerce.Products.Product product;

    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        product = (Dynamicweb.eCommerce.Products.Product)Session["Ecom.Backend.Product"];
    }

    private Dynamicweb.eCommerce.Prices.PriceInfo GetPrice(ProductItemCollection items)
    {
        Dynamicweb.eCommerce.Prices.PriceInfo priceInfo = new Dynamicweb.eCommerce.Prices.PriceInfo();

        if (product.Type == ProductType.Stock & product.PriceType == ProductPriceType.Calculated)
        {
            product.PriceType = ProductPriceType.FixedPrice;
        }

        if (product.Type == ProductType.Service & product.PriceType == ProductPriceType.Calculated)
        {
            product.PriceType = ProductPriceType.FixedPrice;
        }

        if (product.PriceType == ProductPriceType.Calculated | product.PriceType == ProductPriceType.CalculatedWithBase)
        {
            foreach (ProductItem Item in items)
            {
                object priceObj = Dynamicweb.eCommerce.Prices.PriceManager.FindPrice(Item.Products.getProductById(Item.DefaultProductID), Item.Quantity);

                if (priceObj != null)
                {
                    double quantity = 1.0;
                    if (Item.Quantity > 0)
                    {
                        quantity = Item.Quantity;
                    }

                    Dynamicweb.eCommerce.Prices.PriceInfo subPrice = null;

                    if ((priceObj) is Dynamicweb.eCommerce.Prices.PriceInfo)
                    {
                        subPrice = (Dynamicweb.eCommerce.Prices.PriceInfo)priceObj;
                    }
                    else if ((priceObj) is Dynamicweb.eCommerce.Prices.PriceRaw)
                    {
                        Dynamicweb.eCommerce.Prices.PriceRaw rawPrice = (Dynamicweb.eCommerce.Prices.PriceRaw)priceObj;
                        subPrice = new Dynamicweb.eCommerce.Prices.PriceCalculated(Item.Products.getProductById(Item.DefaultProductID), rawPrice);
                    }
                    subPrice = subPrice.Multiply(quantity);
                    priceInfo = priceInfo.Add(subPrice);
                }
            }

            if (product.PriceType == ProductPriceType.CalculatedWithBase)
            {
                priceInfo = priceInfo.Add(new Dynamicweb.eCommerce.Prices.PriceCalculated(product));
            }
        }
        else
        {
            priceInfo = new Dynamicweb.eCommerce.Prices.PriceCalculated(product);
        }

        return priceInfo;
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PriceManager Class
PriceManager Members
Overload List

Send Feedback