protected void CatalogNodeList_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                Product product    = (Product)e.Item.DataItem;
                Label   productSku = (Label)e.Item.FindControl("ProductSku");
                productSku.Text = product.Sku;

                HyperLink productName = (HyperLink)e.Item.FindControl("ProductName");
                productName.Text        = product.Name;
                productName.NavigateUrl = product.NavigateUrl;

                HyperLink    productManufacturer = (HyperLink)e.Item.FindControl("ProductManufacturer");
                Manufacturer manufacturer        = product.Manufacturer;
                if (manufacturer != null)
                {
                    productManufacturer.Text        = manufacturer.Name;
                    productManufacturer.NavigateUrl = string.Format("~/Search.aspx?m={0}", manufacturer.Id);
                }
                else
                {
                    productManufacturer.Visible = false;
                }

                Label productRetailPrice = (Label)e.Item.FindControl("ProductRetailPrice");
                if (!product.UseVariablePrice && product.MSRP > 0)
                {
                    productRetailPrice.Text = TaxHelper.GetShopPrice(product.MSRP, product.TaxCode != null ? product.TaxCode.Id : 0).LSCurrencyFormat("ulc");
                }
                else
                {
                    productRetailPrice.Visible = false;
                }
            }
        }
        public void CreateControls()
        {
            LoadWrapStyles();
            if (_WrapStyles == null)
            {
                //NO GIFT WRAP AVAILABLE
                OneGiftWrapPanel.Visible   = false;
                MultiGiftWrapPanel.Visible = false;
            }
            else
            {
                NoGiftWrapPanel.Visible = false;
                if (_WrapStyles.Count == 1)
                {
                    //ONE GIFT WRAP OPTION, OFF OR ON
                    MultiGiftWrapPanel.Visible = false;
                    AddGiftWrapStyleId.Value   = _WrapStyles[0].Id.ToString();
                    AddGiftWrapLabel.Text      = string.Format(AddGiftWrapLabel.Text, _WrapStyles[0].Name);
                    if (_WrapStyles[0].Price > 0)
                    {
                        decimal shopPrice = TaxHelper.GetShopPrice(_WrapStyles[0].Price, (_WrapStyles[0].TaxCode != null) ? _WrapStyles[0].TaxCode.Id : 0, null, this.ShipTaxAddress);
                        AddGiftWrapPrice.Text = string.Format(AddGiftWrapPrice.Text, shopPrice.LSCurrencyFormat("ulc"));
                    }
                    else
                    {
                        AddGiftWrapPrice.Visible = false;
                    }
                    if (!String.IsNullOrEmpty(_WrapStyles[0].ThumbnailUrl))
                    {
                        string imageUrl = this.Page.ResolveUrl(_WrapStyles[0].ThumbnailUrl);
                        OneGiftWrapThumbnail.ImageUrl = imageUrl;

                        if (!String.IsNullOrEmpty(imageUrl))
                        {
                            string popup = AbleCommerce.Code.PageHelper.GetPopUpScript(this.Page.ResolveUrl(_WrapStyles[0].ImageUrl), "giftwrapimage", 300, 300);
                            OneGiftWrapThumbnailLink.Attributes.Add("onclick", popup);
                            OneGiftWrapThumbnailLink.Attributes.Add("href", "#");
                        }
                    }
                    else
                    {
                        trGiftWrapImage.Visible = false;
                    }
                }
                else
                {
                    OneGiftWrapPanel.Visible = false;
                    BuildWrapStyleList();
                }
            }
        }
