public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { var sb = new StringBuilder(); decimal shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, true)); decimal shoppingCartItemSubTotalWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append("<span class=\"productPrice\">"); sb.Append(subTotalString); sb.Append("</span>"); decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem)); if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); sb.Append(GetLocaleResourceString("Wishlist.ItemYouSave")); sb.Append(" "); sb.Append(discountString); } return(sb.ToString()); }
private void BindData() { GiftCard gc = OrderManager.GetGiftCardById(this.GiftCardId); if (gc != null) { this.lblOrder.Text = string.Format("<a href=\"OrderDetails.aspx?OrderID={0}\">{1}</a>", gc.PurchasedOrderProductVariant.OrderId, GetLocaleResourceString("Admin.GiftCardInfo.Order.View")); this.lblCustomer.Text = string.Format("<a href=\"CustomerDetails.aspx?CustomerID={0}\">{1}</a>", gc.PurchasedOrderProductVariant.Order.CustomerId, GetLocaleResourceString("Admin.GiftCardInfo.Customer.View")); this.txtInitialValue.Value = GiftCardHelper.GetGiftCardInitialValue(gc); decimal remainingAmount = GiftCardHelper.GetGiftCardRemainingAmount(gc); this.lblRemainingAmount.Text = PriceHelper.FormatPrice(remainingAmount, true, false); this.cbIsGiftCardActivated.Checked = gc.IsGiftCardActivated; this.txtCouponCode.Text = gc.GiftCardCouponCode; this.txtRecipientName.Text = gc.RecipientName; this.txtRecipientEmail.Text = gc.RecipientEmail; this.txtSenderName.Text = gc.SenderName; this.txtSenderEmail.Text = gc.SenderEmail; this.txtMessage.Text = gc.Message; if (gc.IsRecipientNotified) { lblIsRecipientNotified.Text = GetLocaleResourceString("Admin.Common.Yes"); } else { lblIsRecipientNotified.Text = GetLocaleResourceString("Admin.Common.No"); } this.lblPurchasedOn.Text = DateTimeHelper.ConvertToUserTime(gc.CreatedOn).ToString(); } else { Response.Redirect("PurchasedGiftCards.aspx"); } }
protected string GetInitialValueInfo(GiftCard gc) { decimal initialValue = GiftCardHelper.GetGiftCardInitialValue(gc); string result = PriceHelper.FormatPrice(initialValue, true, false); return(result); }
public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), customer); decimal shoppingCartItemSubTotalWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append(subTotalString); decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem, customer), customer); if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); //sb.Append(GetLocaleResourceString("ShoppingCart.ItemYouSave")); sb.Append("Saved:"); sb.Append(" "); sb.Append(discountString); sb.Append("<br />"); sb.Append("<em>NOTE: This discount is applied to the current user</em>"); } return(sb.ToString()); }
protected string GetRemainingAmountInfo(GiftCard gc) { decimal remainingAmount = GiftCardHelper.GetGiftCardRemainingAmount(gc); string result = PriceHelper.FormatPrice(remainingAmount, true, false); return(result); }
public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal taxRate = decimal.Zero; decimal shoppingCartItemSubTotalWithDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), customer, out taxRate); decimal shoppingCartItemSubTotalWithDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append(subTotalString); decimal shoppingCartItemDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem, customer), customer, out taxRate); if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); //sb.Append(GetLocaleResourceString("ShoppingCart.ItemYouSave")); sb.Append("Saved:"); sb.Append(" "); sb.Append(discountString); } return(sb.ToString()); }
protected void ddlVariantPrice_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var productVariant = e.Item.DataItem as ProductVariant; var lblPriceDisplay = e.Item.FindControl("lblPriceDisplay") as Label; var lblPrice = e.Item.FindControl("lblPrice") as Label; var imgBuyNow = e.Item.FindControl("imgBuyNow") as ImageButton; if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { if (productVariant.CustomerEntersPrice) { int minimumCustomerEnteredPrice = Convert.ToInt32(Math.Ceiling(CurrencyManager.ConvertCurrency(productVariant.MinimumCustomerEnteredPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency))); lblPrice.Text = minimumCustomerEnteredPrice.ToString(); lblPriceDisplay.Text = PriceHelper.FormatPrice(minimumCustomerEnteredPrice); } else { decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPrice.Text = fromPrice.ToString(); lblPriceDisplay.Text = PriceHelper.FormatPrice(fromPrice); } } else { lblPriceDisplay.Visible = false; btnAddToCart.Visible = false; } } }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, customer, true), customer); decimal shoppingCartUnitPriceWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); sb.Append(unitPriceString); return(sb.ToString()); }
private void BindData() { ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID); if (productVariant != null) { decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice); decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal finalPriceWithDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true)); decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); decimal finalPriceWithDiscount = CurrencyManager.ConvertCurrency(finalPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero) { lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice); lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount); phOldPrice.Visible = true; } else { lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount); phOldPrice.Visible = false; } if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase) { lblFinalPriceWithDiscount.Text = PriceHelper.FormatPrice(finalPriceWithDiscount); phDiscount.Visible = true; } else { phDiscount.Visible = false; } if (phDiscount.Visible) { lblPriceValue.CssClass = string.Empty; } else { lblPriceValue.CssClass = "productPrice"; } if (phDiscount.Visible || phOldPrice.Visible) { lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount"); } } else { this.Visible = false; } }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal taxRate = decimal.Zero; decimal shoppingCartUnitPriceWithDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, customer, true), customer, out taxRate); decimal shoppingCartUnitPriceWithDiscount = this.CurrencyService.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); sb.Append(unitPriceString); return(sb.ToString()); }
protected void rptrGiftCards_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { var giftCardUsageHistory = e.Item.DataItem as GiftCardUsageHistory; var lGiftCard = e.Item.FindControl("lGiftCard") as Literal; lGiftCard.Text = String.Format(GetLocaleResourceString("Order.GiftCardInfo"), Server.HtmlEncode(giftCardUsageHistory.GiftCard.GiftCardCouponCode)); var lblGiftCardAmount = e.Item.FindControl("lblGiftCardAmount") as Label; lblGiftCardAmount.Text = PriceHelper.FormatPrice(-giftCardUsageHistory.UsedValueInCustomerCurrency, true, order.CustomerCurrencyCode, false); } }
protected void rptrTaxRates_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { var item = (KeyValuePair <decimal, decimal>)e.Item.DataItem; var lTaxRateTitle = e.Item.FindControl("lTaxRateTitle") as Literal; lTaxRateTitle.Text = String.Format(GetLocaleResourceString("Order.Totals.TaxRate"), TaxManager.FormatTaxRate(item.Key)); var lTaxRateValue = e.Item.FindControl("lTaxRateValue") as Literal; lTaxRateValue.Text = PriceHelper.FormatPrice(item.Value, true, false); } }
protected void rptrTaxRates_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { var item = (KeyValuePair <decimal, decimal>)e.Item.DataItem; var lTaxRateTitle = e.Item.FindControl("lTaxRateTitle") as Literal; lTaxRateTitle.Text = String.Format(GetLocaleResourceString("ShoppingCart.Totals.TaxRate"), TaxManager.FormatTaxRate(item.Key)); var lTaxRateValue = e.Item.FindControl("lTaxRateValue") as Literal; decimal taxValue = CurrencyManager.ConvertCurrency(item.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lTaxRateValue.Text = PriceHelper.FormatPrice(taxValue, true, false); } }
/// <summary> /// Formats attributes /// </summary> /// <param name="productVariant">Product variant</param> /// <param name="Attributes">Attributes</param> /// <param name="customer">Customer</param> /// <param name="Serapator">Serapator</param> /// <param name="HTMLEncode">A value indicating whether to encode (HTML) values</param> /// <returns>Attributes</returns> public static string FormatAttributes(ProductVariant productVariant, string Attributes, Customer customer, string Serapator, bool HTMLEncode) { StringBuilder result = new StringBuilder(); ProductVariantAttributeCollection pvaCollection = ParseProductVariantAttributes(Attributes); foreach (ProductVariantAttribute pva in pvaCollection) { List <string> valuesStr = ParseValues(Attributes, pva.ProductVariantAttributeID); foreach (string valueStr in valuesStr) { string pvaAttribute = string.Empty; if (!pva.ShouldHaveValues) { pvaAttribute = string.Format("{0}: {1}", pva.ProductAttribute.Name, valueStr); } else { ProductVariantAttributeValue pvaValue = ProductAttributeManager.GetProductVariantAttributeValueByID(Convert.ToInt32(valueStr)); if (pvaValue != null) { pvaAttribute = string.Format("{0}: {1}", pva.ProductAttribute.Name, pvaValue.Name); decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment, customer); decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > 0) { string priceAdjustmentStr = PriceHelper.FormatPrice(priceAdjustment, false, false); pvaAttribute += string.Format(" [+{0}]", priceAdjustmentStr); } } } if (!String.IsNullOrEmpty(pvaAttribute)) { result.Append(Serapator); if (HTMLEncode) { result.Append(HttpUtility.HtmlEncode(pvaAttribute)); } else { result.Append(pvaAttribute); } } } } return(result.ToString()); }
protected string GetOrderSubtotal(ShoppingCart shoppingCart) { decimal subtotalBase = decimal.Zero; string SubTotalError = ShoppingCartManager.GetShoppingCartSubTotal(shoppingCart, NopContext.Current.User, out subtotalBase); if (String.IsNullOrEmpty(SubTotalError)) { decimal subTotal = CurrencyManager.ConvertCurrency(subtotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); return(PriceHelper.FormatPrice(subTotal)); } else { return(GetLocaleResourceString("MiniShoppingCartBox.OrderSubtotal.CalculatedDuringCheckout")); } }
private void BindData() { //pending decimal os_pendingTotalSum = decimal.Zero; int os_pendingCount = 0; using (IDataReader orders_os_pending = OrderManager.GetOrderReport(OrderStatusEnum.Pending, null, null)) { while (orders_os_pending.Read()) { os_pendingTotalSum = NopSqlDataHelper.GetDecimal(orders_os_pending, "Total"); os_pendingCount = NopSqlDataHelper.GetInt(orders_os_pending, "Count"); } lblTotalIncomplete.Text = os_pendingCount.ToString(); lblTotalIncompleteValue.Text = PriceHelper.FormatPrice(os_pendingTotalSum, true, false); } //not paid decimal ps_pendingTotalSum = decimal.Zero; int ps_pendingCount = 0; using (IDataReader orders_ps_pending = OrderManager.GetOrderReport(null, PaymentStatusEnum.Pending, null)) { while (orders_ps_pending.Read()) { ps_pendingTotalSum = NopSqlDataHelper.GetDecimal(orders_ps_pending, "Total"); ps_pendingCount = NopSqlDataHelper.GetInt(orders_ps_pending, "Count"); } lblTotalUnpaid.Text = ps_pendingCount.ToString(); lblTotalUnpaidValue.Text = PriceHelper.FormatPrice(ps_pendingTotalSum, true, false); } //not shipped decimal ss_pendingTotalSum = decimal.Zero; int ss_pendingCount = 0; using (IDataReader orders_ss_pending = OrderManager.GetOrderReport(null, null, ShippingStatusEnum.NotYetShipped)) { while (orders_ss_pending.Read()) { ss_pendingTotalSum = NopSqlDataHelper.GetDecimal(orders_ss_pending, "Total"); ss_pendingCount = NopSqlDataHelper.GetInt(orders_ss_pending, "Count"); } lblTotalUnshipped.Text = ss_pendingCount.ToString(); lblTotalUnshippedValue.Text = PriceHelper.FormatPrice(ss_pendingTotalSum, true, false); } }
public string GetProductVariantSubTotal(OrderProductVariant orderProductVariant) { string result = string.Empty; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: result = PriceHelper.FormatPrice(orderProductVariant.PriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); break; case TaxDisplayTypeEnum.IncludingTax: result = PriceHelper.FormatPrice(orderProductVariant.PriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); break; } return(result); }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { StringBuilder sb = new StringBuilder(); decimal shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, true)); decimal shoppingCartUnitPriceWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { unitPriceString += "$"; } sb.Append("<span class=\"productPrice\">"); sb.Append(unitPriceString); sb.Append("</span>"); return(sb.ToString()); }
protected void lvTierPrices_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ListViewDataItem currentItem = (ListViewDataItem)e.Item; TierPrice tierPrice = currentItem.DataItem as TierPrice; ProductVariant productVariant = tierPrice.ProductVariant; Label lblQuantity = (Label)currentItem.FindControl("lblQuantity"); Label lblPrice = (Label)currentItem.FindControl("lblPrice"); decimal priceBase = TaxManager.GetPrice(productVariant, tierPrice.Price); decimal price = CurrencyManager.ConvertCurrency(priceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string priceStr = PriceHelper.FormatPrice(price, false, false); lblQuantity.Text = string.Format(GetLocaleResourceString("Products.TierPricesQuantityFormat"), tierPrice.Quantity); lblPrice.Text = priceStr; } }
protected void lvTierPrices_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { var currentItem = (ListViewDataItem)e.Item; var tierPrice = currentItem.DataItem as TierPrice; var productVariant = tierPrice.ProductVariant; var lblQuantity = (Label)currentItem.FindControl("lblQuantity"); var lblPrice = (Label)currentItem.FindControl("lblPrice"); decimal taxRate = decimal.Zero; decimal priceBase = this.TaxService.GetPrice(productVariant, tierPrice.Price, out taxRate); decimal price = this.CurrencyService.ConvertCurrency(priceBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string priceStr = PriceHelper.FormatPrice(price, false, false); lblQuantity.Text = string.Format(GetLocaleResourceString("Products.TierPricesQuantityFormat"), tierPrice.Quantity); lblPrice.Text = priceStr; } }
private void BindData() { //pending var orders_os_pending = OrderManager.GetOrderReport(OrderStatusEnum.Pending, null, null); lblTotalIncomplete.Text = orders_os_pending.Count.ToString(); lblTotalIncompleteValue.Text = PriceHelper.FormatPrice(orders_os_pending.Total, true, false); //not paid var orders_ps_pending = OrderManager.GetOrderReport(null, PaymentStatusEnum.Pending, null); lblTotalUnpaid.Text = orders_ps_pending.Count.ToString(); lblTotalUnpaidValue.Text = PriceHelper.FormatPrice(orders_ps_pending.Total, true, false); //not shipped var orders_ss_pending = OrderManager.GetOrderReport(null, null, ShippingStatusEnum.NotYetShipped); lblTotalUnshipped.Text = orders_ss_pending.Count.ToString(); lblTotalUnshippedValue.Text = PriceHelper.FormatPrice(orders_ss_pending.Total, true, false); }
public string GetOrderProductVariantSubTotal(OrderProductVariant orderProductVariant) { string result = string.Empty; Order order = orderProductVariant.Order; if (TaxManager.AllowCustomersToSelectTaxDisplayType) { string subTotalInclTaxStr = PriceHelper.FormatPrice(orderProductVariant.PriceInclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, true, true); string subTotalExclTaxStr = PriceHelper.FormatPrice(orderProductVariant.PriceExclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, false, true); result = subTotalInclTaxStr; result += "<br />"; result += subTotalExclTaxStr; } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string subTotalExclTaxStr = PriceHelper.FormatPrice(orderProductVariant.PriceExclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, false); result += subTotalExclTaxStr; } break; case TaxDisplayTypeEnum.IncludingTax: { string subTotalInclTaxStr = PriceHelper.FormatPrice(orderProductVariant.PriceInclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, true); result = subTotalInclTaxStr; } break; default: break; } } return(result); }
protected string GetOrderSubtotal(ShoppingCart shoppingCart) { decimal subtotalBase = decimal.Zero; decimal orderSubTotalDiscountAmount = decimal.Zero; Discount orderSubTotalAppliedDiscount = null; decimal subTotalWithoutDiscountBase = decimal.Zero; decimal subTotalWithDiscountBase = decimal.Zero; string SubTotalError = this.ShoppingCartService.GetShoppingCartSubTotal(shoppingCart, NopContext.Current.User, out orderSubTotalDiscountAmount, out orderSubTotalAppliedDiscount, out subTotalWithoutDiscountBase, out subTotalWithDiscountBase); subtotalBase = subTotalWithoutDiscountBase; if (String.IsNullOrEmpty(SubTotalError)) { decimal subTotal = this.CurrencyService.ConvertCurrency(subtotalBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); return(PriceHelper.FormatPrice(subTotal)); } else { return(GetLocaleResourceString("MiniShoppingCartBox.OrderSubtotal.CalculatedDuringCheckout")); } }
protected string getPriceRangeString(decimal?From, decimal?To) { string result = string.Empty; if (!From.HasValue) { string toString = PriceHelper.FormatPrice(To.Value, true, false); result = string.Format(GetLocaleResourceString("Common.PriceRangeFilter.Under"), string.Format("<span class=\"{0}\">{1}</span>", PRICE_CSSCLASSNAME, toString)); } else if (!To.HasValue) { string fromString = PriceHelper.FormatPrice(From.Value, true, false); result = string.Format(GetLocaleResourceString("Common.PriceRangeFilter.Over"), string.Format("<span class=\"{0}\">{1}</span>", PRICE_CSSCLASSNAME, fromString)); } else { string fromString = PriceHelper.FormatPrice(From.Value, true, false); string toString = PriceHelper.FormatPrice(To.Value, true, false); result = string.Format("<span class=\"{0}\">{1}</span> - <span class=\"{0}\">{2}</span>", PRICE_CSSCLASSNAME, fromString, toString); } return(result); }
protected void rptrGiftCards_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { var appliedGiftCard = e.Item.DataItem as AppliedGiftCard; var lGiftCard = e.Item.FindControl("lGiftCard") as Literal; lGiftCard.Text = String.Format(GetLocaleResourceString("ShoppingCart.Totals.GiftCardInfo"), Server.HtmlEncode(appliedGiftCard.GiftCard.GiftCardCouponCode)); var lblGiftCardAmount = e.Item.FindControl("lblGiftCardAmount") as Label; decimal amountCanBeUsed = CurrencyManager.ConvertCurrency(appliedGiftCard.AmountCanBeUsed, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblGiftCardAmount.Text = PriceHelper.FormatPrice(-amountCanBeUsed, true, false); var lGiftCardRemaining = e.Item.FindControl("lGiftCardRemaining") as Literal; decimal remainingAmountBase = GiftCardHelper.GetGiftCardRemainingAmount(appliedGiftCard.GiftCard) - appliedGiftCard.AmountCanBeUsed; decimal remainingAmount = CurrencyManager.ConvertCurrency(remainingAmountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lGiftCardRemaining.Text = string.Format(GetLocaleResourceString("ShoppingCart.Totals.GiftCardInfo.Remaining"), PriceHelper.FormatPrice(remainingAmount, true, false)); var btnRemoveGC = e.Item.FindControl("btnRemoveGC") as LinkButton; btnRemoveGC.Visible = this.IsShoppingCart; } }
public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem) { var sb = new StringBuilder(); if (shoppingCartItem.ProductVariant.CallForPrice) { sb.Append("<span class=\"productPrice\">"); sb.Append(GetLocaleResourceString("Products.CallForPrice")); sb.Append("</span>"); } else { decimal taxRate = decimal.Zero; decimal shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, true), out taxRate); decimal shoppingCartUnitPriceWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount); sb.Append("<span class=\"productPrice\">"); sb.Append(unitPriceString); sb.Append("</span>"); } return(sb.ToString()); }
protected string GetShoppingCartSum() { ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); bool isUsd = Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD"; decimal indOrderTotal = 0; IndividualOrderCollection indOrders = new IndividualOrderCollection(); if (NopContext.Current.Session != null) { Guid customerSessionGuid = NopContext.Current.Session.CustomerSessionGUID; indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGuid); indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (isUsd) { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (cart.Count > 0 || indOrders.Count > 0) { //subtotal string subTotalError = string.Empty; decimal shoppingCartSubTotalDiscountBase; decimal shoppingCartSubTotalBase = ShoppingCartManager.GetShoppingCartSubTotal(cart, NopContext.Current.User, out shoppingCartSubTotalDiscountBase, ref subTotalError); if (String.IsNullOrEmpty(subTotalError)) { decimal shoppingCartSubTotal = CurrencyManager.ConvertCurrency(shoppingCartSubTotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shoppingCartSubTotal += indOrderTotal; return(AddCurrency(PriceHelper.FormatPrice(shoppingCartSubTotal), isUsd)); } } return(AddCurrency("0", isUsd)); }
public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem) { var sb = new StringBuilder(); if (shoppingCartItem.ProductVariant.CallForPrice) { sb.Append("<span class=\"productPrice\">"); sb.Append(GetLocaleResourceString("Products.CallForPrice")); sb.Append("</span>"); } else { //sub total decimal taxRate = decimal.Zero; decimal shoppingCartItemSubTotalWithDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, true), out taxRate); decimal shoppingCartItemSubTotalWithDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount); sb.Append("<span class=\"productPrice\">"); sb.Append(subTotalString); sb.Append("</span>"); //display an applied discount amount decimal shoppingCartItemSubTotalWithoutDiscountBase = this.TaxService.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, false), out taxRate); decimal shoppingCartItemDiscountBase = shoppingCartItemSubTotalWithoutDiscountBase - shoppingCartItemSubTotalWithDiscountBase; if (shoppingCartItemDiscountBase > decimal.Zero) { decimal shoppingCartItemDiscount = this.CurrencyService.ConvertCurrency(shoppingCartItemDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount); sb.Append("<br />"); sb.Append(GetLocaleResourceString("Wishlist.ItemYouSave")); sb.Append(" "); sb.Append(discountString); } } return(sb.ToString()); }
protected void CreateAttributeControls() { ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID); if (productVariant != null) { ProductVariantAttributeCollection productVariantAttributes = productVariant.ProductVariantAttributes; if (productVariantAttributes.Count > 0) { this.Visible = true; foreach (ProductVariantAttribute attribute in productVariantAttributes) { Panel divAttribute = new Panel(); Label attributeTitle = new Label(); if (attribute.IsRequired) { attributeTitle.Text = "<span>*</span> "; } //text prompt string textPrompt = string.Empty; if (!string.IsNullOrEmpty(attribute.TextPrompt)) { textPrompt = attribute.TextPrompt; } else { textPrompt += attribute.ProductAttribute.Name; } attributeTitle.Text += Server.HtmlEncode(textPrompt); attributeTitle.Style.Add("font-weight", "bold"); //description if (!string.IsNullOrEmpty(attribute.ProductAttribute.Description)) { attributeTitle.Text += string.Format("<div>{0}</div>", Server.HtmlEncode( attribute.ProductAttribute.Description)); } bool addBreak = true; switch (attribute.AttributeControlType) { case AttributeControlTypeEnum.TextBox: { addBreak = false; } break; default: break; } if (addBreak) { attributeTitle.Text += "<br />"; } else { attributeTitle.Text += " "; } divAttribute.Controls.Add(attributeTitle); switch (attribute.AttributeControlType) { case AttributeControlTypeEnum.DropdownList: { DropDownList ddlAttributes = new DropDownList(); ddlAttributes.ID = attribute.ProductAttribute.Name; if (!attribute.IsRequired) { ddlAttributes.Items.Add(new ListItem("---", "0")); } ProductVariantAttributeValueCollection pvaValues = attribute.ProductVariantAttributeValues; foreach (ProductVariantAttributeValue pvaValue in pvaValues) { string pvaValueName = pvaValue.Name; decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment); decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } ListItem pvaValueItem = new ListItem(pvaValueName, pvaValue.ProductVariantAttributeValueID.ToString()); pvaValueItem.Selected = pvaValue.IsPreSelected; ddlAttributes.Items.Add(pvaValueItem); } divAttribute.Controls.Add(ddlAttributes); } break; case AttributeControlTypeEnum.RadioList: { RadioButtonList rblAttributes = new RadioButtonList(); rblAttributes.ID = attribute.ProductAttribute.Name; ProductVariantAttributeValueCollection pvaValues = attribute.ProductVariantAttributeValues; foreach (ProductVariantAttributeValue pvaValue in pvaValues) { string pvaValueName = pvaValue.Name; decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment); decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } ListItem pvaValueItem = new ListItem(Server.HtmlEncode(pvaValueName), pvaValue.ProductVariantAttributeValueID.ToString()); pvaValueItem.Selected = pvaValue.IsPreSelected; rblAttributes.Items.Add(pvaValueItem); } divAttribute.Controls.Add(rblAttributes); } break; case AttributeControlTypeEnum.Checkboxes: { CheckBoxList cblAttributes = new CheckBoxList(); cblAttributes.ID = attribute.ProductAttribute.Name; ProductVariantAttributeValueCollection pvaValues = attribute.ProductVariantAttributeValues; foreach (ProductVariantAttributeValue pvaValue in pvaValues) { string pvaValueName = pvaValue.Name; decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment); decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (priceAdjustmentBase > decimal.Zero) { pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); } ListItem pvaValueItem = new ListItem(Server.HtmlEncode(pvaValueName), pvaValue.ProductVariantAttributeValueID.ToString()); pvaValueItem.Selected = pvaValue.IsPreSelected; cblAttributes.Items.Add(pvaValueItem); } divAttribute.Controls.Add(cblAttributes); } break; case AttributeControlTypeEnum.TextBox: { TextBox txtAttribute = new TextBox(); txtAttribute.ID = attribute.ProductAttribute.Name; divAttribute.Controls.Add(txtAttribute); } break; default: break; } phAttributes.Controls.Add(divAttribute); } } else { this.Visible = false; } } else { this.Visible = false; } }
protected void BindData() { this.lnkPrint.NavigateUrl = Page.ResolveUrl("~/PrintOrderDetails.aspx?OrderID=" + this.OrderId).ToLowerInvariant(); this.lblOrderId.Text = order.OrderId.ToString(); this.lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(order.CreatedOn).ToString("D"); this.lblOrderStatus.Text = OrderManager.GetOrderStatusName(order.OrderStatusId); btnReOrder.Visible = OrderManager.IsReOrderAllowed; if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { this.pnlShipping.Visible = true; this.lShippingFirstName.Text = Server.HtmlEncode(order.ShippingFirstName); this.lShippingLastName.Text = Server.HtmlEncode(order.ShippingLastName); this.lShippingPhoneNumber.Text = Server.HtmlEncode(order.ShippingPhoneNumber); this.lShippingEmail.Text = Server.HtmlEncode(order.ShippingEmail); this.lShippingFaxNumber.Text = Server.HtmlEncode(order.ShippingFaxNumber); if (!String.IsNullOrEmpty(order.ShippingCompany)) { this.lShippingCompany.Text = Server.HtmlEncode(order.ShippingCompany); } else { pnlShippingCompany.Visible = false; } this.lShippingAddress1.Text = Server.HtmlEncode(order.ShippingAddress1); if (!String.IsNullOrEmpty(order.ShippingAddress2)) { this.lShippingAddress2.Text = Server.HtmlEncode(order.ShippingAddress2); } else { pnlShippingAddress2.Visible = false; } this.lShippingCity.Text = Server.HtmlEncode(order.ShippingCity); this.lShippingStateProvince.Text = Server.HtmlEncode(order.ShippingStateProvince); this.lShippingZipPostalCode.Text = Server.HtmlEncode(order.ShippingZipPostalCode); if (!String.IsNullOrEmpty(order.ShippingCountry)) { this.lShippingCountry.Text = Server.HtmlEncode(order.ShippingCountry); } else { pnlShippingCountry.Visible = false; } this.lblShippingMethod.Text = Server.HtmlEncode(order.ShippingMethod); this.lblOrderWeight.Text = string.Format("{0} [{1}]", order.OrderWeight, MeasureManager.BaseWeightIn.Name); if (order.ShippedDate.HasValue) { this.lblShippedDate.Text = DateTimeHelper.ConvertToUserTime(order.ShippedDate.Value).ToString("D"); } else { this.lblShippedDate.Text = GetLocaleResourceString("Order.NotYetShipped"); } if (order.DeliveryDate.HasValue) { this.lblDeliveredOn.Text = DateTimeHelper.ConvertToUserTime(order.DeliveryDate.Value).ToString("D"); } else { this.lblDeliveredOn.Text = GetLocaleResourceString("Order.Order.NotYetDelivered"); } if (!string.IsNullOrEmpty(order.TrackingNumber)) { lblTrackingNumber.Text = order.TrackingNumber; pnlTrackingNumber.Visible = true; } else { pnlTrackingNumber.Visible = false; } this.pnlShippingTotal.Visible = true; } else { this.pnlShipping.Visible = false; this.pnlShippingTotal.Visible = false; } this.lBillingFirstName.Text = Server.HtmlEncode(order.BillingFirstName); this.lBillingLastName.Text = Server.HtmlEncode(order.BillingLastName); this.lBillingPhoneNumber.Text = Server.HtmlEncode(order.BillingPhoneNumber); this.lBillingEmail.Text = Server.HtmlEncode(order.BillingEmail); this.lBillingFaxNumber.Text = Server.HtmlEncode(order.BillingFaxNumber); if (!String.IsNullOrEmpty(order.BillingCompany)) { this.lBillingCompany.Text = Server.HtmlEncode(order.BillingCompany); } else { pnlBillingCompany.Visible = false; } this.lBillingAddress1.Text = Server.HtmlEncode(order.BillingAddress1); if (!String.IsNullOrEmpty(order.BillingAddress2)) { this.lBillingAddress2.Text = Server.HtmlEncode(order.BillingAddress2); } else { pnlBillingAddress2.Visible = false; } this.lBillingCity.Text = Server.HtmlEncode(order.BillingCity); this.lBillingStateProvince.Text = Server.HtmlEncode(order.BillingStateProvince); this.lBillingZipPostalCode.Text = Server.HtmlEncode(order.BillingZipPostalCode); if (!String.IsNullOrEmpty(order.BillingCountry)) { this.lBillingCountry.Text = Server.HtmlEncode(order.BillingCountry); } else { pnlBillingCountry.Visible = false; } var paymentMethod = PaymentMethodManager.GetPaymentMethodById(order.PaymentMethodId); if (paymentMethod != null) { this.lPaymentMethod.Text = paymentMethod.VisibleName; } else { this.lPaymentMethod.Text = order.PaymentMethodName; } switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblOrderSubtotal.Text = PriceHelper.FormatPrice(order.OrderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); this.lblOrderShipping.Text = PriceHelper.FormatShippingPrice(order.OrderShippingExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); this.lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblOrderSubtotal.Text = PriceHelper.FormatPrice(order.OrderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); this.lblOrderShipping.Text = PriceHelper.FormatShippingPrice(order.OrderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); this.lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); } break; } bool displayPaymentMethodFee = true; if (order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency == decimal.Zero) { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; //discount if (order.OrderDiscountInCustomerCurrency > decimal.Zero) { phDiscount.Visible = true; string discountStr = PriceHelper.FormatPrice(-order.OrderDiscountInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblDiscount.Text = discountStr; } else { phDiscount.Visible = false; } //tax bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { if (order.OrderTax == 0 && TaxManager.HideZeroTax) { displayTax = false; } else { string taxStr = PriceHelper.FormatPrice(order.OrderTaxInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblOrderTax.Text = taxStr; } } phTaxTotal.Visible = displayTax; //gift cards var gcuhC = OrderManager.GetAllGiftCardUsageHistoryEntries(null, null, order.OrderId); if (gcuhC.Count > 0) { rptrGiftCards.Visible = true; rptrGiftCards.DataSource = gcuhC; rptrGiftCards.DataBind(); } else { rptrGiftCards.Visible = false; } //reward points if (order.RedeemedRewardPoints != null) { phRewardPoints.Visible = true; lRewardPointsTitle.Text = string.Format(GetLocaleResourceString("Order.Totals.RewardPoints"), -order.RedeemedRewardPoints.Points); lblRewardPointsAmount.Text = PriceHelper.FormatPrice(-order.RedeemedRewardPoints.UsedAmountInCustomerCurrency, true, order.CustomerCurrencyCode, false); } else { phRewardPoints.Visible = false; } //total string orderTotalStr = PriceHelper.FormatPrice(order.OrderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblOrderTotal.Text = orderTotalStr; this.lblOrderTotal2.Text = orderTotalStr; //purchased products var orderProductVariants = order.OrderProductVariants; bool hasDownloadableItems = false; foreach (var orderProductVariant in orderProductVariants) { var productVariant = orderProductVariant.ProductVariant; if (productVariant != null && productVariant.IsDownload) { hasDownloadableItems = true; break; } } gvOrderProductVariants.Columns[1].Visible = hasDownloadableItems && !this.IsInvoice; gvOrderProductVariants.DataSource = orderProductVariants; gvOrderProductVariants.DataBind(); //checkout attributes lCheckoutAttributes.Text = order.CheckoutAttributeDescription; var orderNoteCollection = order.OrderNotes; if (orderNoteCollection.Count > 0) { gvOrderNotes.DataSource = order.OrderNotes; gvOrderNotes.DataBind(); } else { pnlOrderNotesTitle.Visible = false; pnlOrderNotes.Visible = false; } }