protected void Page_Load(object sender, EventArgs e) { bool offerGlobalPaymentMethods = false; mShippingOptionId = QueryHelper.GetInteger("objectid", 0); if (mShippingOptionId > 0) { mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId); EditedObject = mShippingOptionInfoObj; if (mShippingOptionInfoObj != null) { int editedSiteId = mShippingOptionInfoObj.ShippingOptionSiteID; // Check object's site id CheckEditedObjectSiteID(editedSiteId); // Offer global payment methods when allowed offerGlobalPaymentMethods = ECommerceSettings.AllowGlobalPaymentMethods(editedSiteId); DataSet ds = PaymentOptionInfoProvider.GetPaymentOptionsForShipping(mShippingOptionId).OrderBy("PaymentOptionDisplayName"); if (!DataHelper.DataSourceIsEmpty(ds)) { mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "PaymentOptionID")); } if (!RequestHelper.IsPostBack()) { uniSelector.Value = mCurrentValues; } } } uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged; uniSelector.WhereCondition = GetSelectorWhereCondition(offerGlobalPaymentMethods); }
private static bool CheckPaymentIsAllowedForShipping(ShoppingCartInfo currentShoppingCart, int paymentOptionId) { return((currentShoppingCart.ShoppingCartShippingOptionID == 0) || (PaymentOptionInfoProvider.GetPaymentOptionsForShipping(currentShoppingCart.ShoppingCartShippingOptionID, true) .Where("PaymentOptionID", QueryOperator.Equals, paymentOptionId) .TopN(1) .Any())); }
/// <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(); } }
protected void Page_Load(object sender, EventArgs e) { // Check permissions for CMS Desk -> Ecommerce if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.ShippingOptions.PaymentMethods")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.ShippingOptions.PaymentMethods"); } bool offerGlobalPaymentMethods = false; lblAvialable.Text = GetString("com.shippingoption.payments"); mShippingOptionId = QueryHelper.GetInteger("shippingoptionid", 0); if (mShippingOptionId > 0) { mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId); EditedObject = mShippingOptionInfoObj; if (mShippingOptionInfoObj != null) { int editedSiteId = mShippingOptionInfoObj.ShippingOptionSiteID; // Check object's site id CheckEditedObjectSiteID(editedSiteId); // Offer global payment methods when allowed or configuring global shipping option if (editedSiteId != 0) { SiteInfo si = SiteInfoProvider.GetSiteInfo(editedSiteId); if (si != null) { offerGlobalPaymentMethods = ECommerceSettings.AllowGlobalPaymentMethods(si.SiteName); } } // Configuring global shipping option else { offerGlobalPaymentMethods = true; } DataSet ds = PaymentOptionInfoProvider.GetPaymentOptionsForShipping(mShippingOptionId, false); if (!DataHelper.DataSourceIsEmpty(ds)) { mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "PaymentOptionID")); } if (!RequestHelper.IsPostBack()) { uniSelector.Value = mCurrentValues; } } } uniSelector.IconPath = GetObjectIconUrl("ecommerce.paymentoption", "object.png"); uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged; uniSelector.WhereCondition = GetSelectorWhereCondition(offerGlobalPaymentMethods); }