Пример #3
0
        protected List <ListItem> GetShipMethodList(BasketShipment shipment, bool forceRecalcualte)
        {
            List <ListItem> methodList  = new List <ListItem>();
            bool            hasSelected = false;

            if (shipment != null)
            {
                IShipRateQuoteCalculator  shippingCalculator = AbleContext.Resolve <IShipRateQuoteCalculator>();
                List <LocalShipRateQuote> localQuotes        = null;
                _SavedShipRates.TryGetValue(shipment.Id, out localQuotes);
                if (forceRecalcualte || localQuotes == null)
                {
                    //RECALCULATE THE RATES
                    localQuotes = new List <LocalShipRateQuote>();
                    ICollection <ShipRateQuote> rateQuotes = shippingCalculator.QuoteForShipment(shipment);
                    foreach (ShipRateQuote quote in rateQuotes)
                    {
                        decimal totalRate     = TaxHelper.GetShopPrice(quote.TotalRate, quote.ShipMethod.TaxCodeId, null, new TaxAddress(shipment.Address));
                        string  formattedRate = totalRate.LSCurrencyFormat("ulc");
                        string  methodName    = (totalRate > 0) ? quote.Name + ": " + formattedRate : quote.Name;
                        localQuotes.Add(new LocalShipRateQuote(quote.ShipMethodId, methodName, formattedRate));
                    }
                    _SavedShipRates[shipment.Id] = localQuotes;
                }

                foreach (LocalShipRateQuote quote in localQuotes)
                {
                    ListItem item = new ListItem(quote.Name, quote.ShipMethodId.ToString());
                    if (shipment.ShipMethodId != 0 && shipment.ShipMethodId == quote.ShipMethodId)
                    {
                        item.Selected = true;
                        hasSelected   = true;
                    }
                    methodList.Add(item);
                }

                if (!hasSelected)
                {
                    if (methodList.Count > 0)
                    {
                        methodList[0].Selected = true;
                        shipment.ShipMethodId  = AlwaysConvert.ToInt(methodList[0].Value);
                        shipment.Save();
                    }
                }
            }

            return(methodList);
        }
Пример #4
0
        protected string GetPrice(object dataItem)
        {
            //DETERMINE THE BASE PRICE OF THE ITEM
            WishlistItem item = (WishlistItem)dataItem;
            decimal      price;

            if (item.Product.IsSubscription && item.Product.SubscriptionPlan.IsOptional)
            {
                ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList, AbleContext.Current.UserId, false, !item.IsSubscription);
                price = c.Price;
            }
            else
            {
                if (item.Product.UseVariablePrice)
                {
                    price = AlwaysConvert.ToDecimal(item.Price);
                    if (price < item.Product.MinimumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MinimumPrice);
                    }
                    if (price > item.Product.MaximumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MaximumPrice);
                    }
                    item.Price = price;
                }
                else
                {
                    // ADD PRICE OF KIT PRODUCTS AS WELL
                    ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList);
                    price = c.Price;
                }
            }

            if (item.Product.VolumeDiscounts.Count > 0)
            {
                foreach (var rec in item.Product.VolumeDiscounts[0].Levels)
                {
                    if (item.Desired >= rec.MinValue && item.Desired <= rec.MaxValue)
                    {
                        return((rec.DiscountAmount).LSCurrencyFormat("ulc") + " ea.");
                    }
                }
            }

            decimal shopPrice = TaxHelper.GetShopPrice(price, item.Product.TaxCode != null ? item.Product.TaxCode.Id : 0);

            return(shopPrice > 0 ? shopPrice.LSCurrencyFormat("ulc") + " ea." : "");
        }
