protected string FormatShippingOption(ShippingOption shippingOption) { decimal rateBase = TaxManager.GetShippingPrice(shippingOption.Rate, NopContext.Current.User); decimal rate = CurrencyManager.ConvertCurrency(rateBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string rateStr = PriceHelper.FormatShippingPrice(rate, true); return(string.Format("({0})", rateStr)); }
protected string FormatShippingOption(ShippingOption shippingOption) { //calculate discounted and taxed rate Discount appliedDiscount = null; decimal shippingTotalWithoutDiscount = shippingOption.Rate; decimal discountAmount = ShippingManager.GetShippingDiscount(NopContext.Current.User, shippingTotalWithoutDiscount, out appliedDiscount); decimal shippingTotalWithDiscount = shippingTotalWithoutDiscount - discountAmount; if (shippingTotalWithDiscount < decimal.Zero) shippingTotalWithDiscount = decimal.Zero; shippingTotalWithDiscount = Math.Round(shippingTotalWithDiscount, 2); decimal rateBase = TaxManager.GetShippingPrice(shippingTotalWithDiscount, NopContext.Current.User); decimal rate = CurrencyManager.ConvertCurrency(rateBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string rateStr = PriceHelper.FormatShippingPrice(rate, true); return string.Format("({0})", rateStr); }
protected string FormatShippingOption(ShippingOption shippingOption) { //calculate discounted and taxed rate Discount appliedDiscount = null; decimal shippingTotalWithoutDiscount = shippingOption.Rate; decimal discountAmount = this.ShippingService.GetShippingDiscount(NopContext.Current.User, shippingTotalWithoutDiscount, out appliedDiscount); decimal shippingTotalWithDiscount = shippingTotalWithoutDiscount - discountAmount; if (shippingTotalWithDiscount < decimal.Zero) { shippingTotalWithDiscount = decimal.Zero; } //shippingTotalWithDiscount = Math.Round(shippingTotalWithDiscount, 2, MidpointRounding.AwayFromZero); decimal rateBase = this.TaxService.GetShippingPrice(shippingTotalWithDiscount, NopContext.Current.User); decimal rate = this.CurrencyService.ConvertCurrency(rateBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); string rateStr = PriceHelper.FormatShippingPrice(rate, true); return(string.Format("({0})", rateStr)); }
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; } }
/// <summary> /// Print an order to PDF /// </summary> /// <param name="order">Order</param> /// <param name="languageId">Language identifier</param> /// <param name="filePath">File path</param> public static void PrintOrderToPdf(Order order, int languageId, string filePath) { if (order == null) { throw new ArgumentNullException("order"); } if (String.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath"); } Language lang = LanguageManager.GetLanguageById(languageId); if (lang == null) { throw new NopException("Language could not be loaded"); } Document doc = new Document(); Section sec = doc.AddSection(); Table table = sec.AddTable(); table.Borders.Visible = false; bool logoExists = File.Exists(PDFHelper.LogoFilePath); table.AddColumn(Unit.FromCentimeter(10)); if (logoExists) { table.AddColumn(Unit.FromCentimeter(10)); } Row ordRow = table.AddRow(); int rownum = logoExists ? 1 : 0; Paragraph p1 = ordRow[rownum].AddParagraph(String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Order#", languageId), order.OrderId)); p1.Format.Font.Bold = true; p1.Format.Font.Color = Colors.Black; ordRow[rownum].AddParagraph(SettingManager.StoreUrl.Trim(new char[] { '/' })).AddHyperlink(SettingManager.StoreUrl, HyperlinkType.Url); ordRow[rownum].AddParagraph(String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.OrderDate", languageId), DateTimeHelper.ConvertToUserTime(order.CreatedOn, DateTimeKind.Utc).ToString("D"))); if (File.Exists(PDFHelper.LogoFilePath)) { ordRow[0].AddImage(PDFHelper.LogoFilePath); } var addressTable = sec.AddTable(); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { addressTable.AddColumn(Unit.FromCentimeter(9)); addressTable.AddColumn(Unit.FromCentimeter(9)); } else { addressTable.AddColumn(Unit.FromCentimeter(18)); } addressTable.Borders.Visible = false; Row row = addressTable.AddRow(); //billing info row.Cells[0].AddParagraph(); Paragraph p2 = row.Cells[0].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.BillingInformation", languageId)); p2.Format.Font.Bold = true; p2.Format.Font.Color = Colors.Black; if (!String.IsNullOrEmpty(order.BillingCompany)) { row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Company", languageId), order.BillingCompany)); } row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", languageId), order.BillingFullName)); row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", languageId), order.BillingPhoneNumber)); if (!String.IsNullOrEmpty(order.BillingFaxNumber)) { row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", languageId), order.BillingFaxNumber)); } row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", languageId), order.BillingAddress1)); if (!String.IsNullOrEmpty(order.BillingAddress2)) { row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", languageId), order.BillingAddress2)); } row.Cells[0].AddParagraph(" " + String.Format("{0}, {1}", order.BillingCountry, order.BillingStateProvince)); row.Cells[0].AddParagraph(" " + String.Format("{0}, {1}", order.BillingCity, order.BillingZipPostalCode)); //VAT number if (!String.IsNullOrEmpty(order.VatNumber)) { row.Cells[0].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.VATNumber", languageId), order.VatNumber)); } row.Cells[0].AddParagraph(); //shipping info if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { row.Cells[1].AddParagraph(); Paragraph p3 = row.Cells[1].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingInformation", languageId)); p3.Format.Font.Bold = true; p3.Format.Font.Color = Colors.Black; if (!String.IsNullOrEmpty(order.ShippingCompany)) { row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Company", languageId), order.ShippingCompany)); } row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", languageId), order.ShippingFullName)); row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", languageId), order.ShippingPhoneNumber)); if (!String.IsNullOrEmpty(order.ShippingFaxNumber)) { row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", languageId), order.ShippingFaxNumber)); } row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", languageId), order.ShippingAddress1)); if (!String.IsNullOrEmpty(order.ShippingAddress2)) { row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", languageId), order.ShippingAddress2)); } row.Cells[1].AddParagraph(" " + String.Format("{0}, {1}", order.ShippingCountry, order.ShippingStateProvince)); row.Cells[1].AddParagraph(" " + String.Format("{0}, {1}", order.ShippingCity, order.ShippingZipPostalCode)); row.Cells[1].AddParagraph(); row.Cells[1].AddParagraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingMethod", languageId), order.ShippingMethod)); row.Cells[1].AddParagraph(); } sec.AddParagraph(); //products Paragraph p4 = sec.AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.Product(s)", languageId)); p4.Format.Font.Bold = true; p4.Format.Font.Color = Colors.Black; sec.AddParagraph(); var productCollection = order.OrderProductVariants; var tbl = sec.AddTable(); tbl.Borders.Visible = true; tbl.Borders.Width = 1; tbl.AddColumn(Unit.FromCentimeter(8)); tbl.AddColumn(Unit.FromCentimeter(4)); tbl.AddColumn(Unit.FromCentimeter(2)); tbl.AddColumn(Unit.FromCentimeter(4)); Row header = tbl.AddRow(); header.Cells[0].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductName", languageId)); header.Cells[0].Format.Alignment = ParagraphAlignment.Center; header.Cells[1].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductPrice", languageId)); header.Cells[1].Format.Alignment = ParagraphAlignment.Center; header.Cells[2].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductQuantity", languageId)); header.Cells[2].Format.Alignment = ParagraphAlignment.Center; header.Cells[3].AddParagraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductTotal", languageId)); header.Cells[3].Format.Alignment = ParagraphAlignment.Center; for (int i = 0; i < productCollection.Count; i++) { var orderProductVariant = productCollection[i]; int rowNum = i + 1; Row prodRow = tbl.AddRow(); string name = String.Format("Not available. Id={0}", orderProductVariant.ProductVariantId); var pv = ProductManager.GetProductVariantById(orderProductVariant.ProductVariantId); if (pv != null) { name = pv.GetLocalizedFullProductName(languageId); } prodRow.Cells[0].AddParagraph(name); Paragraph p5 = prodRow.Cells[0].AddParagraph(HtmlHelper.ConvertHtmlToPlainText(orderProductVariant.AttributeDescription, true)); p5.Format.Font.Italic = true; prodRow.Cells[0].Format.Alignment = ParagraphAlignment.Left; string unitPrice = string.Empty; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: unitPrice = PriceHelper.FormatPrice(orderProductVariant.UnitPriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, false); break; case TaxDisplayTypeEnum.IncludingTax: unitPrice = PriceHelper.FormatPrice(orderProductVariant.UnitPriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, true); break; } prodRow.Cells[1].AddParagraph(unitPrice); prodRow.Cells[2].AddParagraph(orderProductVariant.Quantity.ToString()); string subTotal = string.Empty; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: subTotal = PriceHelper.FormatPrice(orderProductVariant.PriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, false); break; case TaxDisplayTypeEnum.IncludingTax: subTotal = PriceHelper.FormatPrice(orderProductVariant.PriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, true); break; } prodRow.Cells[3].AddParagraph(subTotal); } //checkout attributes if (!String.IsNullOrEmpty(order.CheckoutAttributeDescription)) { sec.AddParagraph(); Paragraph pCheckoutAttributes = null; string attributes = HtmlHelper.ConvertHtmlToPlainText(order.CheckoutAttributeDescription, true); pCheckoutAttributes = sec.AddParagraph(attributes); if (pCheckoutAttributes != null) { pCheckoutAttributes.Format.Alignment = ParagraphAlignment.Right; } } //subtotal sec.AddParagraph(); Paragraph p6 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string orderSubtotalExclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, false); p6 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Sub-Total", languageId), orderSubtotalExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string orderSubtotalInclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, true); p6 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Sub-Total", languageId), orderSubtotalInclTaxStr)); } break; } if (p6 != null) { p6.Format.Alignment = ParagraphAlignment.Right; } //shipping if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { Paragraph p9 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string orderShippingExclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, false); p9 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", languageId), orderShippingExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string orderShippingInclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, true); p9 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", languageId), orderShippingInclTaxStr)); } break; } if (p9 != null) { p9.Format.Alignment = ParagraphAlignment.Right; } } //payment fee if (order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency > decimal.Zero) { Paragraph p10 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string paymentMethodAdditionalFeeExclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, false); p10 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.PaymentMethodAdditionalFee", languageId), paymentMethodAdditionalFeeExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string paymentMethodAdditionalFeeInclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, lang, true); p10 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.PaymentMethodAdditionalFee", languageId), paymentMethodAdditionalFeeInclTaxStr)); } break; } if (p10 != null) { p10.Format.Alignment = ParagraphAlignment.Right; } } //tax string taxStr = string.Empty; SortedDictionary <decimal, decimal> taxRates = new SortedDictionary <decimal, decimal>(); bool displayTax = true; bool displayTaxRates = true; if (TaxManager.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { if (order.OrderTax == 0 && TaxManager.HideZeroTax) { displayTax = false; displayTaxRates = false; } else { taxRates = order.TaxRatesDictionaryInCustomerCurrency; displayTaxRates = TaxManager.DisplayTaxRates && taxRates.Count > 0; displayTax = !displayTaxRates; taxStr = PriceHelper.FormatPrice(order.OrderTaxInCustomerCurrency, true, order.CustomerCurrencyCode, false); } } if (displayTax) { var p11 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Tax", languageId), taxStr)); p11.Format.Alignment = ParagraphAlignment.Right; } if (displayTaxRates) { foreach (var item in taxRates) { string taxRate = String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Totals.TaxRate"), TaxManager.FormatTaxRate(item.Key)); string taxValue = PriceHelper.FormatPrice(item.Value, true, false); var p13 = sec.AddParagraph(String.Format("{0} {1}", taxRate, taxValue)); p13.Format.Alignment = ParagraphAlignment.Right; } } //discount if (order.OrderDiscountInCustomerCurrency > decimal.Zero) { string orderDiscountInCustomerCurrencyStr = PriceHelper.FormatPrice(-order.OrderDiscountInCustomerCurrency, true, order.CustomerCurrencyCode, false); Paragraph p7 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Discount", languageId), orderDiscountInCustomerCurrencyStr)); p7.Format.Alignment = ParagraphAlignment.Right; } //gift cards var gcuhC = OrderManager.GetAllGiftCardUsageHistoryEntries(null, null, order.OrderId); foreach (var giftCardUsageHistory in gcuhC) { string gcTitle = string.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.GiftCardInfo", languageId), giftCardUsageHistory.GiftCard.GiftCardCouponCode); string gcAmountStr = PriceHelper.FormatPrice(-giftCardUsageHistory.UsedValueInCustomerCurrency, true, order.CustomerCurrencyCode, false); Paragraph p8 = sec.AddParagraph(String.Format("{0} {1}", gcTitle, gcAmountStr)); p8.Format.Alignment = ParagraphAlignment.Right; } //reward points if (order.RedeemedRewardPoints != null) { string rpTitle = string.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.RewardPoints", languageId), -order.RedeemedRewardPoints.Points); string rpAmount = PriceHelper.FormatPrice(-order.RedeemedRewardPoints.UsedAmountInCustomerCurrency, true, order.CustomerCurrencyCode, false); var p11 = sec.AddParagraph(String.Format("{0} {1}", rpTitle, rpAmount)); p11.Format.Alignment = ParagraphAlignment.Right; } //order total string orderTotalStr = PriceHelper.FormatPrice(order.OrderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false); var p12 = sec.AddParagraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.OrderTotal", languageId), orderTotalStr)); p12.Format.Font.Bold = true; p12.Format.Font.Color = Colors.Black; p12.Format.Alignment = ParagraphAlignment.Right; PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always); renderer.Document = doc; renderer.RenderDocument(); renderer.PdfDocument.Save(filePath); }
protected void btnNextStep_Click(object sender, EventArgs e) { if (Page.IsValid) { try { PaymentInfo paymentInfo = this.PaymentInfo; //if (paymentInfo == null) // Response.Redirect("~/CheckoutPaymentInfo.aspx"); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; int orderId = 0; string result = ""; if (Request["OrderId"] == null) { result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId); } else { orderId = int.Parse(Request["OrderId"]); } this.PaymentInfo = null; Order order = OrderManager.GetOrderByID(orderId); if (!String.IsNullOrEmpty(result)) { lError.Text = Server.HtmlEncode(result); return; } if (Request["OrderId"] != null) { order.PaymentMethodID = paymentInfo.PaymentMethodID; order.PaymentMethodName = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID).Name; } Guid customerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; IndividualOrderCollection indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGUID); string subj = "Заказ в магазине Voobrazi.by"; StringBuilder body = new StringBuilder(); body.AppendFormat("Доставка: {0}<br /><br />", ((bool)Session["Delivery"]) ? "Курьером" : "Самовывоз").AppendLine(); body.AppendFormat("<b>Заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", paymentInfo.BillingAddress.FirstName, paymentInfo.BillingAddress.LastName).AppendLine(); body.AppendFormat("Телефоны: {0} {1}<br />", paymentInfo.BillingAddress.PhoneNumber, !string.IsNullOrEmpty(paymentInfo.BillingAddress.FaxNumber) ? ", " + paymentInfo.BillingAddress.FaxNumber : "").AppendLine(); body.AppendFormat("Адрес: {0} {1}<br />", paymentInfo.BillingAddress.City, paymentInfo.BillingAddress.Address1).AppendLine(); body.AppendFormat("Email: {0}<br /><br />", !string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email).AppendLine(); body.AppendFormat("Комментарии: {0}<br /><br />", tbComments.Text).AppendLine(); PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm != null) { body.AppendFormat("Способ оплаты: {0}<br /><br />", pm.Name).AppendLine(); } decimal total = 0; decimal indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } total += indOrderTotal; body.AppendFormat("Индивидуальные заказы:<br />"); foreach (var indOrder in indOrders) { body.Append(indOrder.OrderText + "<br />"); } if (Session["fn"] != null) { body.AppendLine(); body.Append("<b>Получатель не заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", Session["fn"], Session["ln"]).AppendLine(); body.AppendFormat("Телефон: {0}<br />", Session["pn"]).AppendLine(); body.AppendFormat("Адрес: {0}<br />", Session["address"]).AppendLine(); body.AppendFormat("Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); } body.AppendFormat("Уведомление о доставке: {0} | {1}<br />", chbByMail.Checked ? "Письмом на Email" : "", chbSMS.Checked ? "СМС сообщение" : "").AppendLine(); body.AppendFormat("<br /><br /> Заказано:<br />"); foreach (OrderProductVariant variant in order.OrderProductVariants) { body.AppendFormat(" - {0} ({1}) x {2}шт. -- {3}; <br />", variant.ProductVariant.Product.Name, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price, true), variant.Quantity, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price * variant.Quantity, true)); total += variant.ProductVariant.Price * variant.Quantity; } string shipping = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shipping = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); total += shoppingCartShipping; } } body.AppendFormat("Доставка: {0}<br />", shipping).AppendLine(); body.AppendFormat("<b>Итого:</b> {0}<br />", total).AppendLine(); body.AppendFormat("<br />Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); MessageManager.SendEmail(subj, body.ToString(), MessageManager.AdminEmailAddress, MessageManager.AdminEmailAddress); StartPaymentMethod(indOrders, order); Session.Remove("SelfOrder"); Response.Redirect("~/CheckoutCompleted.aspx"); } catch (Exception exc) { Session.Remove("SelfOrder"); LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc); lError.Text = Server.HtmlEncode("Во время обработки заказа произошла ошибка. Для выполнения заказа, пожалуйста, свяжитесь с администратором. Контактную информацию можно найти на странице Контакты."); } } }
private void BindOrderTotals(Order order) { if (order == null) { return; } //subtotal string orderSubtotalInclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalInclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, true); string orderSubtotalExclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalExclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, false); if (TaxManager.AllowCustomersToSelectTaxDisplayType) { this.lblOrderSubtotalInclTax.Text = orderSubtotalInclTaxStr; this.lblOrderSubtotalExclTax.Text = orderSubtotalExclTaxStr; this.pnlOrderSubtotalInclTax.Visible = true; this.pnlOrderSubtotalExclTax.Visible = true; } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblOrderSubtotalExclTax.Text = orderSubtotalExclTaxStr; this.pnlOrderSubtotalInclTax.Visible = false; this.pnlOrderSubtotalExclTax.Visible = true; } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblOrderSubtotalInclTax.Text = orderSubtotalInclTaxStr; this.pnlOrderSubtotalInclTax.Visible = true; this.pnlOrderSubtotalExclTax.Visible = false; } break; default: { this.pnlOrderSubtotalInclTax.Visible = false; this.pnlOrderSubtotalExclTax.Visible = false; } break; } } //shipping string orderShippingInclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingInclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, true); string orderShippingExclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingExclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, false); if (TaxManager.ShippingIsTaxable) { if (TaxManager.AllowCustomersToSelectTaxDisplayType) { this.lblOrderShippingInclTax.Text = orderShippingInclTaxStr; this.lblOrderShippingExclTax.Text = orderShippingExclTaxStr; this.pnlOrderShippingInclTax.Visible = true; this.pnlOrderShippingExclTax.Visible = true; } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblOrderShippingExclTax.Text = orderShippingExclTaxStr; this.pnlOrderShippingInclTax.Visible = false; this.pnlOrderShippingExclTax.Visible = true; } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblOrderShippingInclTax.Text = orderShippingInclTaxStr; this.pnlOrderShippingInclTax.Visible = true; this.pnlOrderShippingExclTax.Visible = false; } break; default: { this.pnlOrderShippingInclTax.Visible = false; this.pnlOrderShippingExclTax.Visible = false; } break; } } } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblOrderShippingExclTax.Text = orderShippingExclTaxStr; this.pnlOrderShippingInclTax.Visible = false; this.pnlOrderShippingExclTax.Visible = true; } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblOrderShippingInclTax.Text = orderShippingInclTaxStr; this.pnlOrderShippingInclTax.Visible = true; this.pnlOrderShippingExclTax.Visible = false; } break; default: { this.pnlOrderShippingInclTax.Visible = false; this.pnlOrderShippingExclTax.Visible = false; } break; } } //payment method additional fee string paymentMethodAdditionalFeeInclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, true); string paymentMethodAdditionalFeeExclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTax, true, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingLanguage, false); if (order.PaymentMethodAdditionalFeeInclTax > decimal.Zero) { if (TaxManager.PaymentMethodAdditionalFeeIsTaxable) { if (TaxManager.AllowCustomersToSelectTaxDisplayType) { this.lblPaymentMethodAdditionalFeeInclTax.Text = paymentMethodAdditionalFeeInclTaxStr; this.lblPaymentMethodAdditionalFeeExclTax.Text = paymentMethodAdditionalFeeExclTaxStr; this.pnlPaymentMethodAdditionalFeeInclTax.Visible = true; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = true; } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblPaymentMethodAdditionalFeeExclTax.Text = paymentMethodAdditionalFeeExclTaxStr; this.pnlPaymentMethodAdditionalFeeInclTax.Visible = false; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = true; } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblPaymentMethodAdditionalFeeInclTax.Text = paymentMethodAdditionalFeeInclTaxStr; this.pnlPaymentMethodAdditionalFeeInclTax.Visible = true; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = false; } break; default: { this.pnlPaymentMethodAdditionalFeeInclTax.Visible = false; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = false; } break; } } } else { switch (TaxManager.TaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { this.lblPaymentMethodAdditionalFeeExclTax.Text = paymentMethodAdditionalFeeExclTaxStr; this.pnlPaymentMethodAdditionalFeeInclTax.Visible = false; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = true; } break; case TaxDisplayTypeEnum.IncludingTax: { this.lblPaymentMethodAdditionalFeeInclTax.Text = paymentMethodAdditionalFeeInclTaxStr; this.pnlPaymentMethodAdditionalFeeInclTax.Visible = true; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = false; } break; default: { this.pnlPaymentMethodAdditionalFeeInclTax.Visible = false; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = false; } break; } } } else { this.pnlPaymentMethodAdditionalFeeInclTax.Visible = false; this.pnlPaymentMethodAdditionalFeeExclTax.Visible = false; } this.lblOrderDiscount.Text = PriceHelper.FormatPrice(order.OrderDiscount, true, false); this.lblOrderTax.Text = PriceHelper.FormatPrice(order.OrderTax, true, false); this.lblOrderTotal.Text = PriceHelper.FormatPrice(order.OrderTotal, true, false); //this.lblOrderTotalInCustomerCurrencyCode.Text = string.Format("{0} ({1})", order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode); }
private void BindData() { this.lnkPrint.NavigateUrl = Page.ResolveUrl("~/PrintOrderDetails.aspx?OrderID=" + this.OrderID); this.lblOrderID.Text = order.OrderID.ToString(); this.lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(order.CreatedOn).ToString("D"); this.lblOrderStatus.Text = OrderManager.GetOrderStatusName(order.OrderStatusID); 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(!string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email); 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); //TODO use order.ShippingStatus if (order.ShippedDate.HasValue) { this.lblShippedDate.Text = DateTimeHelper.ConvertToUserTime(order.ShippedDate.Value).ToString(); } else { this.lblShippedDate.Text = GetLocaleResourceString("Order.NotYetShipped"); } } else { this.pnlShipping.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(!string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email); 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; } PaymentMethod 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; 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; string orderTotalStr = PriceHelper.FormatPrice(order.OrderTotalInCustomerCurrency, true, order.CustomerCurrencyCode, false); this.lblOrderTotal.Text = orderTotalStr; this.lblOrderTotal2.Text = orderTotalStr; OrderProductVariantCollection orderProductVariants = order.OrderProductVariants; bool hasDownloadableItems = false; foreach (OrderProductVariant orderProductVariant in orderProductVariants) { ProductVariant productVariant = orderProductVariant.ProductVariant; if (productVariant != null) { if (productVariant.IsDownload && OrderManager.AreDownloadsAllowed(order)) { hasDownloadableItems = true; break; } } } gvOrderProductVariants.Columns[2].Visible = hasDownloadableItems; gvOrderProductVariants.DataSource = orderProductVariants; gvOrderProductVariants.DataBind(); }
public void BindData(bool isShoppingCart) { this.IsShoppingCart = isShoppingCart; var cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); if (cart.Count > 0) { //payment method (if already selected) int paymentMethodId = 0; if (NopContext.Current.User != null) { paymentMethodId = NopContext.Current.User.LastPaymentMethodId; } //subtotal //don't include checkout attributes on shopping cart page decimal subtotalBase = decimal.Zero; string SubTotalError = ShoppingCartManager.GetShoppingCartSubTotal(cart, NopContext.Current.User, out subtotalBase); if (String.IsNullOrEmpty(SubTotalError)) { decimal subtotal = CurrencyManager.ConvertCurrency(subtotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblSubTotalAmount.Text = PriceHelper.FormatPrice(subtotal); lblSubTotalAmount.CssClass = "productPrice"; } else { //impossible lblSubTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblSubTotalAmount.CssClass = string.Empty; } //shipping info bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(cart); if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblShippingAmount.Text = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); lblShippingAmount.CssClass = "productPrice"; } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblShippingAmount.CssClass = string.Empty; } } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); lblShippingAmount.CssClass = string.Empty; } //payment method fee bool displayPaymentMethodFee = true; decimal paymentMethodAdditionalFee = PaymentManager.GetAdditionalHandlingFee(paymentMethodId); decimal paymentMethodAdditionalFeeWithTaxBase = TaxManager.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, NopContext.Current.User); if (paymentMethodAdditionalFeeWithTaxBase > decimal.Zero) { decimal paymentMethodAdditionalFeeWithTax = CurrencyManager.ConvertCurrency(paymentMethodAdditionalFeeWithTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(paymentMethodAdditionalFeeWithTax, true); } else { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; //tax bool displayTax = true; bool displayTaxRates = true; if (TaxManager.HideTaxInOrderSummary && NopContext.Current.TaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; displayTaxRates = false; } else { string taxError = string.Empty; SortedDictionary <decimal, decimal> taxRates = null; decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(cart, paymentMethodId, NopContext.Current.User, out taxRates, ref taxError); decimal shoppingCartTax = CurrencyManager.ConvertCurrency(shoppingCartTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (String.IsNullOrEmpty(taxError)) { if (shoppingCartTaxBase == 0 && TaxManager.HideZeroTax) { displayTax = false; displayTaxRates = false; } else { displayTaxRates = TaxManager.DisplayTaxRates && taxRates.Count > 0; displayTax = !displayTaxRates; lblTaxAmount.Text = PriceHelper.FormatPrice(shoppingCartTax, true, false); lblTaxAmount.CssClass = "productPrice"; rptrTaxRates.DataSource = taxRates; rptrTaxRates.DataBind(); } } else { lblTaxAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblTaxAmount.CssClass = string.Empty; displayTaxRates = false; } } rptrTaxRates.Visible = displayTaxRates; phTaxTotal.Visible = displayTax; //total decimal discountAmountBase = decimal.Zero; Discount appliedDiscount = null; List <AppliedGiftCard> appliedGiftCards = null; int redeemedRewardPoints = 0; decimal redeemedRewardPointsAmount = decimal.Zero; bool useRewardPoints = false; if (NopContext.Current.User != null) { useRewardPoints = NopContext.Current.User.UseRewardPointsDuringCheckout; } decimal?shoppingCartTotalBase = ShoppingCartManager.GetShoppingCartTotal(cart, paymentMethodId, NopContext.Current.User, out discountAmountBase, out appliedDiscount, out appliedGiftCards, useRewardPoints, out redeemedRewardPoints, out redeemedRewardPointsAmount); if (shoppingCartTotalBase.HasValue) { decimal shoppingCartTotal = CurrencyManager.ConvertCurrency(shoppingCartTotalBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartTotal, true, false); lblTotalAmount.CssClass = "productPrice"; } else { lblTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblTotalAmount.CssClass = string.Empty; } //discount if (discountAmountBase > decimal.Zero) { decimal discountAmount = CurrencyManager.ConvertCurrency(discountAmountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblDiscountAmount.Text = PriceHelper.FormatPrice(-discountAmount, true, false); phDiscount.Visible = true; } else { phDiscount.Visible = false; } //gift cards if (appliedGiftCards != null && appliedGiftCards.Count > 0) { rptrGiftCards.Visible = true; rptrGiftCards.DataSource = appliedGiftCards; rptrGiftCards.DataBind(); } else { rptrGiftCards.Visible = false; } //reward points if (redeemedRewardPointsAmount > decimal.Zero) { phRewardPoints.Visible = true; decimal redeemedRewardPointsAmountInCustomerCurrency = CurrencyManager.ConvertCurrency(redeemedRewardPointsAmount, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lRewardPointsTitle.Text = string.Format(GetLocaleResourceString("ShoppingCart.Totals.RewardPoints"), redeemedRewardPoints); lblRewardPointsAmount.Text = PriceHelper.FormatPrice(-redeemedRewardPointsAmountInCustomerCurrency, true, false); } else { phRewardPoints.Visible = false; } } else { this.Visible = false; } }
public void BindData() { ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); 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 (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (Cart.Count > 0 || indOrders.Count > 0) { //payment method (if already selected) int paymentMethodID = 0; if (NopContext.Current.User != null) { paymentMethodID = NopContext.Current.User.LastPaymentMethodID; } //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; lblSubTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblSubTotalAmount.Text += "$"; } lblSubTotalAmount.CssClass = "productPrice"; if (shoppingCartSubTotalDiscountBase > decimal.Zero) { decimal shoppingCartSubTotalDiscount = CurrencyManager.ConvertCurrency(shoppingCartSubTotalDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblSubTotalDiscountAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotalDiscount, true, false); phSubTotalDiscount.Visible = true; } else { phSubTotalDiscount.Visible = false; } } else { lblSubTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblSubTotalAmount.CssClass = string.Empty; } //shipping info bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblShippingAmount.Text = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblShippingAmount.Text += "$"; } lblShippingAmount.CssClass = "productPrice"; } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblShippingAmount.CssClass = string.Empty; } } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); lblShippingAmount.CssClass = string.Empty; } //payment method fee bool displayPaymentMethodFee = true; decimal paymentMethodAdditionalFee = PaymentManager.GetAdditionalHandlingFee(paymentMethodID); decimal paymentMethodAdditionalFeeWithTaxBase = TaxManager.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, NopContext.Current.User); if (paymentMethodAdditionalFeeWithTaxBase > decimal.Zero) { decimal paymentMethodAdditionalFeeWithTax = CurrencyManager.ConvertCurrency(paymentMethodAdditionalFeeWithTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(paymentMethodAdditionalFeeWithTax, true); } else { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; //tax bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && NopContext.Current.TaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { string TaxError = string.Empty; decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(Cart, paymentMethodID, NopContext.Current.User, ref TaxError); decimal shoppingCartTax = CurrencyManager.ConvertCurrency(shoppingCartTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); //if (String.IsNullOrEmpty(TaxError)) //{ // if (shoppingCartTaxBase == 0 && TaxManager.HideZeroTax) // { // displayTax = false; // } // else // { // lblTaxAmount.Text = PriceHelper.FormatPrice(shoppingCartTax, true, false); // lblTaxAmount.CssClass = "productPrice"; // } //} //else //{ // lblTaxAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); // lblTaxAmount.CssClass = string.Empty; //} } phTaxTotal.Visible = false;// displayTax; //total decimal?shoppingCartTotalBase = ShoppingCartManager.GetShoppingCartTotal(Cart, paymentMethodID, NopContext.Current.User); if (shoppingCartTotalBase.HasValue) { decimal shoppingCartTotal = CurrencyManager.ConvertCurrency(shoppingCartTotalBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (Session["SelfOrder"] != null) { shoppingCartTotal -= ShippingManager.GetShoppingCartShippingTotal(Cart).Value; } shoppingCartTotal += indOrderTotal; lblTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblTotalAmount.Text += "$"; } lblTotalAmount.CssClass = "productPrice"; } else { lblTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblTotalAmount.CssClass = string.Empty; } } else { this.Visible = false; } }
/// <summary> /// Print an order to PDF /// </summary> /// <param name="order">Order</param> /// <param name="LanguageID">Language identifier</param> /// <param name="FilePath">File path</param> public static void PrintOrderToPDF(Order order, int LanguageID, string FilePath) { if (order == null) { throw new ArgumentNullException("order"); } if (String.IsNullOrEmpty(FilePath)) { throw new ArgumentNullException("FilePath"); } Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(FilePath, FileMode.Create)); doc.Open(); doc.Add(new Paragraph(String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Order#", LanguageID), order.OrderID))); doc.Add(new Paragraph(String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.OrderDate", LanguageID), order.CreatedOn))); //billing info doc.Add(new Paragraph(" ")); doc.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.BillingInformation", LanguageID))); doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.BillingFullName))); doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.BillingPhoneNumber))); if (!String.IsNullOrEmpty(order.BillingFaxNumber)) { doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.BillingFaxNumber))); } doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.BillingAddress1))); if (!String.IsNullOrEmpty(order.BillingAddress2)) { doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.BillingAddress2))); } doc.Add(new Paragraph(" " + String.Format("{0}, {1}", order.BillingCountry, order.BillingStateProvince))); doc.Add(new Paragraph(" " + String.Format("{0}, {1}", order.BillingCity, order.BillingZipPostalCode))); doc.Add(new Paragraph(" ")); //shipping info if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { doc.Add(new Paragraph(" ")); doc.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.ShippingInformation", LanguageID))); doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Name", LanguageID), order.ShippingFullName))); doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Phone", LanguageID), order.ShippingPhoneNumber))); if (!String.IsNullOrEmpty(order.ShippingFaxNumber)) { doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Fax", LanguageID), order.ShippingFaxNumber))); } doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address", LanguageID), order.ShippingAddress1))); if (!String.IsNullOrEmpty(order.ShippingAddress2)) { doc.Add(new Paragraph(" " + String.Format(LocalizationManager.GetLocaleResourceString("PDFInvoice.Address2", LanguageID), order.ShippingAddress2))); } doc.Add(new Paragraph(" " + String.Format("{0}, {1}", order.ShippingCountry, order.ShippingStateProvince))); doc.Add(new Paragraph(" " + String.Format("{0}, {1}", order.ShippingCity, order.ShippingZipPostalCode))); doc.Add(new Paragraph(" ")); } //products doc.Add(new Paragraph(LocalizationManager.GetLocaleResourceString("PDFInvoice.Product(s)", LanguageID))); doc.Add(new Paragraph(" ")); OrderProductVariantCollection productCollection = order.OrderProductVariants; Table tbl = new Table(4, productCollection.Count + 1); tbl.AutoFillEmptyCells = true; tbl.Cellpadding = 2f; tbl.SetWidths(new int[4] { 40, 25, 10, 25 }); Cell c1 = new Cell(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductName", LanguageID)); c1.Header = true; c1.HorizontalAlignment = Element.ALIGN_CENTER; c1.VerticalAlignment = Element.ALIGN_MIDDLE; tbl.AddCell(c1, 0, 0); Cell c2 = new Cell(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductPrice", LanguageID)); c2.Header = true; c2.HorizontalAlignment = Element.ALIGN_CENTER; c2.VerticalAlignment = Element.ALIGN_MIDDLE; tbl.AddCell(c2, 0, 1); Cell c3 = new Cell(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductQuantity", LanguageID)); c3.Header = true; c3.HorizontalAlignment = Element.ALIGN_CENTER; c3.VerticalAlignment = Element.ALIGN_MIDDLE; tbl.AddCell(c3, 0, 2); Cell c4 = new Cell(LocalizationManager.GetLocaleResourceString("PDFInvoice.ProductTotal", LanguageID)); c4.Header = true; c4.HorizontalAlignment = Element.ALIGN_CENTER; c4.VerticalAlignment = Element.ALIGN_MIDDLE; tbl.AddCell(c4, 0, 3); tbl.Width = 90f; for (int i = 0; i < productCollection.Count; i++) { OrderProductVariant orderProductVariant = productCollection[i]; int row = i + 1; string name = String.Format("Not available. ID={0}", orderProductVariant.ProductVariantID); ProductVariant pv = ProductManager.GetProductVariantByID(orderProductVariant.ProductVariantID); if (pv != null) { name = pv.FullProductName; } tbl.AddCell(new Cell(name), row, 0); string unitPrice = string.Empty; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: unitPrice = PriceHelper.FormatPrice(orderProductVariant.UnitPriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); break; case TaxDisplayTypeEnum.IncludingTax: unitPrice = PriceHelper.FormatPrice(orderProductVariant.UnitPriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); break; } tbl.AddCell(new Cell(unitPrice), row, 1); tbl.AddCell(new Cell(orderProductVariant.Quantity.ToString()), row, 2); string subTotal = string.Empty; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: subTotal = PriceHelper.FormatPrice(orderProductVariant.PriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); break; case TaxDisplayTypeEnum.IncludingTax: subTotal = PriceHelper.FormatPrice(orderProductVariant.PriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); break; } tbl.AddCell(new Cell(subTotal), row, 3); } doc.Add(tbl); //subtotal doc.Add(new Paragraph(" ")); Paragraph p1 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string orderSubtotalExclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); p1 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Sub-Total", LanguageID), orderSubtotalExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string orderSubtotalInclTaxStr = PriceHelper.FormatPrice(order.OrderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); p1 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Sub-Total", LanguageID), orderSubtotalInclTaxStr)); } break; } if (p1 != null) { p1.Alignment = Element.ALIGN_RIGHT; doc.Add(p1); } //shipping Paragraph p2 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string orderShippingExclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); p2 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", LanguageID), orderShippingExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string orderShippingInclTaxStr = PriceHelper.FormatShippingPrice(order.OrderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); p2 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Shipping", LanguageID), orderShippingInclTaxStr)); } break; } if (p2 != null) { p2.Alignment = Element.ALIGN_RIGHT; doc.Add(p2); } //payment fee bool displayPaymentMethodFee = true; if (order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency == decimal.Zero) { displayPaymentMethodFee = false; } if (displayPaymentMethodFee) { Paragraph p3 = null; switch (order.CustomerTaxDisplayType) { case TaxDisplayTypeEnum.ExcludingTax: { string paymentMethodAdditionalFeeExclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, false); p3 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.PaymentMethodAdditionalFee", LanguageID), paymentMethodAdditionalFeeExclTaxStr)); } break; case TaxDisplayTypeEnum.IncludingTax: { string paymentMethodAdditionalFeeInclTaxStr = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, NopContext.Current.WorkingLanguage, true); p3 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.PaymentMethodAdditionalFee", LanguageID), paymentMethodAdditionalFeeInclTaxStr)); } break; } if (p3 != null) { p3.Alignment = Element.ALIGN_RIGHT; doc.Add(p3); } } string taxStr = string.Empty; bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { if (order.OrderTax == 0 && TaxManager.HideZeroTax) { displayTax = false; } else { taxStr = string.Format("{0} ({1})", order.OrderTaxInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode); } } if (displayTax) { Paragraph p4 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.Tax", LanguageID), taxStr)); p4.Alignment = Element.ALIGN_RIGHT; doc.Add(p4); } string totalStr = string.Format("{0} ({1})", order.OrderTotalInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode); Paragraph p5 = new Paragraph(String.Format("{0} {1}", LocalizationManager.GetLocaleResourceString("PDFInvoice.OrderTotal", LanguageID), totalStr)); p5.Alignment = Element.ALIGN_RIGHT; doc.Add(p5); doc.Close(); }