コード例 #1
0
    /// <summary>
    /// Checks whether entered dsicount coupon code is usable for this cart. Returns true if so.
    /// </summary>
    private bool CheckDiscountCoupon()
    {
        bool success = true;

        if (txtCoupon.Text.Trim() != "")
        {
            // Get discount info
            DiscountCouponInfo dci = DiscountCouponInfoProvider.GetDiscountCouponInfo(txtCoupon.Text.Trim(), this.ShoppingCartInfoObj.SiteName);
            // Do not validate coupon when editing existing order and coupon code was not changed, otherwise process validation
            if ((dci != null) && (((this.ShoppingCartInfoObj.IsCreatedFromOrder) && (ShoppingCartInfoObj.ShoppingCartDiscountCouponID == dci.DiscountCouponID)) || dci.IsValid))
            {
                ShoppingCartInfoObj.ShoppingCartDiscountCouponID = dci.DiscountCouponID;
            }
            else
            {
                ShoppingCartInfoObj.ShoppingCartDiscountCouponID = 0;

                // Discount coupon is not valid
                lblError.Text = GetString("ecommerce.error.couponcodeisnotvalid");

                success = false;
            }
        }
        else
        {
            ShoppingCartInfoObj.ShoppingCartDiscountCouponID = 0;
        }

        return(success);
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentDiscountCoupon = "";

        mDiscountId = QueryHelper.GetInteger("discountid", 0);
        if (mDiscountId > 0)
        {
            DiscountCouponInfo discountCouponObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountId);
            if (discountCouponObj != null)
            {
                editedSiteId = discountCouponObj.DiscountCouponSiteID;

                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(editedSiteId);

                currentDiscountCoupon = ResHelper.LocalizeString(discountCouponObj.DiscountCouponDisplayName);
            }
        }

        CMSMasterPage master = (CMSMasterPage)CurrentMaster;

        // Initializes page title breadcrumbs control
        string[,] breadcrumbs           = new string[2, 3];
        breadcrumbs[0, 0]               = GetString("DiscounCoupon_Edit.ItemListLink");
        breadcrumbs[0, 1]               = "~/CMSModules/Ecommerce/Pages/Tools/DiscountCoupons/DiscountCoupon_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]               = "ecommerceContent";
        breadcrumbs[1, 0]               = FormatBreadcrumbObjectName(currentDiscountCoupon, editedSiteId);
        breadcrumbs[1, 1]               = "";
        breadcrumbs[1, 2]               = "";
        CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        // Tabs
        master.Tabs.OnTabCreated += Tabs_OnTabCreated;
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        orderCoupon.Text = GetString("Ecommerce.Discount.IsAnOrderDiscount");

        rfvCouponCode.ErrorMessage  = GetString("DiscounCoupon_Edit.errorCode");
        rfvDisplayName.ErrorMessage = GetString("DiscounCoupon_Edit.errorDisplay");

        radFixed.Text      = GetString("DiscounCoupon_Edit.radFixed");
        radPercentage.Text = GetString("DiscounCoupon_Edit.radPercentage");

        dtPickerDiscountCouponValidTo.SupportFolder   = "~/CMSAdminControls/Calendar";
        dtPickerDiscountCouponValidFrom.SupportFolder = "~/CMSAdminControls/Calendar";

        // Get discountCoupon id from querystring
        mDiscountId  = QueryHelper.GetInteger("discountid", 0);
        editedSiteId = ConfiguredSiteID;
        if (mDiscountId > 0)
        {
            DiscountCouponInfo discountCouponObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountId);
            EditedObject = discountCouponObj;

            if (discountCouponObj != null)
            {
                editedSiteId = discountCouponObj.DiscountCouponSiteID;

                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(editedSiteId);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(discountCouponObj);

                    // Show that the discountCoupon was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        ShowChangesSaved();
                    }
                }
            }
        }

        currencyCode = HTMLHelper.HTMLEncode(CurrencyInfoProvider.GetMainCurrencyCode(editedSiteId));

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

        if (!string.IsNullOrEmpty(currencyWarning))
        {
            ShowWarning(currencyWarning, null, null);
        }

        radFixed.Attributes["onclick"]      = "jQuery('span[id*=\"lblCurrency\"]').html(" + ScriptHelper.GetString("(" + currencyCode + ")") + ")";
        radPercentage.Attributes["onclick"] = "jQuery('span[id*=\"lblCurrency\"]').html('(%)')";
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "DiscountCoupons.Products"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "DiscountCoupons.Products");
        }

        mDiscountCouponId = QueryHelper.GetInteger("discountid", 0);
        if (mDiscountCouponId > 0)
        {
            mDiscountCouponInfoObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountCouponId);
            EditedObject           = mDiscountCouponInfoObj;

            if (mDiscountCouponInfoObj != null)
            {
                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(mDiscountCouponInfoObj.DiscountCouponSiteID);

                // Get the active skus
                DataSet ds = SKUInfoProvider.GetCouponProducts(mDiscountCouponId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "SKUID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    this.uniSelector.Value = mCurrentValues;
                    radFollowing.Checked   = true;
                    radExcept.Checked      = false;

                    if (mDiscountCouponInfoObj.DiscountCouponIsExcluded)
                    {
                        radFollowing.Checked = false;
                        radExcept.Checked    = true;
                    }
                }
            }
        }

        this.uniSelector.IconPath            = GetObjectIconUrl("ecommerce.sku", "object.png");
        this.uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        this.uniSelector.WhereCondition      = GetWhereCondition();

        this.lblApplies.Text   = GetString("Discount_Product.Applies");
        this.radExcept.Text    = GetString("Discount_Product.radExcept");
        this.radFollowing.Text = GetString("Discount_Product.radFollowing");
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentDiscountCoupon = "";

        mDiscountId = QueryHelper.GetInteger("discountid", 0);
        if (mDiscountId > 0)
        {
            DiscountCouponInfo discountCouponObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountId);
            if (discountCouponObj != null)
            {
                editedSiteId = discountCouponObj.DiscountCouponSiteID;

                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(editedSiteId);

                currentDiscountCoupon = ResHelper.LocalizeString(discountCouponObj.DiscountCouponDisplayName);
            }
        }

        CMSMasterPage master = (CMSMasterPage)this.CurrentMaster;

        // Page title
        master.Title.HelpTopicName = "new_coupongeneral_tab";
        master.Title.HelpName      = "helpTopic";

        // Initializes page title breadcrumbs control
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("DiscounCoupon_Edit.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/DiscountCoupons/DiscountCoupon_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "ecommerceContent";
        breadcrumbs[1, 0]     = FormatBreadcrumbObjectName(currentDiscountCoupon, editedSiteId);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";
        this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        // Tabs
        master.Tabs.ModuleName    = "CMS.Ecommerce";
        master.Tabs.ElementName   = "DiscountCoupons";
        master.Tabs.UrlTarget     = "DiscountContent";
        master.Tabs.OnTabCreated += new UITabs.TabCreatedEventHandler(Tabs_OnTabCreated);

        // Set master title
        master.Title.TitleText  = GetString("com.discountcoupon.edit");
        master.Title.TitleImage = GetImageUrl("Objects/Ecommerce_DiscountCoupon/object.png");
    }
