Пример #1
0
    /// <summary>
    /// Adds price to individual shipping options when shopping cart object supplied.
    /// </summary>
    /// <param name="item">Shipping option item to add price to.</param>
    protected override void OnListItemCreated(ListItem item)
    {
        // Adding price to shipping option is not required
        if (!DisplayShippingOptionPrice)
        {
            return;
        }

        if ((item != null) && (ShoppingCart != null))
        {
            // Calculate hypothetical shipping cost for shipping option from supplied list item
            var optionID = ValidationHelper.GetInteger(item.Value, 0);
            var option   = ShippingOptionInfoProvider.GetShippingOptionInfo(optionID);

            var shippingPrice  = CalculateShipping(option);
            var formattedPrice = CurrencyInfoProvider.GetFormattedPrice(shippingPrice, ShoppingCart.Currency, false);

            if (shippingPrice > 0)
            {
                var detailInfo = $"({formattedPrice})";
                var rtl        = IsLiveSite ? CultureHelper.IsPreferredCultureRTL() : CultureHelper.IsUICultureRTL();

                if (rtl)
                {
                    item.Text = $"{detailInfo} {item.Text}";
                }
                else
                {
                    item.Text += $" {detailInfo}";
                }
            }
        }
    }
Пример #2
0
    /// <summary>
    /// Ensures that only applicable shipping options are displayed in selector.
    /// </summary>
    /// <param name="ds">Dataset with shipping options.</param>
    protected override DataSet OnAfterRetrieveData(DataSet ds)
    {
        if (DataHelper.IsEmpty(ds) || (ShoppingCart == null))
        {
            return(ds);
        }

        foreach (DataRow shippingRow in ds.Tables[0].Select())
        {
            ShippingOptionInfo shippingOptionInfo;

            if (UseNameForSelection)
            {
                var shippingName = DataHelper.GetStringValue(shippingRow, "ShippingOptionName");
                shippingOptionInfo = ShippingOptionInfoProvider.GetShippingOptionInfo(shippingName, ShoppingCart.SiteName);
            }
            else
            {
                var shippingID = DataHelper.GetIntValue(shippingRow, "ShippingOptionID");
                shippingOptionInfo = ShippingOptionInfoProvider.GetShippingOptionInfo(shippingID);
            }

            // Do not remove already selected item even if the option is not applicable anymore
            // The user would see a different value in UI as is actually stored in the database
            var canBeRemoved = !EnsureSelectedItem || (ShoppingCart.ShoppingCartShippingOptionID != shippingOptionInfo.ShippingOptionID);
            if (canBeRemoved && !ShippingOptionInfoProvider.IsShippingOptionApplicable(ShoppingCart, shippingOptionInfo))
            {
                ds.Tables[0].Rows.Remove(shippingRow);
            }
        }

        return(ds);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        mShippingOptionId = QueryHelper.GetInteger("objectid", 0);
        if (mShippingOptionId > 0)
        {
            mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
            EditedObject           = mShippingOptionInfoObj;

            if (mShippingOptionInfoObj != null)
            {
                // Check object's site id
                CheckEditedObjectSiteID(mShippingOptionInfoObj.ShippingOptionSiteID);

                DataSet ds = ShippingOptionTaxClassInfoProvider.GetShippingOptionTaxClasses(mShippingOptionId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.OrderBy             = "TaxClassDisplayName";
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        mShippingOptionId = QueryHelper.GetInteger("shippingOptionID", 0);

        string             shippingOptionName = "";
        ShippingOptionInfo soi = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);

        if (soi != null)
        {
            editedSiteId = soi.ShippingOptionSiteID;

            // Check site ID
            CheckEditedObjectSiteID(editedSiteId);
            shippingOptionName = ResHelper.LocalizeString(soi.ShippingOptionDisplayName);
        }

        // Initializes page title and breadcrumbs
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("ShippingOption_EditHeader.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ShippingOptions/ShippingOption_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "configEdit";
        breadcrumbs[1, 0]     = FormatBreadcrumbObjectName(shippingOptionName, editedSiteId);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";

        CMSMasterPage master = (CMSMasterPage)CurrentMaster;

        master.Title.Breadcrumbs  = breadcrumbs;
        master.Tabs.OnTabCreated += Tabs_OnTabCreated;
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            var editElementName = IsMultiStoreConfiguration ? "Edit.Ecommerce.GlobalShippingOptions.Properties" : "Edit.Configuration.ShippingOptionProperties";
            URLHelper.Redirect(UIContextHelper.GetElementUrl("CMS.Ecommerce", editElementName, false, actionArgument.ToInteger(0)));
        }
        else if (actionName == "delete")
        {
            var shippingInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(ValidationHelper.GetInteger(actionArgument, 0));
            // Nothing to delete
            if (shippingInfoObj == null)
            {
                return;
            }

            // Check permissions
            CheckConfigurationModification(shippingInfoObj.ShippingOptionSiteID);

            // Check dependencies
            if (shippingInfoObj.Generalized.CheckDependencies())
            {
                // Show error message
                ShowError(GetString("Ecommerce.DeleteDisabled"));

                return;
            }
            // Delete ShippingOptionInfo object from database
            ShippingOptionInfoProvider.DeleteShippingOptionInfo(shippingInfoObj);
        }
    }
Пример #6
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("ShippingOption_Edit_Frameset.aspx?shippingOptionID=" + Convert.ToString(actionArgument) + "&siteId=" + SelectSite.SiteID);
        }
        else if (actionName == "delete")
        {
            ShippingOptionInfo shippingInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(ValidationHelper.GetInteger(actionArgument, 0));
            // Nothing to delete
            if (shippingInfoObj == null)
            {
                return;
            }

            // Check permissions
            CheckConfigurationModification(shippingInfoObj.ShippingOptionSiteID);

            // Check dependencies
            if (ShippingOptionInfoProvider.CheckDependencies(shippingInfoObj.ShippingOptionID))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Ecommerce.DeleteDisabled");
                return;
            }
            // Delete ShippingOptionInfo object from database
            ShippingOptionInfoProvider.DeleteShippingOptionInfo(shippingInfoObj);
        }
    }
        //EndDocSection:CouponCodeRemove


        //DocSection:DisplayDelivery
        /// <summary>
        /// Displays the customer details checkout process step.
        /// </summary>
        public ActionResult DeliveryDetails()
        {
            // Gets the current user's shopping cart
            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // If the shopping cart is empty, displays the shopping cart
            if (cart.IsEmpty)
            {
                return(RedirectToAction(nameof(CheckoutController.ShoppingCart)));
            }

            // Gets all countries for the country selector
            SelectList countries = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName");

            // Creates a collection of shipping options enabled for the current site
            SelectList shippingOptions = CreateShippingOptionList(cart);

            // Loads the customer details
            DeliveryDetailsViewModel model = new DeliveryDetailsViewModel
            {
                Customer       = new CustomerViewModel(shoppingService.GetCurrentCustomer()),
                BillingAddress = new BillingAddressViewModel(shoppingService.GetBillingAddress(), countries, null),
                ShippingOption = new ShippingOptionViewModel(ShippingOptionInfoProvider.GetShippingOptionInfo(shoppingService.GetShippingOption()), shippingOptions)
            };

            // Displays the customer details step
            return(View(model));
        }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mShippingOptionId = QueryHelper.GetInteger("shippingoptionid", 0);

        mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
        EditedObject           = mShippingOptionInfoObj;

        if (mShippingOptionInfoObj != null)
        {
            CheckEditedObjectSiteID(mShippingOptionInfoObj.ShippingOptionSiteID);
            currency = CurrencyInfoProvider.GetMainCurrency(mShippingOptionInfoObj.ShippingOptionSiteID);
        }

        // Init unigrid
        gridElem.OnAction             += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound  += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.OnAfterRetrieveData  += new OnAfterRetrieveData(gridElem_OnAfterRetrieveData);
        gridElem.WhereCondition        = "ShippingCostShippingOptionID = " + mShippingOptionId;
        gridElem.ZeroRowsText          = GetString("com.ui.shippingcost.edit_nodata");
        gridElem.GridView.AllowSorting = false;

        // Prepare the new shipping cost header action
        CurrentMaster.HeaderActions.AddAction(new HeaderAction()
        {
            Text        = GetString("com.ui.shippingcost.edit_new"),
            RedirectUrl = ResolveUrl("ShippingOption_Edit_ShippingCosts_Edit.aspx?shippingCostShippingOptionId=" + mShippingOptionId + "&siteId=" + SiteID),
            ImageUrl    = GetImageUrl("Objects/Ecommerce_ShippingOption/add.png"),
            ControlType = HeaderActionTypeEnum.Hyperlink
        });
    }