Пример #5
0
        public static string GetRecurringPaymentMessage(decimal productPrice, int taxCodeId, SubscriptionPlan sp, string paymentPeriod)
        {
            // GET THE PRICE WITH TAX
            decimal firstPaymentWithTax = TaxHelper.GetShopPrice(productPrice, taxCodeId);

            // DETERMINE RECURRING CHARGE WITH TAX
            decimal recurringPaymentWithTax;

            if (sp.RecurringChargeSpecified)
            {
                decimal recurringPayment = sp.RecurringChargeMode == InheritanceMode.Override ? sp.RecurringCharge : productPrice + sp.RecurringCharge;
                recurringPaymentWithTax = TaxHelper.GetShopPrice(recurringPayment, sp.RecurringTaxCode != null ? sp.RecurringTaxCode.Id : 0);
            }
            else
            {
                recurringPaymentWithTax = firstPaymentWithTax;
            }

            // DETERMINE WHETHER THERE IS A DIFFERENT FIRST AND RECURRING CHARGE
            if (firstPaymentWithTax != recurringPaymentWithTax)
            {
                // INITIAL CHARGE FOLLOWED BY ALTERNATE RECURRING AMOUNT
                if (sp.NumberOfPayments == 0)
                {
                    // PAYMENTS CONTINUE UNTIL CANCELLED
                    return(string.Format("First payment of <span class=\"priceDisplay\">{0}</span>, followed by a payment of <span class=\"priceDisplay\">{1}</span> charged {2} until cancelled.", firstPaymentWithTax.LSCurrencyFormat("ulc"), recurringPaymentWithTax.LSCurrencyFormat("ulc"), paymentPeriod));
                }
                else
                {
                    // A SET NUMBER OF PAYMENTS ARE MADE
                    return(string.Format("First payment of <span class=\"priceDisplay\">{0}</span>, followed by {1} payments of <span class=\"priceDisplay\">{2}</span> charged {3}.", firstPaymentWithTax.LSCurrencyFormat("ulc"), sp.NumberOfPayments - 1, recurringPaymentWithTax.LSCurrencyFormat("ulc"), paymentPeriod));
                }
            }
            else
            {
                if (sp.NumberOfPayments == 1)
                {
                    // ONE TIME CHARGE FOR A SUBSCRIPTION
                    return(string.Format("Subscription is valid for {0}", paymentPeriod));
                }
                else
                {
                    // DETERMINE IF PAYMENTS ARE OPEN ENDED OR A SET NUMBER
                    string paymentEnding = (sp.NumberOfPayments == 0 ? " until cancelled." : " for " + sp.NumberOfPayments + " payments.");
                    return(string.Format("Payment of <span class=\"priceDisplay\">{0}</span> charged {1}", firstPaymentWithTax.LSCurrencyFormat("ulc"), paymentPeriod) + paymentEnding);
                }
            }
        }
        protected string GetStyleName(Object dataItem)
        {
            WrapStyle style = (WrapStyle)dataItem;

            if (style.Price > 0)
            {
                //NAME WITH PRICE
                decimal shopPrice = TaxHelper.GetShopPrice(style.Price, (style.TaxCode != null) ? style.TaxCode.Id : 0, null, this.ShipTaxAddress);
                return(string.Format(_CostFormat, style.Name, shopPrice.LSCurrencyFormat("ulc")));
            }
            else
            {
                //JUST NAME
                return(string.Format(_FreeFormat, style.Name));
            }
        }
Пример #7
0
            protected string GetVariantPrice(string optionList)
            {
                ProductCalculator pcalc = null;

                if (!string.IsNullOrEmpty(optionList) && _showMSRP)
                {
                    pcalc = ProductCalculator.LoadForProduct(_ProductId, 1, optionList, string.Empty);
                    return(pcalc.MSRP.LSCurrencyFormat("ulc"));
                }
                else if (!string.IsNullOrEmpty(optionList))
                {
                    Product p = ProductDataSource.Load(_ProductId);
                    pcalc = ProductCalculator.LoadForProduct(_ProductId, 1, optionList, string.Empty);
                    return(TaxHelper.GetShopPrice(pcalc.Price, p.TaxCode != null ? p.TaxCode.Id : 0).LSCurrencyFormat("ulc"));
                }
                return("");
            }
        protected void ShipmentList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //SHOW SHIPPING METHODS
            DropDownList ShipMethodList = (DropDownList)e.Item.FindControl("ShipMethodList");

            if (ShipMethodList != null)
            {
                BasketShipment shipment = (BasketShipment)e.Item.DataItem;
                if (shipment != null)
                {
                    // CALCULATE THE SHIPPING RATES
                    ICollection <ShipRateQuote> rateQuotes = AbleContext.Resolve <IShipRateQuoteCalculator>().QuoteForShipment(shipment);
                    foreach (ShipRateQuote quote in rateQuotes)
                    {
                        decimal totalRate     = TaxHelper.GetShopPrice(quote.TotalRate, quote.ShipMethod.TaxCodeId, null, new TaxAddress(shipment.Address));
                        string  formattedRate = totalRate.LSCurrencyFormat("ulc");
                        string  methodName    = (totalRate > 0) ? quote.Name + ": " + formattedRate : quote.Name;
                        ShipMethodList.Items.Add(new ListItem(methodName, quote.ShipMethodId.ToString()));
                    }
                }
            }
        }
