Dynamicweb 8 Documentation
PriceManager Class
Members  Example 

Represents a price manager. Provides prepares and finds prices.
Syntax
'Declaration
 
Public Class PriceManager 
public class PriceManager 
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;
    }
}
Inheritance Hierarchy

System.Object
   Dynamicweb.eCommerce.Prices.PriceManager

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 Members
Dynamicweb.eCommerce.Prices Namespace

Send Feedback