Пример #9
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect(UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "Edit.Configuration.ShippingOptionProperties", false, actionArgument.ToInteger(0)));
        }
        else if (actionName == "delete")
        {
            var shippingInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(ValidationHelper.GetInteger(actionArgument, 0));
            // Nothing to delete
            if (shippingInfoObj == null)
            {
                return;
            }

            // Check permissions
            CheckConfigurationModification();

            // Check dependencies
            if (shippingInfoObj.Generalized.CheckDependencies())
            {
                // Show error message
                ShowError(ECommerceHelper.GetDependencyMessage(shippingInfoObj));

                return;
            }
            // Delete ShippingOptionInfo object from database
            ShippingOptionInfoProvider.DeleteShippingOptionInfo(shippingInfoObj);
        }
    }
    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);
    }
        public DeliveryOption GetShippingOption(int id)
        {
            var service = ShippingOptionInfoProvider.GetShippingOptionInfo(id);
            var result  = mapper.Map <DeliveryOption>(service);
            var carrier = CarrierInfoProvider.GetCarrierInfo(service.ShippingOptionCarrierID);

            result.CarrierCode = carrier.CarrierName;
            return(result);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Required field validator error messages initialization
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvName.ErrorMessage        = GetString("COM_ShippingOption_Edit.NameError");
        txtShippingOptionCharge.EmptyErrorMessage      = GetString("COM_ShippingOption_Edit.ChargeError");
        txtShippingOptionCharge.ValidationErrorMessage = GetString("COM_ShippingOption_Edit.ChargePositive");

        // Control initializations
        lblShippingOptionCharge.Text = GetString("COM_ShippingOption_Edit.ShippingOptionChargeLabel");

        // Get shippingOption id from querystring
        mShippingOptionID = QueryHelper.GetInteger("shippingOptionID", 0);
        mEditedSiteId     = ConfiguredSiteID;
        // Edit shipping option
        if (mShippingOptionID > 0)
        {
            ShippingOptionInfo shippingOptionObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionID);
            EditedObject = shippingOptionObj;

            if (shippingOptionObj != null)
            {
                mEditedSiteId = shippingOptionObj.ShippingOptionSiteID;
                CheckEditedObjectSiteID(mEditedSiteId);

                // Init file uploader
                file.ObjectID   = mShippingOptionID;
                file.ObjectType = ECommerceObjectType.SHIPPINGOPTION;
                file.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_THUMBNAIL;
                file.SiteID     = mEditedSiteId;

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(shippingOptionObj);
                    // Show that the shippingOption was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        // Show message
                        ShowChangesSaved();
                    }
                }
            }
        }

        // Ensure currency code after price value
        txtShippingOptionCharge.CurrencySiteID = mEditedSiteId;

        // Check presence of main currency
        string currencyWarning = CheckMainCurrency(mEditedSiteId);

        if (!string.IsNullOrEmpty(currencyWarning))
        {
            ShowWarning(currencyWarning, null, null);
        }
    }
        public ActionResult DeliveryDetails(DeliveryDetailsViewModel model)
        {
            // Gets the user's current shopping cart
            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // Gets all enabled shipping options for the shipping option selector
            SelectList shippingOptions = new SelectList(ShippingOptionInfoProvider.GetShippingOptions(SiteContext.CurrentSiteID, true).ToList(),
                                                        "ShippingOptionID",
                                                        "ShippingOptionDisplayName");

            // If the ModelState is not valid, assembles the country list and the shipping option list and displays the step again
            if (!ModelState.IsValid)
            {
                model.BillingAddress.Countries       = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName");
                model.ShippingOption.ShippingOptions = new ShippingOptionViewModel(ShippingOptionInfoProvider.GetShippingOptionInfo(shoppingService.GetShippingOption()), shippingOptions).ShippingOptions;
                return(View(model));
            }

            // Gets the shopping cart's customer and applies the customer details from the checkout process step
            var customer = shoppingService.GetCurrentCustomer();

            if (customer == null)
            {
                UserInfo userInfo = cart.User;
                if (userInfo != null)
                {
                    customer = CustomerHelper.MapToCustomer(cart.User);
                }
                else
                {
                    customer = new CustomerInfo();
                }
            }
            model.Customer.ApplyToCustomer(customer);

            // Sets the updated customer object to the current shopping cart
            shoppingService.SetCustomer(customer);

            // Gets the shopping cart's billing address and applies the billing address from the checkout process step
            var address = AddressInfoProvider.GetAddressInfo(model.BillingAddress.AddressID) ?? new AddressInfo();

            model.BillingAddress.ApplyTo(address);

            // Sets the address personal name
            address.AddressPersonalName = $"{customer.CustomerFirstName} {customer.CustomerLastName}";

            // Saves the billing address
            shoppingService.SetBillingAddress(address);

            // Sets the selected shipping option and evaluates the cart
            shoppingService.SetShippingOption(model.ShippingOption.ShippingOptionID);

            // Redirects to the next step of the checkout process
            return(RedirectToAction("PreviewAndPay"));
        }
    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);
    }