Пример #9
0
        protected string GetPrice(object dataItem)
        {
            //DETERMINE THE BASE PRICE OF THE ITEM
            WishlistItem item = (WishlistItem)dataItem;
            decimal      price;

            if (item.Product.IsSubscription && item.Product.SubscriptionPlan.IsOptional)
            {
                ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList, AbleContext.Current.UserId, false, !item.IsSubscription);
                price = c.Price;
            }
            else
            {
                if (item.Product.UseVariablePrice)
                {
                    price = AlwaysConvert.ToDecimal(item.Price);
                    if (price < item.Product.MinimumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MinimumPrice);
                    }
                    if (price > item.Product.MaximumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MaximumPrice);
                    }
                    item.Price = price;
                }
                else
                {
                    // ADD PRICE OF KIT PRODUCTS AS WELL
                    ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList);
                    price = c.Price;
                }
            }

            decimal shopPrice = TaxHelper.GetShopPrice(price, item.Product.TaxCode != null ? item.Product.TaxCode.Id : 0);

            return(shopPrice.LSCurrencyFormat("ulc"));
        }
Пример #10
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     PriceLiteral.Text = TaxHelper.GetShopPrice(_Price, _TaxCodeId).LSCurrencyFormat("ulc");
 }
Пример #11
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (_Product != null)
            {
                if (!_Product.UseVariablePrice || _Product.IsSubscription)
                {
                    if (_showQuoteOnZeroPrice && !(_Product.VolumeDiscounts.Any() && _Product.VolumeDiscounts[0].Levels.Any()))
                    {
                        if (_Product.Price == 0)
                        {
                            Price.Text = "Request a quote";
                            return;
                        }
                    }

                    if (_hideZeroPrice)
                    {
                        if (_Product.Price == 0 && _Product.ProductOptions.Count > 0)
                        {
                            this.Visible = false;
                            return;
                        }
                    }
                    // UPDATE THE INCLUDED KITPRODUCTS (Included-Hidden and Included-Shown)
                    if (_SelectedKitProducts.Count == 0 && this.EnableDefaultKitProducts)
                    {
                        UpdateIncludedKitOptions();
                    }
                    ProductCalculator pcalc = ProductCalculator.LoadForProduct(_Product.Id, 1, _OptionList, AlwaysConvert.ToList(",", _SelectedKitProducts), AbleContext.Current.UserId, true, this.CalculateOneTimePrice);

                    //IF REQUIRED MAKE ADJUSTMENTS TO DISPLAYED PRICE TO INCLUDE VAT
                    decimal basePriceWithVAT = TaxHelper.GetShopPrice(_Product.Price, (_Product.TaxCode != null) ? _Product.TaxCode.Id : 0);
                    decimal priceWithVAT     = pcalc.PriceWithTax;
                    decimal msrpWithVAT      = TaxHelper.GetShopPrice(_Product.MSRP, (_Product.TaxCode != null) ? _Product.TaxCode.Id : 0);
                    if (!_Product.HidePrice)
                    {
                        //PRICE IS VISIBLE, NO POPUP
                        phPricePopup.Visible = false;
                        //SHOW RETAIL PRICE IF INDICATED
                        if (_ShowRetailPrice && msrpWithVAT > 0 && !_Product.UseVariablePrice)
                        {
                            RetailPrice1.Text = string.Format(_RetailPriceFormat, msrpWithVAT.LSCurrencyFormat("ulc"));
                        }
                        else
                        {
                            RetailPrice1.Text = string.Empty;
                        }
                        //SHOW THE PRICE
                        if (pcalc.AppliedSpecial != null)
                        {
                            // SHOW THE BASE PRICE AND SPECIAL PRICE
                            RetailPrice1.Text = string.Format(_BasePriceFormat, basePriceWithVAT.LSCurrencyFormat("ulc"));
                            if (pcalc.AppliedSpecial.EndDate != DateTime.MinValue)
                            {
                                Price.Text = string.Format(_SpecialPriceFormat, priceWithVAT.LSCurrencyFormat("ulc"), pcalc.AppliedSpecial.EndDate);
                            }
                            else
                            {
                                Price.Text = string.Format(_SpecialPriceFormat2, priceWithVAT.LSCurrencyFormat("ulc"), null);
                            }
                        }
                        else
                        {
                            Price.Text = string.Format(_PriceFormat, priceWithVAT.LSCurrencyFormat("ulc"));
                        }
                    }
                    else
                    {
                        // HIDDEN PRICE, USE POPUP
                        Price.Visible    = false;
                        ProductName.Text = _Product.Name;
                        // THESE VARIABLES WILL TRACK SAVINGS OFF LISTED OR REGULAR PRICE
                        decimal amountSaved  = 0;
                        decimal percentSaved = 0;
                        // DETERMINE IF A SALE OR SPECIAL PRICE IS APPLIED
                        bool salePriceEffective = (pcalc.AppliedSpecial != null);
                        // DETERMINE IF MSRP IS AVAILABLE FOR DISPLAY
                        if (_ShowRetailPrice && msrpWithVAT > 0 && !salePriceEffective)
                        {
                            trRetailPrice.Visible       = true;
                            HiddenRetailPriceLabel.Text = PopupRetailPriceLabel;
                            HiddenRetailPrice.Text      = string.Format(PopupRetailPriceFormat, msrpWithVAT.LSCurrencyFormat("ulc"));
                            // CALCULATE AMOUNT SAVED OVER MSRP
                            amountSaved  = (msrpWithVAT - priceWithVAT);
                            percentSaved = ((decimal)(amountSaved / msrpWithVAT)) * 100;
                        }
                        else
                        {
                            trRetailPrice.Visible = false;
                        }
                        // CHECK IF A SALE PRICE IS APPLIED
                        if (salePriceEffective)
                        {
                            // SPECIAL APPLIED, SHOW THE PRODUCT BASE PRICE AND THE SPECIAL PRICE
                            trSpecialPrice.Visible = true;
                            HiddenPriceLabel.Text  = PopupBasePriceLabel;
                            HiddenPrice.Text       = string.Format(PopupBasePriceFormat, basePriceWithVAT.LSCurrencyFormat("ulc"));
                            SpecialPriceLabel.Text = PopupSpecialPriceLabel;
                            if (pcalc.AppliedSpecial.EndDate != DateTime.MinValue)
                            {
                                SpecialPrice.Text = string.Format(PopupSpecialPriceFormat, priceWithVAT.LSCurrencyFormat("ulc"), pcalc.AppliedSpecial.EndDate);
                            }
                            else
                            {
                                SpecialPrice.Text = string.Format(PopupSpecialPriceFormat2, priceWithVAT.LSCurrencyFormat("ulc"), null);
                            }
                            // CALCULATE AMOUNT SAVED WITH SALE PRICE
                            amountSaved  = (basePriceWithVAT - priceWithVAT);
                            percentSaved = ((decimal)(amountSaved / basePriceWithVAT)) * 100;
                        }
                        else
                        {
                            // NO SPECIAL, SO JUST SHOW THE CALCULATED PRICE
                            HiddenPriceLabel.Text = PopupPriceLabel;
                            HiddenPrice.Text      = string.Format(PopupPriceFormat, priceWithVAT.LSCurrencyFormat("ulc"));
                        }
                        // SEE IF WE HAVE AN AMOUNT SAVED VALUE
                        if (amountSaved > 0)
                        {
                            trAmountSaved.Visible = true;
                            AmountSavedLabel.Text = PopupAmountSavedLabel;
                            AmountSaved.Text      = string.Format(PopupAmountSavedFormat, amountSaved.LSCurrencyFormat("ulc"), percentSaved);
                        }
                        else
                        {
                            trAmountSaved.Visible = false;
                        }
                    }
                }
                else
                {
                    //DO NOT DISPLAY THIS CONTROL IF THE PRODUCT HAS VARIABLE PRICE
                    this.Controls.Clear();
                }
            }
            else
            {
                //DO NOT DISPLAY THIS CONTROL IF THE PRODUCT IS UNAVAILABLE
                this.Controls.Clear();
            }
            SaveCustomViewState();
        }
