private void LoadControls()
        {
            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsMiniControl))
            {
                _checkoutTotalsDetailed =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsDetailedControl) as
                    CheckoutTotalsDetailed;
                plCheckOutTotalsDetails.Controls.Add(_checkoutTotalsDetailed);
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary))
            {
                _checkoutOrderSummary =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary) as
                    CheckoutOrderSummary;
                _checkoutOrderSummary.DisplayReadOnlyGrid   = true;
                _checkoutOrderSummary.FlattenProductDetails = true;
                _checkoutOrderSummary.OrderSummaryText      = GetLocalResourceObject("OrderSummaryStaticText").ToString();
                _checkoutOrderSummary.OmnitureState         = "purchase|" + OrderNumber;
                plCheckOutOrderDetails.Controls.Add(_checkoutOrderSummary);
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl))
            {
                var _checkoutOptionsControl =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl);

                var _checkOutOptions = _checkoutOptionsControl as CheckOutOptions;
                _checkOutOptions.IsStatic = (Page as ProductsBase).CheckoutOptionsAreStatic;
                _checkOutOptions.DisplayHoursOfOperationForPickup = true;
                var _Message      = (Label)_checkOutOptions.FindControl("lblMessage");
                var _Notifiaction = (Label)_checkOutOptions.FindControl("lblMessageNotifyReadOnly");
                if (_Message != null && _Notifiaction != null)
                {
                    _Message.Visible      = HLConfigManager.Configurations.CheckoutConfiguration.CheckOutShowNotification;
                    _Notifiaction.Visible = HLConfigManager.Configurations.CheckoutConfiguration.CheckOutMessageNotify;
                }

                plCheckOutOptions.Controls.Add(_checkOutOptions);
            }
            if (DisplayInvoiceOptions)
            {
                if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.InvoiceOptionsControl))
                {
                    _invoicOptions =
                        LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.InvoiceOptionsControl) as
                        InvoiceOptions;
                    _invoicOptions.IsReadOnly = true;
                    plInvoiceOptions.Controls.Add(_invoicOptions);
                }
            }
            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.PaymentsConfiguration.PaymentsSummaryControl))
            {
                _paymentsSummary =
                    LoadControl(HLConfigManager.Configurations.PaymentsConfiguration.PaymentsSummaryControl) as
                    PaymentsSummary;
                plPaymentOptions.Controls.Add(_paymentsSummary);
            }
            PolicyMessage.Visible = HLConfigManager.Platform == "PCAD";
            if (
                HLConfigManager.Configurations.DOConfiguration
                .AllowHFFModal)
            {
                var _hFFModal = LoadControl("~/Ordering/Controls/HFFModal.ascx") as HFFModal;
                plHFFModal.Controls.Add(_hFFModal);
                ((OrderingMaster)Page.Master).EventBus.RegisterObject(_hFFModal);
            }
            // Display the HFF message if the item is in the cart
            if (HLConfigManager.Configurations.DOConfiguration.AllowHFF &&
                HLConfigManager.Configurations.DOConfiguration.ShowHFFMessage &&
                !string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku))
            {
                if (
                    ShoppingCart.CartItems.Any(
                        i => i.SKU == HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku))
                {
                    HFFMessage.Visible = true;
                }
            }
            if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && SessionInfo.IsHAPMode &&
                !string.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl))
            {
                var _checkoutHAPOptions =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl);
                plCheckOutHAPOptions.Controls.Add(_checkoutHAPOptions);
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HLConfigManager.Configurations.DOConfiguration.IsChina && !SessionInfo.IsReplacedPcOrder)
            {
                var SurveyEligibility = Providers.China.OrderProvider.GetCustomerSurvey(DistributorID);
                if (SurveyEligibility != null)
                {
                    if (Session["CustomerSurveyCancelled"] == null ||
                        !Convert.ToBoolean(Session["CustomerSurveyCancelled"]))
                    {
                        Response.Redirect("Survey.aspx?@ctrl=CustomerSurvey");
                    }
                }
                else if (SessionInfo.surveyDetails != null && ShoppingCart.CartItems.Any() &&
                         ShoppingCart.CartItems.Find(
                             x => x.SKU == SessionInfo.surveyDetails.SurveySKU.Trim()) == null &&
                         !SessionInfo.surveyDetails.SurveyCompleted)
                {
                    Providers.China.OrderProvider.AddFreeGift(
                        SessionInfo.surveyDetails.SurveySKU.Trim(),
                        SessionInfo.surveyDetails.SurveySKUQuantity,
                        ProductInfoCatalog.AllSKUs, ShoppingCart.DeliveryInfo.WarehouseCode, ShoppingCart);
                }
            }

            (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderProducts").ToString());

            if (ShoppingCart.OrderCategory == OrderCategoryType.ETO)
            {
                (Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("PageHeaderEvents").ToString());
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl))
            {
                var _checkoutOptionsControl =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOptionsControl);

                _checkoutOptions          = _checkoutOptionsControl as CheckOutOptions;
                _checkoutOptions.IsStatic = (Page as ProductsBase).CheckoutOptionsAreStatic;
                plCartOptions.Controls.Add(_checkoutOptions);
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsMiniControl))
            {
                var _checkoutTotalsMini =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutTotalsMiniControl);
                plCheckOutTotalsMini.Controls.Add(_checkoutTotalsMini);
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl) &&
                HLConfigManager.Configurations.DOConfiguration.AllowHAP && ShoppingCart.OrderCategory == OrderCategoryType.HSO)
            {
                var _checkoutHAPOptions =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckOutHAPOptionsControl);
                plCheckOutHAPOptions.Controls.Add(_checkoutHAPOptions);

                if (ShoppingCart.DsType == null)
                {
                    var DistributorType = DistributorOrderingProfileProvider.CheckDsLevelType(DistributorID, CountryCode);
                    ShoppingCart.DsType = DistributorType;
                }
            }

            if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary))
            {
                _checkoutOrderSummary =
                    LoadControl(HLConfigManager.Configurations.CheckoutConfiguration.CheckoutOrderSummary) as
                    CheckoutOrderSummary;
                _checkoutOrderSummary.DisplayReadOnlyGrid = false;
                _checkoutOrderSummary.OmnitureState       = "scView";
                plCheckOutOrderDetails.Controls.Add(_checkoutOrderSummary);
            }

            if (!IsPostBack)
            {
                // display cart name
                if (HLConfigManager.Configurations.DOConfiguration.AllowSavedCarts)
                {
                    if (ShoppingCart != null && ShoppingCart.IsSavedCart &&
                        !ShoppingCart.IsFromCopy && !string.IsNullOrEmpty(ShoppingCart.CartName))
                    {
                        SavedCartTitle.Visible = true;
                        lblSavedCartName.Text  = string.Format(GetLocalResourceObject("lblSavedCartName").ToString(),
                                                               ShoppingCart.CartName);
                    }
                }
                if (ShoppingCart != null && ShoppingCart.CartItems != null && ShoppingCart.CartItems.Count > 0)
                {
                    if (ShoppingCart.DeliveryInfo != null)
                    {
                        var skuList = new List <SKU_V01>();
                        skuList.AddRange(from s in ShoppingCart.CartItems
                                         from k in AllSKUS
                                         where s.SKU == s.SKU
                                         select k.Value);
                        CatalogProvider.GetProductAvailability(skuList, Locale, DistributorID,
                                                               ShoppingCart.DeliveryInfo.WarehouseCode);
                    }
                    findCrossSell(ShoppingCart.CartItems);
                    if (ShoppingCart.CustomerOrderDetail != null)
                    {
                        divcustomerOrderStaticMessage.Visible = true;
                        lblCustomerOrderStaticMessage.Text    =
                            GetLocalResourceObject("CustomerOrderStaticMessage").ToString();
                    }
                }

                else
                {
                    NoCrossSellFound(this, null);
                }

                // Process copy invoice
                var invoiceId = Request.QueryString["invoiceId"];

                if (!string.IsNullOrEmpty(invoiceId) || IsFromMemberInvoice())
                {
                    var isCopingFromInvoice = Session["IsCopingFromInvoice"] as string;
                    if (!string.IsNullOrEmpty(isCopingFromInvoice) && isCopingFromInvoice.Equals("Y"))
                    {
                        // Save the active cart if needed
                        if (ShoppingCart.CartItems.Count != 0 && !ShoppingCart.IsSavedCart)
                        {
                            txtSaveCartName.Text = SaveCartCommand.SuggestCartName(ShoppingCart.DeliveryInfo,
                                                                                   string.Empty, DistributorID, Locale);
                            mdlClearCart.Show();
                        }
                        else
                        {
                            CopyInvoice();
                        }
                    }
                }

                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    HLRulesManager.Manager.ProcessCart(ShoppingCart, ShoppingCartRuleReason.CartItemsAdded);
                }
                var allowedCountries = HL.Common.Configuration.Settings.GetRequiredAppSetting("AllowAPFPopupForStandAloneContries", "CH");
                if (Session["showedAPFPopup"] == null)
                {
                    Session["showedAPFPopup"] = false;
                }
                if (!(bool)Session["showedAPFPopup"] && allowedCountries.Contains(Locale.Substring(3)) && (APFDueProvider.IsAPFDueWithinOneYear(DistributorID, Locale.Substring(3)) || APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)))
                {
                    APFDuermndrPopUp.ShowPopUp();
                }
                if (HLConfigManager.Configurations.AddressingConfiguration.HasAddressRestriction)
                {
                    List <DeliveryOption> shippingAddresses =
                        (Page as ProductsBase).GetShippingProvider()
                        .GetShippingAddresses((Page as ProductsBase).DistributorID,
                                              (Page as ProductsBase).Locale)
                        .Where(s => s.HasAddressRestriction == true)
                        .ToList();
                    if (shippingAddresses.Count == 0)
                    {
                        AddressResPopUP1.ShowAddressRestrictionPopUp();
                    }
                }
            }

            if (HLConfigManager.Configurations.DOConfiguration.IsChina && DistributorOrderingProfile.IsTermConditionAlert)
            {
                // TermConditionPopupExtender.Show();
            }

            (Master as OrderingMaster).SetDivSpacerVisibility(false);
            (Master as OrderingMaster).SetHeaderRowVisibility(false);
            //(this.Master as OrderingMaster).SetRightPanelStyle("margin", "13px 8px");
            if (HLConfigManager.Configurations.DOConfiguration.IsResponsive && (Master as OrderingMaster).IsMobile())
            {
                (Master as OrderingMaster).divLeftVisibility = true;
            }
            else
            {
                (Master as OrderingMaster).divLeftVisibility = false;
            }
            (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-xs-12 col-sm-9 gdo-nav-mid-sp");

            var strScript1 = @"$(document).ready(function()
                                { 
                                    scrollTo(0, 0);
                                });";

            ScriptManager.RegisterStartupScript(this, GetType(), "ScriptPopup", strScript1, true);
            DisplayELearningMessage();

            if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && SessionInfo.IsHAPMode && !string.IsNullOrEmpty(ShoppingCart.HAPAction) && ShoppingCart.HAPAction == "UPDATE")
            {
                divHapEditMessage.Visible = true;
            }
            if (HLConfigManager.Configurations.DOConfiguration.CheckSKUExpirationDate)
            {
                ExpireDatePopUp1.ShowPopUp();
            }
        }