Пример #15
0
        /// <summary>
        /// Returns a shipping option with the specified identifier.
        /// </summary>
        /// <param name="shippingOptionId">Shipping option's identifier.</param>
        /// <returns><see cref="ShippingOptionInfo"/> object representing a shipping option with the specified identifier. Returns <c>null</c> if not found.</returns>
        public ShippingOptionInfo GetById(int shippingOptionId)
        {
            var shippingInfo = ShippingOptionInfoProvider.GetShippingOptionInfo(shippingOptionId);

            if (shippingInfo == null || shippingInfo.ShippingOptionSiteID != SiteID)
            {
                return(null);
            }

            return(shippingInfo);
        }
        //EndDocSection:DisplayDelivery


        //DocSection:DisplayDeliveryAddressSelector
        /// <summary>
        /// Displays the customer details checkout process step with an address selector for known customers.
        /// </summary>
        public ActionResult DeliveryDetailsAddressSelector()
        {
            // Gets the current user's shopping cart
            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // If the shopping cart is empty, redirects to the shopping cart view
            if (cart.IsEmpty)
            {
                return(RedirectToAction("ShoppingCart"));
            }

            // Gets all countries for the country selector
            SelectList countries = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName");

            // Gets the current customer
            CustomerInfo customer = shoppingService.GetCurrentCustomer();

            // Gets all customer billing addresses for the address selector
            IEnumerable <AddressInfo> customerAddresses = Enumerable.Empty <AddressInfo>();

            if (customer != null)
            {
                customerAddresses = AddressInfoProvider.GetAddresses(customer.CustomerID).ToList();
            }

            // Prepares address selector options
            SelectList addresses = new SelectList(customerAddresses, "AddressID", "AddressName");

            // Gets all enabled shipping options for the shipping option selector
            SelectList shippingOptions = new SelectList(ShippingOptionInfoProvider.GetShippingOptions(SiteContext.CurrentSiteID, true).ToList(), "ShippingOptionID", "ShippingOptionDisplayName");

            // Loads the customer details
            DeliveryDetailsViewModel model = new DeliveryDetailsViewModel
            {
                Customer       = new CustomerViewModel(shoppingService.GetCurrentCustomer()),
                BillingAddress = new BillingAddressViewModel(shoppingService.GetBillingAddress(), countries, addresses),
                ShippingOption = new ShippingOptionViewModel(ShippingOptionInfoProvider.GetShippingOptionInfo(shoppingService.GetShippingOption()), shippingOptions)
            };


            // Displays the customer details step
            return(View(model));
        }
        /// <summary>
        /// Prepares a view model of the preview checkout process step including the shopping cart,
        /// the customer details, and the payment method.
        /// </summary>
        /// <returns>View model with information about the future order.</returns>
        private PreviewAndPayViewModel PreparePreviewViewModel()
        {
            // Gets the current user's shopping cart
            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // Prepares the customer details
            DeliveryDetailsViewModel deliveryDetailsModel = new DeliveryDetailsViewModel
            {
                Customer       = new CustomerViewModel(shoppingService.GetCurrentCustomer()),
                BillingAddress = new BillingAddressViewModel(shoppingService.GetBillingAddress(), null, null),
                ShippingOption = new ShippingOptionViewModel()
                {
                    ShippingOptionID          = cart.ShippingOption.ShippingOptionID,
                    ShippingOptionDisplayName = ShippingOptionInfoProvider.GetShippingOptionInfo(cart.ShippingOption.ShippingOptionID).ShippingOptionDisplayName
                }
            };

            // Prepares the payment method
            PaymentMethodViewModel paymentViewModel = new PaymentMethodViewModel
            {
                PaymentMethods = new SelectList(GetApplicablePaymentMethods(cart), "PaymentOptionID", "PaymentOptionDisplayName")
            };

            // Gets the selected payment method
            PaymentOptionInfo paymentMethod = cart.PaymentOption;

            if (paymentMethod != null)
            {
                paymentViewModel.PaymentMethodID = paymentMethod.PaymentOptionID;
            }

            // Prepares a model from the preview step
            PreviewAndPayViewModel model = new PreviewAndPayViewModel
            {
                DeliveryDetails = deliveryDetailsModel,
                Cart            = new ShoppingCartViewModel(cart),
                PaymentMethod   = paymentViewModel
            };

            return(model);
        }