Пример #12
0
        private void Calculate()
        {
            Product product = ProductDataSource.Load(_ProductId);

            if (product != null)
            {
                if (string.IsNullOrEmpty(_OptionList))
                {
                    //NO VARIANT, SET VALUES FROM BASE PRODCUT
                    _Sku    = product.Sku;
                    _Price  = GetPriceFromRules(product);
                    _Weight = product.Weight;
                }
                else
                {
                    //VARIANT PRESENT, CHECK VARIANT FOR CORRECT VALUES
                    ProductVariant variant = ProductVariantDataSource.LoadForOptionList(_ProductId, _OptionList);
                    if (variant == null)
                    {
                        throw new InvalidOptionsException("The options specified for " + product.Name + " are invalid.");
                    }
                    _Sku = variant.Sku;
                    if (variant.Price != 0)
                    {
                        if (variant.PriceMode == ModifierMode.Modify)
                        {
                            _Price = GetPriceFromRules(product) + variant.Price;
                        }
                        else
                        {
                            _Price = variant.Price;
                        }
                    }
                    else
                    {
                        _Price = GetPriceFromRules(product);
                    }
                    if (variant.Weight != 0)
                    {
                        if (variant.WeightMode == ModifierMode.Modify)
                        {
                            _Weight = product.Weight + variant.Weight;
                        }
                        else
                        {
                            _Weight = variant.Weight;
                        }
                    }
                    else
                    {
                        _Weight = product.Weight;
                    }
                }

                // CALCULATE PRICE WITH TAX IF SPECIFIED
                if (_CalculateTax)
                {
                    _PriceWithTax = TaxHelper.GetShopPrice(_Price, product.TaxCodeId);
                }

                //CHECK FOR KIT PRODUCTS
                if (_KitProductIds != null)
                {
                    foreach (int kitProductId in _KitProductIds)
                    {
                        KitProduct kp = KitProductDataSource.Load(kitProductId);
                        if (kp != null)
                        {
                            _Price  += kp.CalculatedPrice;
                            _Weight += kp.CalculatedWeight;

                            // CALCULATE PRICE WITH TAX IF SPECIFIED
                            if (_CalculateTax)
                            {
                                int          taxCodeId = 0;
                                KitComponent component = kp.KitComponent;
                                if (component.InputType == KitInputType.IncludedHidden)
                                {
                                    taxCodeId = product.TaxCodeId;
                                }
                                else if (kp.Product != null)
                                {
                                    taxCodeId = kp.Product.TaxCodeId;
                                }
                                _PriceWithTax += TaxHelper.GetShopPrice(kp.CalculatedPrice, taxCodeId);
                            }
                        }
                    }
                }
                _Calculated = true;
            }
        }