コード例 #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 gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            // Discount coupon detail url
            var redirectURL = UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, "EditDiscountCouponProperties", false, actionArgument.ToInteger(0));
            redirectURL = URLHelper.AddParameterToUrl(redirectURL, "siteid", SiteContext.CurrentSiteID.ToString());

            URLHelper.Redirect(redirectURL);
        }
        else if (actionName == "delete")
        {
            int id = ValidationHelper.GetInteger(actionArgument, 0);

            DiscountCouponInfo discountCouponInfoObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(id);
            // Nothing to delete
            if (discountCouponInfoObj == null)
            {
                return;
            }

            // Check module permissions
            if (!ECommerceContext.IsUserAuthorizedToModifyDiscountCoupon(discountCouponInfoObj))
            {
                if (discountCouponInfoObj.IsGlobal)
                {
                    RedirectToAccessDenied(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL);
                }
                else
                {
                    RedirectToAccessDenied(ModuleName.ECOMMERCE, "EcommerceModify OR ModifyDiscounts");
                }
            }

            if (discountCouponInfoObj.Generalized.CheckDependencies())
            {
                ShowError(ECommerceHelper.GetDependencyMessage(discountCouponInfoObj));
                return;
            }

            // Delete DiscountCouponInfo object from database
            DiscountCouponInfoProvider.DeleteDiscountCouponInfo(discountCouponInfoObj);
        }
    }
コード例 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mDiscountCouponId = QueryHelper.GetInteger("discountid", 0);
        if (mDiscountCouponId > 0)
        {
            mDiscountCouponInfoObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountCouponId);
            EditedObject           = mDiscountCouponInfoObj;

            if (mDiscountCouponInfoObj != null)
            {
                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(mDiscountCouponInfoObj.DiscountCouponSiteID);

                // Get the active skus
                DataSet ds = SKUInfoProvider.GetCouponProducts(mDiscountCouponId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "SKUID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value    = mCurrentValues;
                    radFollowing.Checked = true;
                    radExcept.Checked    = false;

                    if (mDiscountCouponInfoObj.DiscountCouponIsExcluded)
                    {
                        radFollowing.Checked = false;
                        radExcept.Checked    = true;
                    }
                }
            }
        }

        // Init selector
        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.sku", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetWhereCondition();

        lblApplies.Text   = GetString("Discount_Product.Applies");
        radExcept.Text    = GetString("Discount_Product.radExcept");
        radFollowing.Text = GetString("Discount_Product.radFollowing");
    }