Пример #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsMultiStoreConfiguration)
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Ecommerce.GlobalShippingOptions.TaxClasses");
        }
        else
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Configuration.ShippingOptions.TaxClasses");
        }

        mShippingOptionId = QueryHelper.GetInteger("objectid", 0);
        if (mShippingOptionId > 0)
        {
            mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
            EditedObject           = mShippingOptionInfoObj;

            if (mShippingOptionInfoObj != null)
            {
                // Check object's site id
                CheckEditedObjectSiteID(mShippingOptionInfoObj.ShippingOptionSiteID);

                DataSet ds = ShippingOptionTaxClassInfoProvider.GetShippingOptionTaxClasses(mShippingOptionId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.OrderBy             = "TaxClassDisplayName";
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for shipping costs
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.ShippingOptions.ShippingCosts"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.ShippingOptions.ShippingCosts");
        }

        mShippingOptionId = QueryHelper.GetInteger("shippingoptionid", 0);

        mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
        EditedObject           = mShippingOptionInfoObj;

        if (mShippingOptionInfoObj != null)
        {
            CheckEditedObjectSiteID(mShippingOptionInfoObj.ShippingOptionSiteID);
            currency = CurrencyInfoProvider.GetMainCurrency(mShippingOptionInfoObj.ShippingOptionSiteID);
        }

        gridElem.OnAction             += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound  += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.OnAfterRetrieveData  += new OnAfterRetrieveData(gridElem_OnAfterRetrieveData);
        gridElem.WhereCondition        = "ShippingCostShippingOptionID = " + mShippingOptionId;
        gridElem.ZeroRowsText          = GetString("com.ui.shippingcost.edit_nodata");
        gridElem.GridView.AllowSorting = false;

        // Set the master page actions element
        string[,] actions = new string[1, 10];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("com.ui.shippingcost.edit_new");
        actions[0, 3]     = ResolveUrl("~/CMSModules/Ecommerce/Pages/Tools/Configuration/ShippingOptions/ShippingOption_Edit_ShippingCosts_Edit.aspx?shippingCostShippingOptionId=" + mShippingOptionId + "&siteId=" + SiteID);
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("Objects/Ecommerce_ShippingOption/add.png");

        this.CurrentMaster.HeaderActions.Actions = actions;

        this.CurrentMaster.Title.HelpTopicName = "shippingcosts_list";
        this.CurrentMaster.Title.HelpName      = "helpTopic";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for Tax clases
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.ShippingOptions.TaxClasses"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.ShippingOptions.TaxClasses");
        }

        lblAvialable.Text = GetString("com.shippingoption.taxes");
        mShippingOptionId = QueryHelper.GetInteger("shippingoptionid", 0);
        if (mShippingOptionId > 0)
        {
            mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
            EditedObject           = mShippingOptionInfoObj;

            if (mShippingOptionInfoObj != null)
            {
                // Check object's site id
                CheckEditedObjectSiteID(mShippingOptionInfoObj.ShippingOptionSiteID);

                DataSet ds = ShippingOptionTaxClassInfoProvider.GetShippingOptionTaxClasses(mShippingOptionId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.taxclass", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.OrderBy             = "TaxClassDisplayName";
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        mShippingOptionId = QueryHelper.GetInteger("shippingOptionID", 0);

        string             shippingOptionName = "";
        ShippingOptionInfo soi = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);

        if (soi != null)
        {
            editedSiteId = soi.ShippingOptionSiteID;

            // Check site ID
            CheckEditedObjectSiteID(editedSiteId);
            shippingOptionName = ResHelper.LocalizeString(soi.ShippingOptionDisplayName);
        }

        // Initializes page title and breadcrumbs
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("ShippingOption_EditHeader.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ShippingOptions/ShippingOption_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "configEdit";
        breadcrumbs[1, 0]     = FormatBreadcrumbObjectName(shippingOptionName, editedSiteId);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";

        CMSMasterPage master = (CMSMasterPage)this.CurrentMaster;

        master.Title.Breadcrumbs   = breadcrumbs;
        master.Title.TitleText     = GetString("ShippingOption_EditHeader.TitleText");
        master.Title.TitleImage    = GetImageUrl("Objects/Ecommerce_ShippingOption/object.png");
        master.Title.HelpTopicName = "newgeneral_tab2";
        master.Title.HelpName      = "helpTopic";

        master.Tabs.ModuleName    = "CMS.Ecommerce";
        master.Tabs.ElementName   = "Configuration.ShippingOptions";
        master.Tabs.UrlTarget     = "shippingOptionContent";
        master.Tabs.OnTabCreated += new UITabs.TabCreatedEventHandler(Tabs_OnTabCreated);
    }
Пример #22
0
    /// <summary>
    /// Ensures that only applicable shipping options are displayed in selector.
    /// </summary>
    /// <param name="ds"></param>
    /// <returns></returns>
    protected override DataSet OnAfterRetrieveData(DataSet ds)
    {
        if ((ds == null) || (ShoppingCart == null))
        {
            return(ds);
        }

        var shippingOptions = ds.Tables[0].Select();

        foreach (DataRow optionRow in shippingOptions)
        {
            int optionID = ValidationHelper.GetInteger(optionRow["ShippingOptionID"], 0);

            ShippingOptionInfo option = ShippingOptionInfoProvider.GetShippingOptionInfo(optionID);

            if ((option != null) && !ShippingOptionInfoProvider.IsShippingOptionApplicable(ShoppingCart, option))
            {
                ds.Tables[0].Rows.Remove(optionRow);
            }
        }

        return(ds);
    }
Пример #23
0
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private WhereCondition GetWhereCondition()
    {
        // Orders from current site
        var where = new WhereCondition()
                    .WhereEquals("OrderSiteID", SiteContext.CurrentSiteID);

        // Order status filter
        var status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName);

        if (status != null)
        {
            where.WhereEquals("OrderStatusID", status.StatusID);
        }

        // Customer or company like filter
        if (!string.IsNullOrEmpty(CustomerOrCompany))
        {
            where.WhereIn("OrderCustomerID", new IDQuery <CustomerInfo>()
                          .Where("CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName LIKE N'%" + SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(CustomerOrCompany)) + "%'")
                          .Or()
                          .WhereContains("CustomerCompany", CustomerOrCompany));
        }

        // Filter for orders with note
        if (HasNote)
        {
            where.WhereNotEmpty("OrderNote");
        }

        // Payment method filter
        var payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName);

        if (payment != null)
        {
            where.WhereEquals("OrderPaymentOptionID", payment.PaymentOptionID);
        }

        // Payment status filter
        switch (PaymentStatus.ToLowerCSafe())
        {
        case PAY_STATUS_NOT_PAID:
            where.Where(new WhereCondition().WhereFalse("OrderIsPaid").Or().WhereNull("OrderIsPaid"));
            break;

        case PAY_STATUS_PAID:
            where.WhereTrue("OrderIsPaid");
            break;
        }

        // Currency filter
        var currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName);

        if (currencyObj != null)
        {
            where.WhereEquals("OrderCurrencyID", currencyObj.CurrencyID);
        }

        // Min price in main currency filter
        if (MinPriceInMainCurrency > 0)
        {
            where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LargerOrEquals, MinPriceInMainCurrency);
        }

        // Max price in main currency filter
        if (MaxPriceInMainCurrency > 0)
        {
            where.Where("OrderTotalPriceInMainCurrency", QueryOperator.LessOrEquals, MaxPriceInMainCurrency);
        }

        // Shipping option filter
        var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName);

        if (shipping != null)
        {
            where.WhereEquals("OrderShippingOptionID", shipping.ShippingOptionID);
        }

        // Shipping country filter
        if (!string.IsNullOrEmpty(ShippingCountry) && ShippingCountry != "0")
        {
            AddCountryWhereCondition(where);
        }

        // Date filter
        AddDateWhereCondition(where);

        return(where);
    }
