private void HandleAutomaticSelections(ShoppingCartInfo currentShoppingCart)
    {
        if ((currentShoppingCart.ShippingOption == null) && currentShoppingCart.IsShippingNeeded)
        {
            // Try to select shipping option if there is only one in system
            var query = ShippingOptionInfoProvider.GetShippingOptions(currentShoppingCart.ShoppingCartSiteID, true).Column("ShippingOptionID");
            if (query.Count == 1)
            {
                currentShoppingCart.ShoppingCartShippingOptionID = DataHelper.GetIntegerValues(query.Tables[0], "ShippingOptionID").FirstOrDefault();
            }
        }

        if (currentShoppingCart.PaymentOption == null)
        {
            // Try to select payment option if there is only one in system
            var query = PaymentOptionInfoProvider.GetPaymentOptions(currentShoppingCart.ShoppingCartSiteID, true).Column("PaymentOptionID");
            if (query.Count == 1)
            {
                int paymentOptionId = DataHelper.GetIntegerValues(query.Tables[0], "PaymentOptionID").FirstOrDefault();
                // Check if payment is allowed for shipping, or shipping is not set
                if (CheckPaymentIsAllowedForShipping(currentShoppingCart, paymentOptionId))
                {
                    currentShoppingCart.ShoppingCartPaymentOptionID = paymentOptionId;
                }
            }
        }
    }
    /// <summary>
    /// Checks payment methods.
    /// </summary>
    private void CheckPaymentMethods()
    {
        if (PaymentMethodsCheck)
        {
            // Get all payment options
            DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions("PaymentOptionEnabled = 1", "PaymentOptionID", 0, "PaymentOptionID", CMSContext.CurrentSiteID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Build where condition
                StringBuilder sb = new StringBuilder();
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    sb.Append(row["PaymentOptionID"] + ",");
                }
                sb.Remove(sb.Length - 1, 1);

                // Check if at least one is assigned to shipping method
                DataSet ds2 = PaymentShippingInfoProvider.GetPaymentShippings("PaymentOptionID IN (" + sb.ToString() + ")", null, 1, "PaymentOptionID");
                if (DataHelper.DataSourceIsEmpty(ds2))
                {
                    DisplayMessage("com.settingschecker.nopaymentoptionsshippingmethod");
                }
            }
            // If there is no Payment option, it shows error
            else
            {
                DisplayMessage("com.settingschecker.nopaymentoptions");
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Checks payment methods.
    /// </summary>
    private void CheckPaymentMethods()
    {
        if (PaymentMethodsCheck)
        {
            // Get all payment options
            DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions(SiteContext.CurrentSiteID, true).Column("PaymentOptionID").OrderBy("PaymentOptionID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Build where condition
                var paymentIds = DataHelper.GetIntegerValues(ds.Tables[0], "PaymentOptionID");

                // Check if at least one is assigned to shipping method
                DataSet ds2 = PaymentShippingInfoProvider.GetPaymentShippings().TopN(1).Column("PaymentOptionID").WhereIn("PaymentOptionID", paymentIds);
                if (DataHelper.DataSourceIsEmpty(ds2))
                {
                    DisplayMessage("com.settingschecker.nopaymentoptionsshippingmethod");
                }
            }
            // Show error if there is no payment option
            else
            {
                DisplayMessage("com.settingschecker.nopaymentoptions");
            }
        }
    }
    private void LoadControlData(bool forceReload = false)
    {
        var paymentOptions = PaymentOptionInfoProvider.GetPaymentOptions(ShoppingCart.ShoppingCartSiteID, true)
                             .Column("PaymentOptionID")
                             .OrderBy("PaymentOptionDisplayName");

        if (ShoppingCart.ShippingOption == null || !ShoppingCart.IsShippingNeeded)
        {
            paymentOptions.WhereTrue("PaymentOptionAllowIfNoShipping");
        }

        var paymentIds = paymentOptions.GetListResult <int>();

        // If there is only one payment method set it
        if (paymentIds.Count == 1)
        {
            var paymentOptionID = paymentIds.First();
            ShoppingService.SetPaymentOption(paymentOptionID);
            drpPayment.SelectedID = paymentOptionID;

            // Make sure that in-memory changes persist (unsaved address, etc.)
            Service.Resolve <ICurrentShoppingCartService>().SetCurrentShoppingCart(ShoppingCart);
        }

        drpPayment.DisplayOnlyAllowedIfNoShipping = (ShoppingCart.ShoppingCartShippingOptionID <= 0) || !ShoppingCart.IsShippingNeeded;

        if (!RequestHelper.IsPostBack() || forceReload || ((ShoppingCart.ShoppingCartPaymentOptionID != 0) && !PaymentOptionInfoProvider.IsPaymentOptionApplicable(ShoppingCart, ShoppingCart.PaymentOption)))
        {
            // Reset selector on shipping changed event if selected payment is not allowed for current shipping (zero shipping id is Please select state).
            drpPayment.Reload();
            drpPayment.SelectedID = ShoppingService.GetPaymentOption();
        }
    }
        //EndDocSection:LoadingAddress


        //DocSection:PreparePayment
        /// <summary>
        /// Gets all applicable payment methods assigned to the current site.
        /// </summary>
        /// <param name="cart">Shopping cart of the site</param>
        /// <returns>Collection of applicable payment methods</returns>
        private IEnumerable <PaymentOptionInfo> GetApplicablePaymentMethods(ShoppingCartInfo cart)
        {
            // Gets all enabled payment methods from Kentico
            IEnumerable <PaymentOptionInfo> enabledPaymentMethods = PaymentOptionInfoProvider.GetPaymentOptions(SiteContext.CurrentSiteID, true).ToList();

            // Returns all applicable payment methods
            return(enabledPaymentMethods.Where(paymentMethod => PaymentOptionInfoProvider.IsPaymentOptionApplicable(cart, paymentMethod)));
        }
    /// <summary>
    /// Control initialization.
    /// </summary>
    public void SetupControl()
    {
        if (!StopProcessing)
        {
            // Set up empty record text. The macro ResourcePrefix + .empty represents empty record value.
            drpPayment.UniSelector.ResourcePrefix = "com.livesiteselector";

            DataSet dsOptions;

            // Get correct payment options if shipping is set or not
            if (ShoppingCart.ShippingOption != null)
            {
                dsOptions = PaymentOptionInfoProvider.GetPaymentOptionsForShipping(ShoppingCart.ShippingOption.ShippingOptionID, true)
                            .Column("PaymentOptionID")
                            .OrderBy("PaymentOptionDisplayName");
            }
            else
            {
                dsOptions = PaymentOptionInfoProvider.GetPaymentOptions(ShoppingCart.ShoppingCartSiteID, true)
                            .Column("PaymentOptionID")
                            .WhereTrue("PaymentOptionAllowIfNoShipping")
                            .OrderBy("PaymentOptionDisplayName");
            }

            IList <int> paymentIds = new List <int>();

            if (!DataHelper.DataSourceIsEmpty(dsOptions))
            {
                paymentIds = DataHelper.GetIntegerValues(dsOptions.Tables[0], "PaymentOptionID");
            }

            // If there is only one payment method set it.
            if (paymentIds.Count == 1)
            {
                ShoppingCart.ShoppingCartPaymentOptionID = paymentIds.FirstOrDefault();
                drpPayment.SelectedID = ShoppingCart.ShoppingCartPaymentOptionID;
            }

            // Set selected shipping option to determine available payment options
            drpPayment.ShippingOptionID = ShoppingCart.ShoppingCartShippingOptionID;
            drpPayment.DisplayOnlyAllowedIfNoShipping = (drpPayment.ShippingOptionID <= 0);

            if ((ShoppingCart.ShoppingCartPaymentOptionID != 0) && !paymentIds.Contains(ShoppingCart.ShoppingCartPaymentOptionID))
            {
                // Reset selector on shipping changed event if selected payment is not allowed for current shipping (zero shipping id is Please select state).
                ResetSelector();
            }

            // Update selection
            if (!RequestHelper.IsPostBack())
            {
                PreselectPaymentOption();
            }

            drpPayment.Reload();
        }
    }
        public PaymentMethod[] GetPaymentMethods()
        {
            var paymentOptionInfoCollection = PaymentOptionInfoProvider.GetPaymentOptions(SiteContext.CurrentSiteID).Where(p => p.PaymentOptionEnabled).ToArray();
            var methods = mapper.Map <PaymentMethod[]>(paymentOptionInfoCollection);

            foreach (var method in methods)
            {
                method.Title = resources.ResolveMacroString(method.DisplayName);
            }
            return(methods);
        }
    // Displays PaymentList
    private void ShowPaymentList()
    {
        DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions(CurrentSite.SiteID, true);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            ddlPaymentOption.DataSource     = ds;
            ddlPaymentOption.DataTextField  = "PaymentOptionDisplayName";
            ddlPaymentOption.DataValueField = "PaymentOptionId";
            ddlPaymentOption.DataBind();
            ddlPaymentOption.SelectedValue = ValidationHelper.GetString(SessionHelper.GetValue("PaymentID"), string.Empty);
            ddlPaymentOption_SelectedIndexChanged(null, null);
        }
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check input values from textboxes and other contrlos
        string errorMessage = new Validator()
                              .NotEmpty(txtPaymentOptionDisplayName.Text.Trim(), GetString("paymentoption_edit.errorEmptyDisplayName"))
                              .NotEmpty(txtPaymentOptionName.Text.Trim(), GetString("paymentoption_edit.errorEmptyCodeName")).Result;

        if (!ValidationHelper.IsCodeName(txtPaymentOptionName.Text.Trim()))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentifierFormat");
        }

        if (errorMessage == "")
        {
            // PaymentOptionName must be unique
            PaymentOptionInfo paymentOptionObj = null;
            string            siteWhere        = (mSiteId > 0) ? " AND (PaymentOptionSiteID = " + mSiteId + " OR PaymentOptionSiteID IS NULL)" : "";
            DataSet           ds = PaymentOptionInfoProvider.GetPaymentOptions("PaymentOptionName = '" + txtPaymentOptionName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                paymentOptionObj = new PaymentOptionInfo(ds.Tables[0].Rows[0]);
            }

            if ((paymentOptionObj == null) || (paymentOptionObj.PaymentOptionID == mPaymentOptionId))
            {
                // Get the object
                if (paymentOptionObj == null)
                {
                    paymentOptionObj = PaymentOptionInfoProvider.GetPaymentOptionInfo(mPaymentOptionId);
                    if (paymentOptionObj == null)
                    {
                        paymentOptionObj = new PaymentOptionInfo();
                        paymentOptionObj.PaymentOptionSiteID = mSiteId;
                    }
                }

                // Fill object
                paymentOptionObj.PaymentOptionID                     = mPaymentOptionId;
                paymentOptionObj.PaymentOptionDisplayName            = txtPaymentOptionDisplayName.Text.Trim();
                paymentOptionObj.PaymentOptionDescription            = txtDescription.Text.Trim();
                paymentOptionObj.PaymentOptionName                   = txtPaymentOptionName.Text.Trim();
                paymentOptionObj.PaymentOptionEnabled                = chkPaymentOptionEnabled.Checked;
                paymentOptionObj.PaymentOptionPaymentGateUrl         = txtGateUrl.Text.Trim();
                paymentOptionObj.PaymentOptionClassName              = txtPaymentClassName.Text.Trim();
                paymentOptionObj.PaymentOptionAssemblyName           = txtPaymentAssemblyName.Text.Trim();
                paymentOptionObj.PaymentOptionSucceededOrderStatusID = succeededElem.OrderStatusID;
                paymentOptionObj.PaymentOptionFailedOrderStatusID    = failedElem.OrderStatusID;
                paymentOptionObj.PaymentOptionAllowIfNoShipping      = chkAllowIfNoShipping.Checked;

                CheckConfigurationModification(paymentOptionObj.PaymentOptionSiteID);

                bool isNew = (paymentOptionObj.PaymentOptionID <= 0);

                PaymentOptionInfoProvider.SetPaymentOptionInfo(paymentOptionObj);

                // Upload image teaser
                if (isNew)
                {
                    file.ObjectID = paymentOptionObj.PaymentOptionID;
                    file.UploadFile();
                }

                URLHelper.Redirect("PaymentOption_Edit.aspx?paymentOptionId=" + Convert.ToString(paymentOptionObj.PaymentOptionID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                // Show error message
                ShowError(GetString("PaymentOption_Edit.PaymentOptionNameExists"));
            }
        }
        else
        {
            // Show error message
            ShowError(errorMessage);
        }
    }
 /// <summary>
 /// Returns an enumerable collection of all enabled payment methods.
 /// </summary>
 /// <returns>Collection of enabled payment methods. See <see cref="PaymentOptionInfo"/> for detailed information.</returns>
 public IEnumerable <PaymentOptionInfo> GetAll()
 {
     return(PaymentOptionInfoProvider.GetPaymentOptions(SiteID, true)
            .ToList());
 }
        private void GenerateEcommerceData(int siteID)
        {
            var siteName     = SiteInfoProvider.GetSiteName(siteID);
            var currencyInfo = CurrencyInfoProvider.GetCurrencies(siteID)
                               .Where("CurrencyIsMain", QueryOperator.Equals, 1).TopN(1).FirstOrDefault();
            var list1 = PaymentOptionInfoProvider.GetPaymentOptions(siteID).ToList();
            var list2 = ShippingOptionInfoProvider.GetShippingOptions(siteID).ToList();

            var orderStatusList = OrderStatusInfoProvider.GetOrderStatuses(siteID).ToDictionary(status => status.StatusName);

            var manufacturerExceptionList = new List <int>
            {
                ManufacturerInfoProvider.GetManufacturerInfo("Aerobie", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Chemex", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Espro", siteName).ManufacturerID
            };
            var list3 = SKUInfoProvider.GetSKUs(siteID).ToList().Where(sku =>
            {
                if (sku.IsProduct)
                {
                    return(!manufacturerExceptionList.Contains(sku.SKUManufacturerID));
                }
                return(false);
            }).ToList();
            int         num1;
            IList <int> intList;

            if (CustomerInfoProvider.GetCustomers().WhereEquals("CustomerSiteID", siteID).Count < 50)
            {
                num1    = customerNames.Length;
                intList = new List <int>();
                for (var index = 0; index < num1; ++index)
                {
                    intList.Add(GenerateCustomer(customerNames[index], siteID).CustomerID);
                }
            }
            else
            {
                intList = DataHelper.GetIntegerValues(CustomerInfoProvider.GetCustomers().Column("CustomerID")
                                                      .WhereEquals("CustomerSiteID", siteID).WhereNotEquals("CustomerEmail", "alex").Tables[0],
                                                      "CustomerID");
                num1 = intList.Count;
            }

            var num2 = 0;
            var num3 = 0;

            for (var index1 = 0; index1 <= 30; ++index1)
            {
                ++num2;
                var num4 = 0;
                if (index1 > 5)
                {
                    num4 = rand.Next(-1, 2);
                }
                for (var index2 = 0; index2 < num2 / 2 + num4; ++index2)
                {
                    var orderStatusInfo = index1 >= 25
                        ? index1 >= 29 ? orderStatusList["New"] : orderStatusList["InProgress"]
                        : orderStatusList["Completed"];
                    var orderInfo = new OrderInfo
                    {
                        OrderCustomerID = intList[num3 % num1],
                        OrderCurrencyID = currencyInfo.CurrencyID,
                        OrderSiteID     = siteID,
                        OrderStatusID   = orderStatusInfo.StatusID,
                        OrderIsPaid     = "Completed".Equals(orderStatusInfo.StatusName, StringComparison.Ordinal) ||
                                          (uint)rand.Next(0, 2) > 0U,
                        OrderShippingOptionID         = list2[rand.Next(list2.Count)].ShippingOptionID,
                        OrderPaymentOptionID          = list1[rand.Next(list1.Count)].PaymentOptionID,
                        OrderGrandTotal               = decimal.Zero,
                        OrderGrandTotalInMainCurrency = decimal.Zero,
                        OrderTotalPrice               = decimal.Zero,
                        OrderTotalPriceInMainCurrency = decimal.Zero,
                        OrderTotalShipping            = new decimal(10),
                        OrderTotalTax = new decimal(10)
                    };
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    var orderItems = GenerateOrderItems(orderInfo, list3);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Billing);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Shipping);
                    orderInfo.OrderDate       = DateTime.Now.AddDays(index1 - 30);
                    orderInfo.OrderTotalPrice = orderItems;
                    orderInfo.OrderTotalPriceInMainCurrency = orderItems;
                    orderInfo.OrderGrandTotal = orderItems;
                    orderInfo.OrderGrandTotalInMainCurrency = orderItems;
                    var cartInfoFromOrder = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderInfo.OrderID);
                    orderInfo.OrderInvoiceNumber = OrderInfoProvider.GenerateInvoiceNumber(cartInfoFromOrder);
                    orderInfo.OrderInvoice       = ShoppingCartInfoProvider.GetOrderInvoice(cartInfoFromOrder);
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    ++num3;
                }
            }

            if (UserInfoProvider.GetUserInfo("alex") != null)
            {
                return;
            }
            var customerInfo = new CustomerInfo
            {
                CustomerEmail             = "*****@*****.**",
                CustomerFirstName         = "Alexander",
                CustomerLastName          = "Adams",
                CustomerSiteID            = siteID,
                CustomerCompany           = "Alex & Co. Ltd",
                CustomerTaxRegistrationID = "12S379BDF798",
                CustomerOrganizationID    = "WRQ7987VRG79"
            };

            CustomerInfoProvider.SetCustomerInfo(customerInfo);
            var userInfo = CustomerInfoProvider.RegisterCustomer(customerInfo, "", "alex");
            var roleInfo = RoleInfoProvider.GetRoleInfo("SilverPartner", siteID);

            if (roleInfo != null)
            {
                UserInfoProvider.AddUserToRole(userInfo.UserID, roleInfo.RoleID);
            }
            for (var index = 0; index < 5; ++index)
            {
                var cart = new ShoppingCartInfo();
                cart.ShoppingCartCulture         = CultureHelper.GetDefaultCultureCode(siteName);
                cart.ShoppingCartCurrencyID      = currencyInfo.CurrencyID;
                cart.ShoppingCartSiteID          = siteID;
                cart.ShoppingCartCustomerID      = customerInfo.CustomerID;
                cart.ShoppingCartBillingAddress  = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.ShoppingCartShippingAddress = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.User = userInfo;
                ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
                ShoppingCartInfoProvider.SetShoppingCartItem(cart,
                                                             new ShoppingCartItemParameters(list3.ElementAt(rand.Next(list3.Count)).SKUID, rand.Next(5)));
                cart.Evaluate();
                ShoppingCartInfoProvider.SetOrder(cart);
            }
        }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        EventLogProvider p = new EventLogProvider();

        // Init labels
        lblTitle.Text    = GetString("shoppingcart.shippingpaymentoptions");
        lblPayment.Text  = GetString("shoppingcartpaymentshipping.payment");
        lblShipping.Text = GetString("shoppingcartpaymentshipping.shipping");

        selectShipping.IsLiveSite = IsLiveSite;
        selectPayment.IsLiveSite  = IsLiveSite;

        if ((ShoppingCart != null) && (SiteContext.CurrentSite != null))
        {
            if (ShoppingCart.CountryID == 0)
            {
                string      countryName = ECommerceSettings.DefaultCountryName(SiteContext.CurrentSite.SiteName);
                CountryInfo ci          = CountryInfoProvider.GetCountryInfo(countryName);
                ShoppingCart.CountryID = (ci != null) ? ci.CountryID : 0;
            }

            selectShipping.ShoppingCart = ShoppingCart;
        }

        if (!ShoppingCartControl.IsCurrentStepPostBack)
        {
            if (IsShippingNeeded)
            {
                p.LogEvent("I", DateTime.Now, "SHIPPING NEED TRUE", "");
                SelectShippingOption();
            }
            else
            {
                p.LogEvent("I", DateTime.Now, "SHIPPING NEED FALSE", "");
                // Don't use shipping selection
                selectShipping.StopProcessing = true;

                // Hide title
                lblTitle.Visible = false;

                // Change current checkout process step caption
                ShoppingCartControl.CheckoutProcessSteps[ShoppingCartControl.CurrentStepIndex].Caption = GetString("order_new.paymentshipping.titlenoshipping");
            }
        }
        AddressInfo aiBill = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID);
        AddressInfo aiShip = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID);

        if (aiBill != null && aiShip != null)
        {
            addressData.Text = string.Format("<h1> ADDRESS DATA </h1> <br/>{0} - {1} <br/> {2} - {3}", aiBill.AddressID.ToString(), aiBill.AddressCity, aiShip.AddressID.ToString(), aiShip.AddressCity);
        }
        else
        {
            if (aiBill == null)
            {
                addressData.Text = "AIBILL NULL";
            }
            if (aiShip == null)
            {
                addressData.Text = string.Format("{0} AISHIP NULL", addressData.Text);
            }
        }
        // bind drop ddlShippingOption
        DataSet ds, dsoi = null;

        double vat = ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart);

        p.LogEvent("I", DateTime.Now, "TVA du BO : " + vat, "code B.O");
        if (vat > 0)
        {
            vat = 1.06;
        }
        else
        {
            vat = 1;
        }

        p.LogEvent("I", DateTime.Now, "ShoppingCart.ShoppingCartShippingAddressID : " + ShoppingCart.ShoppingCartShippingAddressID, "code B.O");
        var addrezz = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID);

        if (addrezz != null)
        {
            var newCountryId = addrezz.AddressCountryID;
            QueryDataParameters parameters = new QueryDataParameters();
            ShippingUnit = ShippingExtendedInfoProvider.GetCartShippingUnit(ShoppingCart);
            p.LogEvent("I", DateTime.Now, "shipping du B.O : " + ShippingUnit, "code B.O");
            parameters.Add("@ShippingUnits", ShippingUnit);
            parameters.Add("@CountryID", newCountryId);
            parameters.Add("@VATRate", vat);
            //parameters.Add("@VATRate", 1 + ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart) / 100);
            GeneralConnection cn = ConnectionHelper.GetConnection();
            ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataTable dt = ds.Tables[0];
                foreach (DataRow drow in dt.Rows)
                {
                    double price  = Convert.ToDouble(drow["ShippingFinalCost"]);
                    string prices = CurrencyInfoProvider.GetFormattedPrice(price, ShoppingCart.Currency);
                    drow["DisplayString"] = string.Format("{0}- {1}", drow["ShippingOptionDisplayName"].ToString(), prices);
                }

                ddlShippingOption.DataSource    = ds;
                ddlShippingOption.SelectedIndex = -1;
                ddlShippingOption.SelectedValue = null;
                ddlShippingOption.ClearSelection();
                ddlShippingOption.DataTextField  = "DisplayString";
                ddlShippingOption.DataValueField = "ItemID";
                ddlShippingOption.DataBind();
                ddlShippingOption.AutoPostBack = (ddlShippingOption.Items.Count > 1);
                // string value = ValidationHelper.GetString(SessionHelper.GetValue("CarriedOnPriceID"), string.Empty);
                string value = ValidationHelper.GetString(ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartCarriedOnPriceID"), string.Empty);

                if (!string.IsNullOrEmpty(value) && ddlShippingOption.Items.Count > 1)
                {
                    if (int.Parse(value) > 0)
                    {
                        // SessionHelper.SetValue("CarriedOnPriceID", string.Empty);
                        ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCarriedOnPriceID", -1);
                        try
                        {
                            ddlShippingOption.SelectedValue = value;
                        }
                        catch
                        {
                        }
                    }
                }
                //int PriceID = ValidationHelper.GetInteger(ddlShippingOption.SelectedValue, -1);
                //SessionHelper.SetValue("PriceID", PriceID);

                // SessionHelper.SetValue("CountryID", ai.AddressCountryID);
                ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCountryID", newCountryId);

                ddlShippingOption_SelectedIndexChanged(null, null);
                //btnUpdate_Click1(null, null);
            }

            else
            {
                // NO SHIPPING AVAILABLE
                ddlShippingOption.Items.Clear();
                ddlShippingOption.DataSource = null;
                ListItem listItem = new ListItem("Votre choix", "-1");
                ddlShippingOption.Items.Add(listItem);
            }
        }


        // bind drop ddlPaymentOption
        string where = "PaymentOptionEnabled=1 AND PaymentOptionID != 9";
        string orderby = "PaymentOptionName";
        //DataSet ds = PaymentOptionInfoProvider.GetPaymentOptions(CurrentSite.SiteID, true);
        DataSet ds2 = PaymentOptionInfoProvider.GetPaymentOptions(where, orderby);

        if (!DataHelper.DataSourceIsEmpty(ds2))
        {
            ddlPaymentOption.DataSource     = ds2;
            ddlPaymentOption.DataTextField  = "PaymentOptionDisplayName";
            ddlPaymentOption.DataValueField = "PaymentOptionId";
            ddlPaymentOption.DataBind();
            // string value = ValidationHelper.GetString(SessionHelper.GetValue("PaymentID"), string.Empty);
            string value = ValidationHelper.GetString(ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPaymentID"), string.Empty);
            if (!string.IsNullOrEmpty(value))
            {
                ddlPaymentOption.SelectedValue = value;
            }
            ddlPaymentOption_SelectedIndexChanged(null, null);
        }
    }