コード例 #1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // TAX CLOUD TIC FIELD
            TaxCloudProvider taxCloudProvider = ProviderHelper.LoadTaxProvider <TaxCloudProvider>();

            trTIC.Visible = taxCloudProvider != null && taxCloudProvider.Activated;
        }
コード例 #2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            var provider = ProviderHelper.LoadTaxProvider <TaxCloudProvider>();

            if (provider == null || !provider.EnableTaxCloud || !provider.UseTaxExemption)
            {
                Response.Redirect("Default.aspx");
            }

            Dictionary <string, decimal> taxes = new Dictionary <string, decimal>();
            decimal totalTaxAmount             = 0;
            Basket  basket = AbleContext.Current.User.Basket;

            foreach (BasketItem item in basket.Items)
            {
                decimal extendedPrice = AbleCommerce.Code.InvoiceHelper.GetInvoiceExtendedPrice(item);
                if (item.OrderItemType == OrderItemType.Tax)
                {
                    totalTaxAmount += extendedPrice;
                }
            }

            TaxAmount.Text = totalTaxAmount.LSCurrencyFormat("ulc");
            BasketId.Text  = AbleContext.Current.User.Basket.Id.ToString();
        }
コード例 #3
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //Calculate billable weight
            billableWeightLink.Visible = _Product.Weight > 0;
            if (billableWeightLink.Visible)
            {
                ProductWeightLabel.Text = string.Format(ProductWeightLabel.Text, _Product.Weight);

                if (_Product.Height > 0 && _Product.Width > 0 && _Product.Length > 0)
                {
                    decimal productDimensions   = _Product.Height * _Product.Width * _Product.Length;
                    decimal domesticWeight      = productDimensions / 166;
                    decimal internationalWeight = productDimensions / 139;
                    DomesticLabel.Text      = string.Format(DomesticLabel.Text, domesticWeight);
                    InternationalLabel.Text = string.Format(InternationalLabel.Text, internationalWeight);
                }
                else
                {
                    trDimensionalWeightText.Visible = true;
                    trDomesticWeight.Visible        = false;
                    trInternationalWeight.Visible   = false;
                }
            }

            // TAX CLOUD TIC FIELD
            TaxCloudProvider taxCloudProvider = ProviderHelper.LoadTaxProvider <TaxCloudProvider>();

            trTIC.Visible = taxCloudProvider != null && taxCloudProvider.Activated;

            //Get File Names Uploaded
            string replaceText = "Assets/PDF/";

            if (_Product.CustomFields.Count > 0)
            {
                foreach (var rec in _Product.CustomFields)
                {
                    switch (rec.FieldName)
                    {
                    case "Download1":
                        FileName1.Text = rec.FieldValue.Replace(replaceText, "");
                        break;

                    case "Download2":
                        FileName2.Text = rec.FieldValue.Replace(replaceText, "");
                        break;

                    case "Download3":
                        FileName3.Text = rec.FieldValue.Replace(replaceText, "");
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #4
0
        //USE PRERENDER TO ALLOW FOR CALCULATIONS TO BASKET CONTENTS
        protected void Page_PreRender(object sender, EventArgs e)
        {
            decimal productsTotal = 0;
            decimal subtotal      = 0;
            decimal gstTotal      = 0;
            decimal shipping      = 0;
            decimal handling      = 0;
            Dictionary <string, decimal> taxes = new Dictionary <string, decimal>();
            decimal totalTaxAmount             = 0;
            decimal coupons          = 0;
            decimal discounts        = 0;
            decimal total            = 0;
            decimal giftwrap         = 0;
            int     numberOfProducts = 0;
            decimal giftCodes        = 0;
            Basket  basket           = AbleContext.Current.User.Basket;

            foreach (BasketItem item in basket.Items)
            {
                decimal extendedPrice = InvoiceHelper.GetInvoiceExtendedPrice(item); /*TaxHelper.GetInvoiceExtendedPrice(AbleContext.Current.User.Basket, item);*/

                switch (item.OrderItemType)
                {
                case OrderItemType.Product:
                    bool countItem = !item.IsChildItem;
                    if (!countItem)
                    {
                        BasketItem parentItem = item.GetParentItem(false);
                        if (parentItem != null)
                        {
                            countItem = parentItem.Product.IsKit && parentItem.Product.Kit.ItemizeDisplay;
                        }
                    }
                    if (countItem)
                    {
                        productsTotal    += extendedPrice;
                        subtotal         += extendedPrice;
                        gstTotal         += ((extendedPrice * (decimal)1.1) - extendedPrice);
                        numberOfProducts += item.Quantity;
                    }
                    else
                    {
                        // zero out the ext price - it is included with the parent
                        extendedPrice = 0;
                    }
                    break;

                case OrderItemType.Shipping:
                    shipping += extendedPrice;
                    break;

                case OrderItemType.Handling:
                    BasketShipment shipment = item.Shipment;
                    if (shipment != null && shipment.ShipMethod != null && shipment.ShipMethod.SurchargeIsVisible)
                    {
                        handling += extendedPrice;
                    }
                    else
                    {
                        shipping += extendedPrice;
                    }
                    break;

                case OrderItemType.Tax:
                    if (taxes.ContainsKey(item.Name + ":"))
                    {
                        taxes[item.Name + ":"] += extendedPrice;
                    }
                    else
                    {
                        taxes[item.Name + ":"] = extendedPrice;
                    }
                    totalTaxAmount += extendedPrice;
                    break;

                case OrderItemType.Coupon:
                    coupons += extendedPrice;
                    break;

                case OrderItemType.GiftWrap:
                    giftwrap += extendedPrice;
                    break;

                case OrderItemType.Discount:
                    discounts += extendedPrice;
                    subtotal  += extendedPrice;
                    break;

                case OrderItemType.GiftCertificatePayment:
                    giftCodes += extendedPrice;
                    break;

                default:
                    subtotal += extendedPrice;
                    break;
                }
                total += (extendedPrice * (decimal)1.1);
            }
            ProductTotalLabel.Text = string.Format(ProductTotalLabel.Text, numberOfProducts);
            ProductTotal.Text      = productsTotal.LSCurrencyFormat("ulc");
            Subtotal.Text          = subtotal.LSCurrencyFormat("ulc");
            GstTotal.Text          = gstTotal.LSCurrencyFormat("ulc");
            // DISCOUNT ROW VISIBILITY
            if (discounts != 0)
            {
                trDiscounts.Visible = true;
                Discounts.Text      = discounts.LSCurrencyFormat("ulc");
            }
            else
            {
                trDiscounts.Visible = false;
            }

            if (giftwrap != 0)
            {
                trGiftWrap.Visible = true;
                GiftWrap.Text      = giftwrap.LSCurrencyFormat("ulc");
            }
            else
            {
                trGiftWrap.Visible = false;
            }

            if (this.ShowTaxes &&
                AbleContext.Current.User.PrimaryAddress.IsValid &&
                TaxHelper.GetEffectiveInvoiceDisplay(AbleContext.Current.User) != TaxInvoiceDisplay.Included)
            {
                if (ShowTaxBreakdown)
                {
                    TaxesBreakdownRepeater.DataSource = taxes;
                    TaxesBreakdownRepeater.DataBind();
                    TaxesBreakdownRepeater.Visible = true;
                    trTax.Visible = false;
                }
                else
                {
                    TaxesLabel.Text = totalTaxAmount.LSCurrencyFormat("ulc");
                    TaxesBreakdownRepeater.Visible = false;
                    trTax.Visible = true;
                }
            }
            else
            {
                // TAXES ARE NOT DISPLAYED, REMOVE ANY TAX FROM THE TOTAL
                total -= totalTaxAmount;
                TaxesBreakdownRepeater.Visible = false;
                trTax.Visible = false;
                trTaxCloudTaxExemption.Visible = false;
            }

            // SHIPPING SHOULD NOT BE VISIBLE WHEN USER BILLING ADDRESS IS NOT SELECTED
            Shipping.Text = shipping.LSCurrencyFormat("ulc");
            if (!basket.User.PrimaryAddress.IsValid)
            {
                trShipping.Visible = false;
            }
            else if (shipping > 0)
            {
                trShipping.Visible = true;
            }
            else
            {
                trShipping.Visible = ShowShipping;
            }

            if (handling > 0 && trShipping.Visible)
            {
                trHandling.Visible = true;
                Handling.Text      = handling.LSCurrencyFormat("ulc");
            }
            else
            {
                trHandling.Visible = false;
            }

            if (giftCodes != 0)
            {
                trGifCodes.Visible = true;
                GifCodes.Text      = giftCodes.LSCurrencyFormat("ulc");
            }
            else
            {
                trGifCodes.Visible = false;
            }

            // COUPON ROW VISIBILITY
            if (coupons != 0)
            {
                trCoupon.Visible = true;
                Coupons.Text     = coupons.LSCurrencyFormat("ulc");
            }
            else
            {
                trCoupon.Visible = false;
            }

            trCouponsDivider.Visible = trCoupon.Visible || trGifCodes.Visible;

            Total.Text = total.LSCurrencyFormat("ulc");
            TotalPendingMessagePanel.Visible = this.ShowMessage;

            TaxCloudProvider taxProvider = ProviderHelper.LoadTaxProvider <TaxCloudProvider>();

            if (taxProvider != null && taxProvider.EnableTaxCloud && ShowTaxes && taxes.Count > 0 && taxProvider.UseTaxExemption)
            {
                trTaxCloudTaxExemption.Visible = true;
            }
        }