Пример #24
0
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private string GetWhereCondition()
    {
        // Orders from current site
        string where = "OrderSiteID = " + CMSContext.CurrentSiteID;

        // Order status filter
        OrderStatusInfo status = OrderStatusInfoProvider.GetOrderStatusInfo(OrderStatus, SiteContext.CurrentSiteName);

        if (status != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderStatusID = " + status.StatusID);
        }

        // Customer or company like filter
        if (!string.IsNullOrEmpty(CustomerOrCompany))
        {
            string safeQueryStr = SecurityHelper.GetSafeQueryString(CustomerOrCompany);
            where = SqlHelper.AddWhereCondition(where, "OrderCustomerID  IN (SELECT CustomerID FROM COM_Customer WHERE ((CustomerFirstName + ' ' + CustomerLastName + ' ' + CustomerFirstName) LIKE N'%" + safeQueryStr + "%') OR (CustomerCompany LIKE N'%" + safeQueryStr + "%'))");
        }

        // Filter for orders with note
        if (HasNote)
        {
            where = SqlHelper.AddWhereCondition(where, "(OrderNote != '') AND (OrderNote IS NOT NULL)");
        }

        // Payment method filter
        PaymentOptionInfo payment = PaymentOptionInfoProvider.GetPaymentOptionInfo(PaymentMethod, SiteContext.CurrentSiteName);

        if (payment != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderPaymentOptionID = " + payment.PaymentOptionID);
        }

        // Payment status filter
        switch (PaymentStatus.ToLowerCSafe())
        {
        case PAY_STATUS_NOT_PAID:
            where = SqlHelper.AddWhereCondition(where, "(OrderIsPaid = 0) OR (OrderIsPaid IS NULL)");
            break;

        case PAY_STATUS_PAID:
            where = SqlHelper.AddWhereCondition(where, "OrderIsPaid = 1");
            break;
        }

        // Currency filter
        CurrencyInfo currencyObj = CurrencyInfoProvider.GetCurrencyInfo(Currency, SiteContext.CurrentSiteName);

        if (currencyObj != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderCurrencyID = " + currencyObj.CurrencyID);
        }

        // Min price in main currency filter
        if (MinPriceInMainCurrency > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency >= " + MinPriceInMainCurrency);
        }

        // Max price in main currency filter
        if (MaxPriceInMainCurrency > 0)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderTotalPriceInMainCurrency <= " + MaxPriceInMainCurrency);
        }

        // Shipping option filter
        ShippingOptionInfo shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(ShippingOption, SiteContext.CurrentSiteName);

        if (shipping != null)
        {
            where = SqlHelper.AddWhereCondition(where, "OrderShippingOptionID = " + shipping.ShippingOptionID);
        }

        // Shipping country filter
        where = SqlHelper.AddWhereCondition(where, GetCountryWhereCondition());

        // Date filter
        where = SqlHelper.AddWhereCondition(where, GetDateWhereCondition());

        return(where);
    }