コード例 #8
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 gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("DiscountCoupon_Edit_Frameset.aspx?discountid=" + Convert.ToString(actionArgument) + "&siteId=" + SelectSite.SiteID);
        }
        else if (actionName == "delete")
        {
            int id = ValidationHelper.GetInteger(actionArgument, 0);

            DiscountCouponInfo discountCouponInfoObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(id);
            // Nothing to delete
            if (discountCouponInfoObj == null)
            {
                return;
            }

            // Check module permissions
            if (!ECommerceContext.IsUserAuthorizedToModifyDiscountCoupon(discountCouponInfoObj))
            {
                if (discountCouponInfoObj.IsGlobal)
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
                }
                else
                {
                    RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyDiscounts");
                }
            }

            if (DiscountCouponInfoProvider.CheckDependencies(id))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Ecommerce.DeleteDisabled");
                return;
            }

            // Delete DiscountCouponInfo object from database
            DiscountCouponInfoProvider.DeleteDiscountCouponInfo(discountCouponInfoObj);
        }
    }
コード例 #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "DiscountCoupons.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "DiscountCoupons.General");
        }

        rfvCouponCode.ErrorMessage  = GetString("DiscounCoupon_Edit.errorCode");
        rfvDisplayName.ErrorMessage = GetString("DiscounCoupon_Edit.errorDisplay");

        // Control initializations
        lblDiscountCouponValue.Text   = GetString("DiscounCoupon_Edit.DiscountCouponAbsoluteValueLabel");
        lblDiscountCouponValidTo.Text = GetString("DiscounCoupon_Edit.DiscountCouponValidToLabel");
        lblDiscountCouponCode.Text    = GetString("DiscounCoupon_Edit.DiscountCouponCodeLabel");

        lblDiscountCouponDisplayName.Text = GetString("DiscounCoupon_Edit.DiscountCouponDisplayNameLabel");
        lblDiscountCouponValidFrom.Text   = GetString("DiscounCoupon_Edit.DiscountCouponValidFromLabel");

        radFixed.Text      = GetString("DiscounCoupon_Edit.radFixed");
        radPercentage.Text = GetString("DiscounCoupon_Edit.radPercentage");

        btnOk.Text = GetString("General.OK");
        dtPickerDiscountCouponValidTo.SupportFolder   = "~/CMSAdminControls/Calendar";
        dtPickerDiscountCouponValidFrom.SupportFolder = "~/CMSAdminControls/Calendar";

        // Get discountCoupon id from querystring
        mDiscountId  = QueryHelper.GetInteger("discountid", 0);
        editedSiteId = ConfiguredSiteID;
        if (mDiscountId > 0)
        {
            DiscountCouponInfo discountCouponObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountId);
            EditedObject = discountCouponObj;

            if (discountCouponObj != null)
            {
                editedSiteId = discountCouponObj.DiscountCouponSiteID;

                // Check if edited object belongs to configured site
                CheckEditedObjectSiteID(editedSiteId);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(discountCouponObj);

                    // Show that the discountCoupon was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }
        }

        currencyCode = HTMLHelper.HTMLEncode(CurrencyInfoProvider.GetMainCurrencyCode(editedSiteId));

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

        if (!string.IsNullOrEmpty(currencyErr))
        {
            // Show message
            lblError.Text    = currencyErr;
            lblError.Visible = true;
        }

        radFixed.Attributes["onclick"]      = "jQuery('span[id*=\"lblCurrency\"]').html(" + ScriptHelper.GetString("(" + currencyCode + ")") + ")";
        radPercentage.Attributes["onclick"] = "jQuery('span[id*=\"lblCurrency\"]').html('(%)')";
    }