Пример #13
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (_Product != null)
     {
         if (!_Product.UseVariablePrice)
         {
             // UPDATE THE INCLUDED KITPRODUCTS (Included-Hidden and Included-Shown)
             string kitList = string.Empty;
             if (_SelectedKitProducts == null || _SelectedKitProducts.Count == 0)
             {
                 UpdateIncludedKitOptions();
                 kitList = AlwaysConvert.ToList(",", _SelectedKitProducts.ToArray());
             }
             ProductCalculator pcalc = ProductCalculator.LoadForProduct(_Product.Id, 1, _OptionList, kitList, 0);
             //IF REQUIRED MAKE ADJUSTMENTS TO DISPLAYED PRICE TO INCLUDE VAT
             decimal basePriceWithVAT = TaxHelper.GetShopPrice(_Product.Price, (_Product.TaxCode != null ? _Product.TaxCode.Id : 0));
             decimal priceWithVAT     = TaxHelper.GetShopPrice(pcalc.Price, (_Product.TaxCode != null ? _Product.TaxCode.Id : 0));
             decimal msrpWithVAT      = TaxHelper.GetShopPrice(_Product.MSRP, (_Product.TaxCode != null ? _Product.TaxCode.Id : 0));
             if (!_Product.HidePrice)
             {
                 //PRICE IS VISIBLE, NO POPUP
                 phPricePopup.Visible = false;
                 //SHOW RETAIL PRICE IF INDICATED
                 if (_ShowRetailPrice && msrpWithVAT > 0 && !_Product.UseVariablePrice)
                 {
                     RetailPrice1.Text = string.Format(_RetailPriceFormat, msrpWithVAT.LSCurrencyFormat("lc"));
                 }
                 else
                 {
                     RetailPrice1.Text = string.Empty;
                 }
                 //SHOW THE PRICE
                 if (pcalc.AppliedSpecial != null && pcalc.AppliedSpecial.EndDate != DateTime.MinValue)
                 {
                     // SHOW THE BASE PRICE AND SPECIAL PRICE
                     RetailPrice1.Text = string.Format(_BasePriceFormat, basePriceWithVAT.LSCurrencyFormat("lc"));
                     Price.Text        = string.Format(_SpecialPriceFormat, priceWithVAT.LSCurrencyFormat("lc"), pcalc.AppliedSpecial.EndDate);
                 }
                 else
                 {
                     Price.Text = string.Format(_PriceFormat, priceWithVAT.LSCurrencyFormat("lc"));
                 }
             }
             else
             {
                 // HIDDEN PRICE, USE POPUP
                 Price.Visible    = false;
                 ProductName.Text = _Product.Name;
                 // THESE VARIABLES WILL TRACK SAVINGS OFF LISTED OR REGULAR PRICE
                 decimal amountSaved  = 0;
                 decimal percentSaved = 0;
                 // DETERMINE IF A SALE OR SPECIAL PRICE IS APPLIED
                 bool salePriceEffective = (pcalc.AppliedSpecial != null && pcalc.AppliedSpecial.EndDate != DateTime.MinValue);
                 // DETERMINE IF MSRP IS AVAILABLE FOR DISPLAY
                 if (_ShowRetailPrice && msrpWithVAT > 0 && !salePriceEffective)
                 {
                     trRetailPrice.Visible       = true;
                     HiddenRetailPriceLabel.Text = PopupRetailPriceLabel;
                     HiddenRetailPrice.Text      = string.Format(PopupRetailPriceFormat, msrpWithVAT.LSCurrencyFormat("lc"));
                     // CALCULATE AMOUNT SAVED OVER MSRP
                     amountSaved  = (msrpWithVAT - priceWithVAT);
                     percentSaved = ((decimal)(amountSaved / msrpWithVAT)) * 100;
                 }
                 else
                 {
                     trRetailPrice.Visible = false;
                 }
                 // CHECK IF A SALE PRICE IS APPLIED
                 if (salePriceEffective)
                 {
                     // SPECIAL APPLIED, SHOW THE PRODUCT BASE PRICE AND THE SPECIAL PRICE
                     trSpecialPrice.Visible = true;
                     HiddenPriceLabel.Text  = PopupBasePriceLabel;
                     HiddenPrice.Text       = string.Format(PopupBasePriceFormat, basePriceWithVAT.LSCurrencyFormat("lc"));
                     SpecialPriceLabel.Text = PopupSpecialPriceLabel;
                     SpecialPrice.Text      = string.Format(PopupSpecialPriceFormat, priceWithVAT.LSCurrencyFormat("lc"), pcalc.AppliedSpecial.EndDate);
                     // CALCULATE AMOUNT SAVED WITH SALE PRICE
                     amountSaved  = (basePriceWithVAT - priceWithVAT);
                     percentSaved = ((decimal)(amountSaved / basePriceWithVAT)) * 100;
                 }
                 else
                 {
                     // NO SPECIAL, SO JUST SHOW THE CALCULATED PRICE
                     HiddenPriceLabel.Text = PopupPriceLabel;
                     HiddenPrice.Text      = string.Format(PopupPriceFormat, priceWithVAT.LSCurrencyFormat("lc"));
                 }
                 // SEE IF WE HAVE AN AMOUNT SAVED VALUE
                 if (amountSaved > 0)
                 {
                     trAmountSaved.Visible = true;
                     AmountSavedLabel.Text = PopupAmountSavedLabel;
                     AmountSaved.Text      = string.Format(PopupAmountSavedFormat, amountSaved.LSCurrencyFormat("lc"), percentSaved);
                 }
                 else
                 {
                     trAmountSaved.Visible = false;
                 }
                 //DO NOT GIVE ADD BUTTON FOR KITTED PRODUCTS
                 //AddToCartButton.Visible = (_Product.KitStatus != KitStatus.Master);
             }
         }
         else
         {
             //DO NOT DISPLAY THIS CONTROL IF THE PRODUCT HAS VARIABLE PRICE
             this.Controls.Clear();
             Label lbl = new Label();
             lbl.Text = "Variable";
             this.Controls.Add(lbl);
         }
     }
     else
     {
         //DO NOT DISPLAY THIS CONTROL IF THE PRODUCT IS UNAVAILABLE
         this.Controls.Clear();
     }
     SaveCustomViewState();
 }
Пример #14
0
 protected decimal GetItemShopPrice(BasketItem item)
 {
     return(TaxHelper.GetShopPrice(item.Basket, item));
 }