Пример #25
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        CheckConfigurationModification(mEditedSiteId);

        string errorMessage = new Validator()
                              .NotEmpty(txtShippingOptionDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage)
                              .NotEmpty(txtShippingOptionName.Text.Trim(), rfvName.ErrorMessage).Result;

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

        if (errorMessage == "")
        {
            errorMessage = txtShippingOptionCharge.ValidatePrice(false);
        }

        if (errorMessage == "")
        {
            // ShippingOptionName must be unique
            ShippingOptionInfo shippingOptionObj = null;
            string             siteWhere         = (mEditedSiteId > 0) ? " AND (ShippingOptionSiteID = " + mEditedSiteId + " OR ShippingOptionSiteID IS NULL)" : "";
            DataSet            ds = ShippingOptionInfoProvider.GetShippingOptions("ShippingOptionName = '" + txtShippingOptionName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                shippingOptionObj = new ShippingOptionInfo(ds.Tables[0].Rows[0]);
            }

            if ((shippingOptionObj == null) || (shippingOptionObj.ShippingOptionID == mShippingOptionID))
            {
                // Get object
                if ((shippingOptionObj == null))
                {
                    shippingOptionObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionID);
                    if (shippingOptionObj == null)
                    {
                        shippingOptionObj = new ShippingOptionInfo();
                        shippingOptionObj.ShippingOptionSiteID = mEditedSiteId;
                    }
                }

                shippingOptionObj.ShippingOptionDisplayName = txtShippingOptionDisplayName.Text.Trim();
                shippingOptionObj.ShippingOptionCharge      = txtShippingOptionCharge.Value;
                shippingOptionObj.ShippingOptionName        = txtShippingOptionName.Text.Trim();
                shippingOptionObj.ShippingOptionEnabled     = chkShippingOptionEnabled.Checked;

                // Save changes
                ShippingOptionInfoProvider.SetShippingOptionInfo(shippingOptionObj);

                URLHelper.Redirect("ShippingOption_Edit_General.aspx?shippingOptionID=" + shippingOptionObj.ShippingOptionID + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("ShippingOption_Edit.ShippingOptionNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
Пример #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.ShippingOptions.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.ShippingOptions.General");
        }

        // Required field validator error messages initialization
        rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvName.ErrorMessage        = GetString("COM_ShippingOption_Edit.NameError");
        txtShippingOptionCharge.EmptyErrorMessage      = GetString("COM_ShippingOption_Edit.ChargeError");
        txtShippingOptionCharge.ValidationErrorMessage = GetString("COM_ShippingOption_Edit.ChargePositive");

        // Control initializations
        lblShippingOptionDisplayName.Text = GetString("COM_ShippingOption_Edit.ShippingOptionDisplayNameLabel");
        lblShippingOptionCharge.Text      = GetString("COM_ShippingOption_Edit.ShippingOptionChargeLabel");
        lblShippingOptionName.Text        = GetString("COM_ShippingOption_Edit.ShippingOptionNameLabel");

        btnOk.Text = GetString("General.OK");

        // Get shippingOption id from querystring
        mShippingOptionID = QueryHelper.GetInteger("shippingOptionID", 0);
        mEditedSiteId     = ConfiguredSiteID;
        // Edit shiping option
        if (mShippingOptionID > 0)
        {
            ShippingOptionInfo shippingOptionObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionID);
            EditedObject = shippingOptionObj;

            if (shippingOptionObj != null)
            {
                mEditedSiteId = shippingOptionObj.ShippingOptionSiteID;
                CheckEditedObjectSiteID(mEditedSiteId);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(shippingOptionObj);
                    // Show that the shippingOption was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }
        }

        // Ensure currency code after price value
        txtShippingOptionCharge.CurrencySiteID = mEditedSiteId;

        // Check presence of main currency
        string currencyErr = CheckMainCurrency(mEditedSiteId);

        if (!string.IsNullOrEmpty(currencyErr))
        {
            // Show message
            lblError.Text    = currencyErr;
            lblError.Visible = true;
        }
    }
Пример #27
0
    /// <summary>
    /// Convert given shipping name to its ID for specified site.
    /// </summary>
    /// <param name="name">Name of the shipping to be converted.</param>
    /// <param name="siteName">Name of the site of the shipping.</param>
    protected override int GetID(string name, string siteName)
    {
        var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(name, siteName);

        return((shipping != null) ? shipping.ShippingOptionID : 0);
    }
Пример #28
0
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView dr = null;
        bool        orderCurrencyIsMain = false;

        switch (sourceName.ToLowerCSafe())
        {
        case "idandinvoice":
            dr = (DataRowView)parameter;
            int    orderId       = ValidationHelper.GetInteger(dr["OrderID"], 0);
            string invoiceNumber = ValidationHelper.GetString(dr["OrderInvoiceNumber"], "");

            // Show OrderID and invoice number in brackets if InvoiceNumber is different from OrderID
            if (!string.IsNullOrEmpty(invoiceNumber) && (invoiceNumber != orderId.ToString()))
            {
                return(HTMLHelper.HTMLEncode(orderId + " (" + invoiceNumber + ")"));
            }
            return(orderId);

        case "customer":
            dr = (DataRowView)parameter;
            string customerName    = dr["CustomerFirstName"] + " " + dr["CustomerLastName"];
            string customerCompany = ValidationHelper.GetString(dr["CustomerCompany"], "");

            // Show customer name and company in brakcets, if company specified
            if (!string.IsNullOrEmpty(customerCompany))
            {
                return(HTMLHelper.HTMLEncode(customerName + " (" + customerCompany + ")"));
            }
            return(HTMLHelper.HTMLEncode(customerName));

        //
        case "email":
            dr = (DataRowView)parameter;
            string mailCustomer = ValidationHelper.GetString(dr["CustomerEmail"], "");
            // Show customer mail
            return(HTMLHelper.HTMLEncode(mailCustomer));

        //

        case "totalpriceinmaincurrency":
            dr = (DataRowView)parameter;
            double totalPriceInMainCurrency = ValidationHelper.GetDouble(dr["OrderTotalPriceInMainCurrency"], 0);
            orderCurrencyIsMain = ValidationHelper.GetBoolean(dr["CurrencyIsMain"], false);

            // Format currency
            string priceInMainCurrencyFormatted = "";
            if (orderCurrencyIsMain)
            {
                priceInMainCurrencyFormatted = String.Format(dr["CurrencyFormatString"].ToString(), totalPriceInMainCurrency);
            }
            else
            {
                int siteId = ValidationHelper.GetInteger(dr["OrderSiteID"], 0);
                priceInMainCurrencyFormatted = CurrencyInfoProvider.GetFormattedPrice(totalPriceInMainCurrency, siteId);
            }

            return(HTMLHelper.HTMLEncode(priceInMainCurrencyFormatted));

        case "totalpriceinorderprice":
            dr = (DataRowView)parameter;
            orderCurrencyIsMain = ValidationHelper.GetBoolean(dr["CurrencyIsMain"], false);

            if (orderCurrencyIsMain)
            {
                return("-");
            }

            // If order is not in main currency, show order price
            double orderTotalPrice = ValidationHelper.GetDouble(dr["OrderTotalPrice"], 0);
            string priceFormatted  = String.Format(dr["CurrencyFormatString"].ToString(), orderTotalPrice);

            // Formated currency
            return(HTMLHelper.HTMLEncode(priceFormatted));

        case "orderpaymentoptionid":
            // Tranform to display name and localize
            int paymentOptionId             = ValidationHelper.GetInteger(parameter, 0);
            PaymentOptionInfo paymentOption = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentOptionId);

            if (paymentOption != null)
            {
                return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(paymentOption.PaymentOptionDisplayName)));
            }
            break;

        case "ordershippingoptionid":
            // Tranform to display name and localize
            int shippingOptionId = ValidationHelper.GetInteger(parameter, 0);
            ShippingOptionInfo shippingOption = ShippingOptionInfoProvider.GetShippingOptionInfo(shippingOptionId);

            if (shippingOption != null)
            {
                return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(shippingOption.ShippingOptionDisplayName)));
            }
            break;

        case "note":
            string note = ValidationHelper.GetString(parameter, "");

            if (string.IsNullOrEmpty(note))
            {
                return("-");
            }
            // Display link, note is in tooltip
            return("<a>" + GetString("general.view") + "</a>");
        }
        return(parameter);
    }
