/// <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 (ShoppingCart.ShoppingCartBillingAddress == null)
        {
            ShoppingCartControl.LoadStep(0);
            return(false);
        }

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

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

            // Create order
            ShoppingCartInfoProvider.SetOrder(ShoppingCart);
        }
        catch (Exception ex)
        {
            // Show error
            lblError.Text = GetString("Ecommerce.OrderPreview.ErrorOrderSave");

            // Log exception
            Service.Resolve <IEventLogService>().LogException("Shopping cart", "SAVEORDER", ex, ShoppingCart.ShoppingCartSiteID);
            return(false);
        }

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

        if (LogActivityForCustomer)
        {
            var mainCurrency             = CurrencyInfoProvider.GetMainCurrency(ShoppingCart.ShoppingCartSiteID);
            var grandTotalInMainCurrency = Service.Resolve <ICurrencyConverterService>().Convert(ShoppingCart.GrandTotal, ShoppingCart.Currency.CurrencyCode, mainCurrency.CurrencyCode, ShoppingCart.ShoppingCartSiteID);
            var formattedPrice           = CurrencyInfoProvider.GetFormattedPrice(grandTotalInMainCurrency, mainCurrency);

            ShoppingCartControl.TrackActivityPurchasedProducts(ShoppingCart, siteName, ContactID);
            ShoppingCartControl.TrackActivityPurchase(ShoppingCart.OrderId, ContactID,
                                                      SiteContext.CurrentSiteName, RequestContext.CurrentRelativePath,
                                                      grandTotalInMainCurrency, formattedPrice);
        }

        // Raise finish order event
        ShoppingCartControl.RaiseOrderCompletedEvent();

        if (chkSendEmail.Checked)
        {
            // Send order notification emails
            OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);
            OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart);
        }

        return(true);
    }
    /// <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 (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);
        }
        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();

        // When in CMSDesk
        if (ShoppingCartControl.IsInternalOrder)
        {
            if (chkSendEmail.Checked)
            {
                // Send order notification emails
                OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);
                //OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart);
                //EventLogProvider p = new EventLogProvider();
                //p.LogEvent("I", DateTime.Now, "Envoi de mail d'achat au client"+ShoppingCart.Customer.CustomerEmail, "code BO");
                sendconf2(null, null, null);
            }
        }
        // When on the live site
        else if (ECommerceSettings.SendOrderNotification(SiteContext.CurrentSite.SiteName))
        {
            // Send order notification emails
            OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);
            OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart);
        }

        return(true);
    }
    /// <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);
    }
예제 #4
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 (ShoppingCart.ShoppingCartBillingAddress == null)
        {
            ShoppingCartControl.LoadStep(0);
            return(false);
        }

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

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

            // Create order
            ShoppingCartInfoProvider.SetOrder(ShoppingCart);
        }
        catch (Exception ex)
        {
            // Show error
            lblError.Text = GetString("Ecommerce.OrderPreview.ErrorOrderSave");

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

        if (!ShoppingCartControl.IsInternalOrder)
        {
            // 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(SiteContext.CurrentSiteID)));
        }

        // Raise finish order event
        ShoppingCartControl.RaiseOrderCompletedEvent();

        // When in CMSDesk
        if (ShoppingCartControl.IsInternalOrder)
        {
            if (chkSendEmail.Checked)
            {
                // Send order notification emails
                OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);
                OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart);
            }
        }
        // When on the live site
        else if (ECommerceSettings.SendOrderNotification(SiteContext.CurrentSite.SiteName))
        {
            // Send order notification emails
            OrderInfoProvider.SendOrderNotificationToAdministrator(ShoppingCart);
            OrderInfoProvider.SendOrderNotificationToCustomer(ShoppingCart);
        }

        return(true);
    }