public override bool ProcessStep() { try { //int paymentID = ValidationHelper.GetInteger(SessionHelper.GetValue("PaymentID"), 0); int paymentID = ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPaymentID"); // Cleanup the ShoppingCart ViewState ShoppingCartControl.SetTempValue(SHIPPING_OPTION_ID, null); ShoppingCartControl.SetTempValue(PAYMENT_OPTION_ID, null); //ShoppingCart.ShoppingCartShippingOptionID = selectShipping.ShippingID; //ShoppingCart.ShoppingCartPaymentOptionID = selectPayment.PaymentID; ShoppingCart.ShoppingCartShippingOptionID = IsShippingNeeded ? GetShippingID() : selectShipping.ShippingID; ShoppingCart.ShoppingCartPaymentOptionID = paymentID; // Update changes in database only when on the live site if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart); } return(true); } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message + " /step " + IsShippingNeeded.ToString(); return(false); } }
protected void ddlShippingOption_SelectedIndexChanged(object sender, EventArgs e) { int PriceID = ValidationHelper.GetInteger(ddlShippingOption.SelectedValue, -1); int CountryID = (AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID)).AddressCountryID; // SessionHelper.SetValue("PriceID", PriceID); // SessionHelper.SetValue("CountryID", CountryID); ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartPriceID", PriceID); ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCountryID", CountryID); //btnUpdate_Click1(null, null); //DisplayTotalPrice(); }
private int GetShippingID() { int result = 0; /*GeneralConnection cn= ConnectionHelper.GetConnection(); * string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID") ,"0"); * string stringQuery = string.Format("SELECT ShippingoptionID FROM customtable_shippingextensioncountry WHERE itemid IN (SELECT shippingextensioncountryID FROM customtable_shippingextensionpricing WHERE itemID={0})", priceID); * DataSet ds = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false); * if (!DataHelper.DataSourceIsEmpty(ds)) * { * result = Convert.ToInt32((ds.Tables[0].Rows[0]["ShippingoptionID"])); * }*/ int PriceID = ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPriceID"); int ShippingUnit = ShippingExtendedInfoProvider.GetCartShippingUnit(ShoppingCart); //string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID"), "0"); string priceID = PriceID.ToString(); QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ShippingUnits", ShippingUnit); parameters.Add("@CountryID", (AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID)).AddressCountryID); parameters.Add("@VATRate", 1 + ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart) / 100); string where = string.Format("ItemID={0}", priceID); GeneralConnection cn = ConnectionHelper.GetConnection(); DataSet ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters, where); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow drow in ds.Tables[0].Rows) { result = ValidationHelper.GetInteger(drow["ShippingoptionID"], 0); if (priceID == drow["ItemID"].ToString()) { return(result); } } } return(result); }
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); } }
protected void ddlPaymentOption_SelectedIndexChanged(object sender, EventArgs e) { int PaymentID = ValidationHelper.GetInteger(ddlPaymentOption.SelectedValue, 9); ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartPaymentID", PaymentID); }