Пример #29
0
    /// <summary>
    /// Convert given shipping name to its ID for specified site.
    /// </summary>
    /// <param name="name">Name of the shipping to be converted.</param>
    /// <param name="siteName">Name of the site of the shipping.</param>
    protected override int GetID(string name, string siteName)
    {
        var shipping = ShippingOptionInfoProvider.GetShippingOptionInfo(name, siteName);

        return(shipping?.ShippingOptionID ?? 0);
    }
Пример #30
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        CheckConfigurationModification(ConfiguredSiteID);

        string errorMessage = new Validator()
                              .NotEmpty(txtShippingOptionDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage)
                              .NotEmpty(txtShippingOptionName.Text.Trim(), rfvName.ErrorMessage).Result;

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

        if (errorMessage == "")
        {
            errorMessage = txtShippingOptionCharge.Validate(false);
        }

        if (errorMessage == "")
        {
            // ShippingOptionName must be unique
            ShippingOptionInfo shippingOptionObj = null;
            string             siteWhere         = (ConfiguredSiteID > 0) ? " AND (ShippingOptionSiteID = " + ConfiguredSiteID + " OR ShippingOptionSiteID IS NULL)" : "";
            DataSet            ds = ShippingOptionInfoProvider.GetShippingOptions("ShippingOptionName = '" + txtShippingOptionName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                shippingOptionObj = new ShippingOptionInfo(ds.Tables[0].Rows[0]);
            }

            // If shippingOptionName value is unique
            if ((shippingOptionObj == null) || (shippingOptionObj.ShippingOptionID == mShippingOptionID))
            {
                // If shippingOptionName value is unique -> determine whether it is update or insert
                if ((shippingOptionObj == null))
                {
                    // Get ShippingOptionInfo object by primary key
                    shippingOptionObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionID);
                    if (shippingOptionObj == null)
                    {
                        // Create new item -> insert
                        shippingOptionObj = new ShippingOptionInfo();
                        shippingOptionObj.ShippingOptionSiteID = ConfiguredSiteID;
                    }
                }

                shippingOptionObj.ShippingOptionDisplayName = txtShippingOptionDisplayName.Text.Trim();
                shippingOptionObj.ShippingOptionDescription = txtDescription.Text.Trim();
                shippingOptionObj.ShippingOptionCharge      = txtShippingOptionCharge.Price;
                shippingOptionObj.ShippingOptionName        = txtShippingOptionName.Text.Trim();
                shippingOptionObj.ShippingOptionEnabled     = chkShippingOptionEnabled.Checked;

                // Save record
                ShippingOptionInfoProvider.SetShippingOptionInfo(shippingOptionObj);

                // Upload file
                file.ObjectID = shippingOptionObj.ShippingOptionID;
                file.UploadFile();

                URLHelper.Redirect("ShippingOption_Edit_Frameset.aspx?ShippingOptionID=" + Convert.ToString(shippingOptionObj.ShippingOptionID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                // Show error message
                ShowError(GetString("ShippingOption_Edit.ShippingOptionNameExists"));
            }
        }
        else
        {
            // Show error message
            ShowError(errorMessage);
        }
    }