Dynamicweb 8 Documentation
Substract(IWithPrice) Method
Example 

The priceholder.
Substracts the specified priceholder.
Syntax
'Declaration
 
Public Overloads Overridable Function Substract( _ 
   ByVal priceholder As IWithPrice _ 
) As PriceInfo
public virtual PriceInfo Substract( 
   IWithPrice priceholder 
)

Parameters

priceholder
The priceholder.
Example
class MyPage : System.Web.UI.Page
{
    private void RenderOrderLine(Dynamicweb.eCommerce.Orders.OrderLine orderLine, Dynamicweb.Rendering.Template template)
    {
        Dynamicweb.eCommerce.International.Currency temporaryContextCurrency = Dynamicweb.eCommerce.Common.Context.Currency;
        if (orderLine.Price.Currency != null)
        {
            Dynamicweb.eCommerce.Common.Context.Currency = orderLine.Price.Currency;
        }
        Dynamicweb.eCommerce.Prices.IWithPrice totalDiscountPriceInfo = (Dynamicweb.eCommerce.Prices.IWithPrice)orderLine.Product.Discounts.TotalDiscount.Multiply(orderLine.Quantity);
        totalDiscountPriceInfo.Price.Currency = Dynamicweb.eCommerce.Common.Context.Currency;
        Dynamicweb.eCommerce.Prices.PriceInfo netPrice = orderLine.Price.Substract(totalDiscountPriceInfo);
        RenderPriceInfo(netPrice, template, "Ecom:Order:OrderLine.TotalPriceWithProductDiscounts");
        Dynamicweb.eCommerce.Common.Context.Currency = temporaryContextCurrency;
    }

    public static void RenderPriceInfo(Dynamicweb.eCommerce.Prices.IPriceInfo price, Dynamicweb.Rendering.Template template, string tagName)
    {
        if (template.HtmlHasPartialTag(tagName))
        {
            if (template.TagExists(tagName + ""))
            {
                template.SetTag(tagName + "", price.PriceFormatted);
            }
            if (template.TagExists(tagName + ".Price"))
            {
                template.SetTag(tagName + ".Price", price.PriceFormattedNoSymbol);
            }
            if (template.TagExists(tagName + ".PricePIP"))
            {
                template.SetTag(tagName + ".PricePIP", price.PricePIP);
            }
            if (template.TagExists(tagName + ".PriceFormatted"))
            {
                template.SetTag(tagName + ".PriceFormatted", price.PriceFormatted);
            }
            if (template.TagExists(tagName + ".PriceWithVAT"))
            {
                template.SetTag(tagName + ".PriceWithVAT", price.PriceWithVATFormattedNoSymbol);
            }
            if (template.TagExists(tagName + ".PriceWithVATFormatted"))
            {
                template.SetTag(tagName + ".PriceWithVATFormatted", price.PriceWithVATFormatted);
            }
            if (template.TagExists(tagName + ".PriceWithoutVAT"))
            {
                template.SetTag(tagName + ".PriceWithoutVAT", price.PriceWithoutVATFormattedNoSymbol);
            }
            if (template.TagExists(tagName + ".PriceWithoutVATFormatted"))
            {
                template.SetTag(tagName + ".PriceWithoutVATFormatted", price.PriceWithoutVATFormatted);
            }
            if (template.TagExists(tagName + ".VAT"))
            {
                template.SetTag(tagName + ".VAT", price.VATFormattedNoSymbol);
            }
            if (template.TagExists(tagName + ".VATFormatted"))
            {
                template.SetTag(tagName + ".VATFormatted", price.VATFormatted);
            }
            if (template.TagExists(tagName + ".VATPercent"))
            {
                template.SetTag(tagName + ".VATPercent", price.VATPercent);
            }
            if (template.TagExists(tagName + ".VATPercentFormatted"))
            {
                template.SetTag(tagName + ".VATPercentFormatted", price.VATPercentFormatted);
            }
            bool isZero = price.Price == 0;
            template.SetTag(string.Format("{0}.IsZero", tagName), Base.IIf(ref isZero, "true", ""));
        }
    }
}
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

PriceInfo Class
PriceInfo Members
Overload List

Send Feedback