コード例 #10
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check module permissions
        bool global = (editedSiteId <= 0);

        if (!ECommerceContext.IsUserAuthorizedToModifyDiscountCoupon(global))
        {
            if (global)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceGlobalModify");
            }
            else
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyDiscounts");
            }
        }

        string errorMessage = new Validator().NotEmpty(txtDiscountCouponDisplayName.Text.Trim(), GetString("DiscounCoupon_Edit.errorDisplay"))
                              .NotEmpty(txtDiscountCouponCode.Text.Trim(), GetString("DiscounCoupon_Edit.errorCode"))
                              .IsCodeName(txtDiscountCouponCode.Text.Trim(), GetString("DiscounCoupon_Edit.errorCodeFormat")).Result;

        // Discount value validation
        if (errorMessage == "")
        {
            // Relative
            if (this.radPercentage.Checked && !ValidationHelper.IsInRange(0, 100, ValidationHelper.GetDouble(this.txtDiscountCouponValue.Text.Trim(), -1)))
            {
                errorMessage = GetString("Com.Error.RelativeDiscountValue");
            }
            // Absolute
            else if (this.radFixed.Checked && !ValidationHelper.IsPositiveNumber(ValidationHelper.GetDouble(this.txtDiscountCouponValue.Text.Trim(), -1)))
            {
                errorMessage = GetString("Com.Error.AbsoluteDiscountValue");
            }
        }

        // From/to date validation
        if (errorMessage == "")
        {
            if ((!dtPickerDiscountCouponValidFrom.IsValidRange()) || (!dtPickerDiscountCouponValidTo.IsValidRange()))
            {
                errorMessage = GetString("general.errorinvaliddatetimerange");
            }

            if ((dtPickerDiscountCouponValidFrom.SelectedDateTime != DateTime.MinValue) &&
                (dtPickerDiscountCouponValidTo.SelectedDateTime != DateTime.MinValue) &&
                (dtPickerDiscountCouponValidFrom.SelectedDateTime >= dtPickerDiscountCouponValidTo.SelectedDateTime))
            {
                errorMessage = GetString("General.DateOverlaps");
            }
        }

        if (errorMessage == "")
        {
            // DiscountCoupon code name must to be unique
            DiscountCouponInfo discountCouponObj = null;
            string             siteWhere         = (editedSiteId > 0) ? " AND (DiscountCouponSiteID = " + editedSiteId + " OR DiscountCouponSiteID IS NULL)" : "";
            DataSet            ds = DiscountCouponInfoProvider.GetDiscountCoupons("DiscountCouponCode = '" + txtDiscountCouponCode.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                discountCouponObj = new DiscountCouponInfo(ds.Tables[0].Rows[0]);
            }

            // If discountCouponCode value is unique
            if ((discountCouponObj == null) || (discountCouponObj.DiscountCouponID == mDiscountId))
            {
                // If discountCouponCode value is unique -> determine whether it is update or insert
                if ((discountCouponObj == null))
                {
                    // Get DiscountCouponInfo object by primary key
                    discountCouponObj = DiscountCouponInfoProvider.GetDiscountCouponInfo(mDiscountId);
                    if (discountCouponObj == null)
                    {
                        // Create new item -> insert
                        discountCouponObj = new DiscountCouponInfo();
                        discountCouponObj.DiscountCouponSiteID = editedSiteId;
                    }
                }

                discountCouponObj.DiscountCouponValue       = ValidationHelper.GetDouble(txtDiscountCouponValue.Text.Trim(), 0.0);
                discountCouponObj.DiscountCouponCode        = txtDiscountCouponCode.Text.Trim();
                discountCouponObj.DiscountCouponIsFlatValue = true;

                if (radPercentage.Checked)
                {
                    discountCouponObj.DiscountCouponIsFlatValue = false;
                }

                discountCouponObj.DiscountCouponDisplayName = txtDiscountCouponDisplayName.Text.Trim();
                discountCouponObj.DiscountCouponValidFrom   = dtPickerDiscountCouponValidFrom.SelectedDateTime;
                discountCouponObj.DiscountCouponValidTo     = dtPickerDiscountCouponValidTo.SelectedDateTime;

                DiscountCouponInfoProvider.SetDiscountCouponInfo(discountCouponObj);

                URLHelper.Redirect("DiscountCoupon_Edit_General.aspx?discountid=" + Convert.ToString(discountCouponObj.DiscountCouponID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("DiscounCoupon_Edit.DiscountCouponCodeExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
コード例 #11
0
    /// <summary>
    /// Saves order information from ShoppingCartInfo object to database as new order.
    /// </summary>
    public override bool ProcessStep()
    {
        // Load first step if there is no address
        if (IsShippingNeeded && ShoppingCart.ShoppingCartBillingAddressID <= 0)
        {
            ShoppingCartControl.LoadStep(0);
            return(false);
        }

        // Check if customer is enabled
        if ((ShoppingCart.Customer != null) && (!ShoppingCart.Customer.CustomerEnabled))
        {
            lblError.Text = GetString("ecommerce.cartcontent.customerdisabled");
            return(false);
        }

        // Deal with order note
        ShoppingCartControl.SetTempValue(ORDER_NOTE, null);
        ShoppingCart.ShoppingCartNote = txtNote.Text.Trim();

        try
        {
            // Set order culture
            ShoppingCart.ShoppingCartCulture = LocalizationContext.PreferredCultureCode;

            // Update customer preferences
            CustomerInfoProvider.SetCustomerPreferredSettings(ShoppingCart);

            // Create order
            ShoppingCartInfoProvider.SetOrder(ShoppingCart);
            ShoppingCart.Order.SetValue("OrderBundleData", ShoppingCart.GetStringValue("ShoppingCartBundleData", string.Empty));
        }
        catch (Exception ex)
        {
            // Show error
            lblError.Text = GetString("Ecommerce.OrderPreview.ErrorOrderSave");

            // Log exception
            EventLogProvider.LogException("Shopping cart", "SAVEORDER", ex, ShoppingCart.ShoppingCartSiteID, null);
            return(false);
        }

        // Track order items conversions
        ECommerceHelper.TrackOrderItemsConversions(ShoppingCart);

        // Track order conversion
        string name = ShoppingCartControl.OrderTrackConversionName;

        ECommerceHelper.TrackOrderConversion(ShoppingCart, name);

        // Track order activity
        string siteName = SiteContext.CurrentSiteName;

        if (LogActivityForCustomer)
        {
            ShoppingCartControl.TrackActivityPurchasedProducts(ShoppingCart, siteName, ContactID);
            ShoppingCartControl.TrackActivityPurchase(ShoppingCart.OrderId, ContactID,
                                                      SiteContext.CurrentSiteName, RequestContext.CurrentRelativePath,
                                                      ShoppingCart.TotalPriceInMainCurrency, CurrencyInfoProvider.GetFormattedPrice(ShoppingCart.TotalPriceInMainCurrency,
                                                                                                                                    CurrencyInfoProvider.GetMainCurrency(CMSContext.CurrentSiteID)));
        }

        // Raise finish order event
        ShoppingCartControl.RaiseOrderCompletedEvent();
        string currentCultureCode = DocumentContext.CurrentDocument.DocumentCulture;
        string template           = "Ecommerce.OrderNotificationToCustomer" + currentCultureCode;

        // When in CMSDesk
        if (ShoppingCartControl.IsInternalOrder)
        {
            if (chkSendEmail.Checked)
            {
                // Send order notification emails
                OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);


                OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart, template);
            }
        }
        // When on the live site
        else if (ECommerceSettings.SendOrderNotification(SiteContext.CurrentSite.SiteName))
        {
            // Send order notification emails
            OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);


            OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart, template);
        }

        /*desactiver le coupon code*/
        if (Session["CouponValue"] != null)
        {
            DiscountCouponInfo dci = DiscountCouponInfoProvider.GetDiscountCouponInfo(Session["CouponValue"].ToString(), ShoppingCart.SiteName);
            if ((dci != null) && (((ShoppingCart.IsCreatedFromOrder) && (ShoppingCart.ShoppingCartDiscountCouponID == dci.DiscountCouponID)) || dci.IsValid))
            {
                DateTime d = DateTime.Now;
                d = d.AddMinutes(5);
                dci.DiscountCouponValidTo = d;
                Session["CouponValue"]    = null;
            }
        }
        /**/

        return(true);
    }
コード例 #12
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        this.lblTitle.Text = GetString("ShoppingCart.CartContent");
        //bool currencySelected = false;

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

            // Set currency selectors site ID
            selectCurrency.SiteID = this.ShoppingCartInfoObj.ShoppingCartSiteID;
        }

        // Initialization
        imgNewItem.ImageUrl      = GetImageUrl("Objects/Ecommerce_OrderItem/add.png");
        lblCurrency.Text         = GetString("Ecommerce.ShoppingCartContent.Currency");
        lblCoupon.Text           = GetString("Ecommerce.ShoppingCartContent.Coupon");
        lnkNewItem.Text          = GetString("Ecommerce.ShoppingCartContent.AddItem");
        imgNewItem.AlternateText = lnkNewItem.Text;
        btnUpdate.Text           = GetString("Ecommerce.ShoppingCartContent.BtnUpdate");
        btnEmpty.Text            = GetString("Ecommerce.ShoppingCartContent.BtnEmpty");
        btnEmpty.OnClientClick   = "return confirm(" + ScriptHelper.GetString(GetString("Ecommerce.ShoppingCartContent.EmptyConfirm")) + ");";
        //this.TitleText = GetString("order_new.cartcontent.title");
        lnkNewItem.OnClientClick        = "OpenAddProductDialog('" + GetCMSDeskShoppingCartSessionName() + "');return false;";
        gridData.Columns[4].HeaderText  = GetString("general.remove");
        gridData.Columns[5].HeaderText  = GetString("Ecommerce.ShoppingCartContent.SKUName");
        gridData.Columns[6].HeaderText  = GetString("Ecommerce.ShoppingCartContent.SKUUnits");
        gridData.Columns[7].HeaderText  = GetString("Ecommerce.ShoppingCartContent.UnitPrice");
        gridData.Columns[8].HeaderText  = GetString("Ecommerce.ShoppingCartContent.UnitDiscount");
        gridData.Columns[9].HeaderText  = GetString("Ecommerce.ShoppingCartContent.Tax");
        gridData.Columns[10].HeaderText = GetString("Ecommerce.ShoppingCartContent.Subtotal");
        this.gridData.RowDataBound     += new GridViewRowEventHandler(gridData_RowDataBound);

        // Registre product price detail javascript
        StringBuilder script = new StringBuilder();

        script.Append("function ShowProductPriceDetail(cartItemGuid, sessionName){");
        script.Append("if (sessionName != \"\"){sessionName =  \"&cart=\" + sessionName;}");
        string detailUrl = "~/CMSModules/Ecommerce/Controls/ShoppingCart/ShoppingCartSKUPriceDetail.aspx";

        if (this.IsLiveSite)
        {
            detailUrl = "~/CMSModules/Ecommerce/CMSPages/ShoppingCartSKUPriceDetail.aspx";
        }
        script.Append("modalDialog('" + ResolveUrl(detailUrl) + "?itemguid=' + cartItemGuid + sessionName, 'ProductPriceDetail', 750, 500);}");
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ProductPriceDetail", ScriptHelper.GetScript(script.ToString()));

        script = new StringBuilder();
        script.Append("function OpenOrderItemDialog(cartItemGuid, sessionName){");
        script.Append("if (sessionName != \"\"){sessionName =  \"&cart=\" + sessionName;}");
        script.Append("modalDialog('" + ResolveUrl("~/CMSModules/Ecommerce/Controls/ShoppingCart/OrderItemEdit.aspx") + "?itemguid=' + cartItemGuid + sessionName, 'OrderItemEdit', 500, 350);}");
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "OrderItemEdit", ScriptHelper.GetScript(script.ToString()));

        // Hide "add product" link if it is live site order
        if (!this.ShoppingCartControl.IsInternalOrder)
        {
            pnlNewItem.Visible = false;

            this.ShoppingCartControl.ButtonBack.Text     = GetString("Ecommerce.CartContent.ButtonBackText");
            this.ShoppingCartControl.ButtonBack.CssClass = "LongButton";
            this.ShoppingCartControl.ButtonNext.Text     = GetString("Ecommerce.CartContent.ButtonNextText");

            if (!this.ShoppingCartControl.IsCurrentStepPostBack)
            {
                // Get shopping cart item parameters from URL
                ShoppingCartItemParameters itemParams = ShoppingCartItemParameters.GetShoppingCartItemParameters();

                // Set item in the shopping cart
                AddProducts(itemParams);
            }
        }

        // Set sending order notification when editing existing order according to the site settings
        if (this.ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        {
            if (!this.ShoppingCartControl.IsCurrentStepPostBack)
            {
                SiteInfo si = SiteInfoProvider.GetSiteInfo(this.ShoppingCartInfoObj.ShoppingCartSiteID);
                if (si != null)
                {
                    chkSendEmail.Checked = ECommerceSettings.SendOrderNotification(si.SiteName);
                }
            }
            chkSendEmail.Visible = true;
            chkSendEmail.Text    = GetString("ShoppingCartContent.SendEmail");
        }

        if (this.ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        {
            this.ShoppingCartControl.ButtonBack.Visible  = false;
            this.ShoppingCartInfoObj.CheckAvailableItems = false;

            if ((!ExistAnotherStepsExceptPayment) && (this.ShoppingCartControl.PaymentGatewayProvider == null))
            {
                this.ShoppingCartControl.ButtonNext.Text = GetString("General.OK");
            }
            else
            {
                this.ShoppingCartControl.ButtonNext.Text = GetString("general.next");
            }
        }

        // Fill dropdownlist
        if (!this.ShoppingCartControl.IsCurrentStepPostBack)
        {
            if ((this.ShoppingCartInfoObj.CartItems.Count > 0) || this.ShoppingCartControl.IsInternalOrder)
            {
                if (this.ShoppingCartInfoObj != null)
                {
                    if (ShoppingCartInfoObj.ShoppingCartCurrencyID == 0)
                    {
                        // Select customer preferred currency
                        if (ShoppingCartInfoObj.CustomerInfoObj != null)
                        {
                            CustomerInfo customer = ShoppingCartInfoObj.CustomerInfoObj;
                            ShoppingCartInfoObj.ShoppingCartCurrencyID = (customer.CustomerUser != null) ? customer.CustomerUser.GetUserPreferredCurrencyID(CMSContext.CurrentSiteName) : 0;
                        }
                    }

                    if (ShoppingCartInfoObj.ShoppingCartCurrencyID == 0)
                    {
                        if (CMSContext.CurrentSite != null)
                        {
                            ShoppingCartInfoObj.ShoppingCartCurrencyID = CMSContext.CurrentSite.SiteDefaultCurrencyID;
                        }
                    }

                    selectCurrency.CurrencyID = ShoppingCartInfoObj.ShoppingCartCurrencyID;

                    if (ShoppingCartInfoObj.ShoppingCartDiscountCouponID > 0)
                    {
                        // fill textbox with discount coupon code
                        DiscountCouponInfo dci = DiscountCouponInfoProvider.GetDiscountCouponInfo(ShoppingCartInfoObj.ShoppingCartDiscountCouponID);
                        if (dci != null)
                        {
                            if (this.ShoppingCartInfoObj.IsCreatedFromOrder || dci.IsValid)
                            {
                                txtCoupon.Text = dci.DiscountCouponCode;
                            }
                            else
                            {
                                this.ShoppingCartInfoObj.ShoppingCartDiscountCouponID = 0;
                            }
                        }
                    }
                }
            }

            ReloadData();
        }

        // Turn on available items checking after content is loaded
        ShoppingCartInfoObj.CheckAvailableItems = true;
    }
コード例 #13
0
    protected override void OnLoad(EventArgs e)
    {
        lblTitle.Text = GetString("shoppingcart.cartcontent");

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

            // Set currency selectors site ID
            selectCurrency.SiteID = ShoppingCart.ShoppingCartSiteID;
        }

        imgNewItem.ImageUrl      = GetImageUrl("Objects/Ecommerce_OrderItem/add.png");
        lblCurrency.Text         = GetString("ecommerce.shoppingcartcontent.currency");
        lblCoupon.Text           = GetString("ecommerce.shoppingcartcontent.coupon");
        lnkNewItem.Text          = GetString("ecommerce.shoppingcartcontent.additem");
        imgNewItem.AlternateText = lnkNewItem.Text;
        btnUpdate.Text           = GetString("ecommerce.shoppingcartcontent.btnupdate");
        btnEmpty.Text            = GetString("ecommerce.shoppingcartcontent.btnempty");
        btnEmpty.OnClientClick   = string.Format("return confirm({0});", ScriptHelper.GetString(GetString("ecommerce.shoppingcartcontent.emptyconfirm")));
        lnkNewItem.OnClientClick = string.Format("OpenAddProductDialog('{0}');return false;", GetCMSDeskShoppingCartSessionName());

        gridData.Columns[4].HeaderText  = GetString("general.remove");
        gridData.Columns[5].HeaderText  = GetString("ecommerce.shoppingcartcontent.actions");
        gridData.Columns[6].HeaderText  = GetString("ecommerce.shoppingcartcontent.skuname");
        gridData.Columns[7].HeaderText  = GetString("ecommerce.shoppingcartcontent.skuunits");
        gridData.Columns[8].HeaderText  = GetString("ecommerce.shoppingcartcontent.unitprice");
        gridData.Columns[9].HeaderText  = GetString("ecommerce.shoppingcartcontent.unitdiscount");
        gridData.Columns[10].HeaderText = GetString("ecommerce.shoppingcartcontent.tax");
        gridData.Columns[11].HeaderText = GetString("ecommerce.shoppingcartcontent.subtotal");
        gridData.RowDataBound          += new GridViewRowEventHandler(gridData_RowDataBound);

        // Register product price detail dialog script
        StringBuilder script = new StringBuilder();

        script.Append("function ShowProductPriceDetail(cartItemGuid, sessionName) {");
        script.Append("if (sessionName != \"\"){sessionName =  \"&cart=\" + sessionName;}");
        string detailUrl = (IsLiveSite) ? "~/CMSModules/Ecommerce/CMSPages/ShoppingCartSKUPriceDetail.aspx" : "~/CMSModules/Ecommerce/Controls/ShoppingCart/ShoppingCartSKUPriceDetail.aspx";

        script.Append(string.Format("modalDialog('{0}?itemguid=' + cartItemGuid + sessionName, 'ProductPriceDetail', 750, 500); }}", ResolveUrl(detailUrl)));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ProductPriceDetail", ScriptHelper.GetScript(script.ToString()));

        // Register add order item dialog script
        script = new StringBuilder();
        script.Append("function OpenOrderItemDialog(cartItemGuid, sessionName) {");
        script.Append("if (sessionName != \"\"){sessionName =  \"&cart=\" + sessionName;}");
        script.Append(string.Format("modalDialog('{0}?itemguid=' + cartItemGuid + sessionName, 'OrderItemEdit', 500, 350); }}", ResolveUrl("~/CMSModules/Ecommerce/Controls/ShoppingCart/OrderItemEdit.aspx")));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "OrderItemEdit", ScriptHelper.GetScript(script.ToString()));

        script = new StringBuilder();
        string addProductUrl = AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Ecommerce/Pages/Tools/Orders/Order_Edit_AddItems.aspx");

        script.AppendFormat("var addProductDialogURL = '{0}'", URLHelper.GetAbsoluteUrl(addProductUrl));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "AddProduct", ScriptHelper.GetScript(script.ToString()));


        // Hide "add product" action for live site order
        if (!ShoppingCartControl.IsInternalOrder)
        {
            pnlNewItem.Visible = false;

            ShoppingCartControl.ButtonBack.Text     = GetString("ecommerce.cartcontent.buttonbacktext");
            ShoppingCartControl.ButtonBack.CssClass = "LongButton";
            ShoppingCartControl.ButtonNext.Text     = GetString("ecommerce.cartcontent.buttonnexttext");

            if (!ShoppingCartControl.IsCurrentStepPostBack)
            {
                // Get shopping cart item parameters from URL
                ShoppingCartItemParameters itemParams = ShoppingCartItemParameters.GetShoppingCartItemParameters();

                // Set item in the shopping cart
                AddProducts(itemParams);
            }
        }

        // Set sending order notification when editing existing order according to the site settings
        if (ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        {
            if (!ShoppingCartControl.IsCurrentStepPostBack)
            {
                if (!string.IsNullOrEmpty(ShoppingCart.SiteName))
                {
                    chkSendEmail.Checked = ECommerceSettings.SendOrderNotification(ShoppingCart.SiteName);
                }
            }
            // Show send email checkbox
            chkSendEmail.Visible = true;
            chkSendEmail.Text    = GetString("shoppingcartcontent.sendemail");

            // Setup buttons
            ShoppingCartControl.ButtonBack.Visible = false;
            ShoppingCart.CheckAvailableItems       = false;
            ShoppingCartControl.ButtonNext.Text    = GetString("general.next");

            if ((!ExistAnotherStepsExceptPayment) && (ShoppingCartControl.PaymentGatewayProvider == null))
            {
                ShoppingCartControl.ButtonNext.Text = GetString("general.ok");
            }
        }

        // Fill dropdownlist
        if (!ShoppingCartControl.IsCurrentStepPostBack)
        {
            if ((ShoppingCart.CartItems.Count > 0) || ShoppingCartControl.IsInternalOrder)
            {
                if (ShoppingCart.ShoppingCartCurrencyID == 0)
                {
                    // Select customer preferred currency
                    if (ShoppingCart.Customer != null)
                    {
                        CustomerInfo customer = ShoppingCart.Customer;
                        ShoppingCart.ShoppingCartCurrencyID = (customer.CustomerUser != null) ? customer.CustomerUser.GetUserPreferredCurrencyID(SiteContext.CurrentSiteName) : 0;
                    }
                }

                if (ShoppingCart.ShoppingCartCurrencyID == 0)
                {
                    if (SiteContext.CurrentSite != null)
                    {
                        ShoppingCart.ShoppingCartCurrencyID = SiteContext.CurrentSite.SiteDefaultCurrencyID;
                    }
                }

                selectCurrency.CurrencyID = ShoppingCart.ShoppingCartCurrencyID;

                if (ShoppingCart.ShoppingCartDiscountCouponID > 0)
                {
                    // Fill textbox with discount coupon code
                    DiscountCouponInfo dci = DiscountCouponInfoProvider.GetDiscountCouponInfo(ShoppingCart.ShoppingCartDiscountCouponID);
                    if (dci != null)
                    {
                        if (ShoppingCart.IsCreatedFromOrder || dci.IsValid)
                        {
                            txtCoupon.Text = dci.DiscountCouponCode;
                        }
                        else
                        {
                            ShoppingCart.ShoppingCartDiscountCouponID = 0;
                        }
                    }
                }
            }

            ReloadData();
        }

        // Check if customer is enabled
        if ((ShoppingCart.Customer != null) && (!ShoppingCart.Customer.CustomerEnabled))
        {
            HideCartContent(GetString("ecommerce.cartcontent.customerdisabled"));
        }

        // Turn on available items checking after content is loaded
        ShoppingCart.CheckAvailableItems = true;

        base.OnLoad(e);
    }