public ShoppingCart CreateEmptyShoppingCart()
        {
            var originalCart = ShoppingCartFactory.CreateCart(SiteID);

            ShoppingCartInfoProvider.SetShoppingCartInfo(originalCart);

            return(new ShoppingCart(originalCart, new EcommerceActivitiesLoggerFake(), null, null));
        }
示例#2
0
        public ShoppingCart CreateCartWithCustomerInfo(CustomerInfo customer, AddressInfo address = null, ICurrentContactProvider currentContactProvider = null)
        {
            var cartInfo = ShoppingCartFactory.CreateCart(SiteID);

            cartInfo.ShoppingCartCurrencyID = Factory.MainCurrency.CurrencyID;
            cartInfo.Customer = customer;
            cartInfo.ShoppingCartBillingAddress = address;

            ShoppingCartInfoProvider.SetShoppingCartInfo(cartInfo);

            return(new ShoppingCart(cartInfo, new EcommerceActivitiesLoggerFake(), currentContactProvider));
        }
示例#3
0
    protected ShoppingCartInfo GetNewCart()
    {
        ShoppingCartInfo cart = null;
        var siteId            = SiteContext.CurrentSiteID;

        if (customerId > 0)
        {
            var customer = CustomerInfo.Provider.Get(customerId);
            if (customer != null)
            {
                cart = ShoppingCartFactory.CreateCart(siteId, customer.CustomerUser);
                cart.ShoppingCartCustomerID = customerId;
            }
        }

        cart = cart ?? ShoppingCartFactory.CreateCart(siteId);

        return(cart);
    }
示例#4
0
    /// <summary>
    /// Creates a new shopping cart record and corresponding shopping cart items records in the database
    /// as a copy of given shopping cart info.
    /// Currency is set according to the currency of the given cart.
    /// If a configuration of cart item is no longer available it is not cloned to new shopping cart.
    /// <see cref="AbstractUserControl.CurrentUser"/> is set as the new cart owner (only non-public user is set).
    /// </summary>
    /// <param name="originalCart">Original cart to clone.</param>
    /// <returns>Created shopping cart info.</returns>
    private ShoppingCartInfo CloneShoppingCartInfo(ShoppingCartInfo originalCart)
    {
        using (new CMSActionContext {
            UpdateTimeStamp = false
        })
        {
            var cartClone = ShoppingCartFactory.CreateCart(CurrentSite.SiteID, CurrentUser.IsPublic() ? null : CurrentUser);

            cartClone.ShoppingCartCurrencyID = originalCart.ShoppingCartCurrencyID;
            cartClone.ShoppingCartLastUpdate = originalCart.ShoppingCartLastUpdate;
            ShoppingCartInfoProvider.SetShoppingCartInfo(cartClone);

            ShoppingCartInfoProvider.CopyShoppingCartItems(originalCart, cartClone);

            // Set the shopping cart items into the database
            cartClone.CartItems.ForEach(i => i.Generalized.SetObject());

            return(cartClone);
        }
    }
示例#5
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var currentSite = SiteContext.CurrentSite;

        // If shopping cart is created -> create empty one
        if ((ShoppingCartInfoObj == null) && (currentSite != null))
        {
            var currentUser = MembershipContext.AuthenticatedUser;

            ShoppingCartInfoObj = ShoppingCartFactory.CreateCart(currentSite.SiteID, currentUser);
        }

        // Display / hide checkout process images
        plcCheckoutProcess.Visible = false;

        // Load current step data
        LoadCurrentStep();

        if (CurrentStepIndex == 0)
        {
            ShoppingCartInfoObj.PrivateDataCleared = false;
            btnBack.Enabled = false;
        }

        // If shopping cart information exist
        if (ShoppingCartInfoObj != null)
        {
            // Get order information
            var order = OrderInfo.Provider.Get(ShoppingCartInfoObj.OrderId);

            // If order is paid
            if ((order != null) && (order.OrderIsPaid))
            {
                // Disable specific controls
                btnNext.Enabled            = false;
                CurrentStepControl.Enabled = false;
            }
        }
    }
    /// <summary>
    /// Creates a new shopping cart record and corresponding shopping cart items records in the database
    /// as a copy of given shopping cart info.
    /// Currency is set according to the currency of given cart.
    /// If a configuration of cart item is no longer available it is not cloned to new shopping cart.
    /// Correct user id for logged user is _not_ handled in this method, because it does not depend on
    /// abandoned cart's user id. It should be handled according to user's status (logged in/anonymous)
    /// in the browser where the cart is loaded:
    ///  - anonymous cart or user's cart opened in the browser where user is logged in - new cart userId should be set to logged user's id
    ///  - anonymous cart or user's cart opened in the browser where user is _not_ logged in - new cart userId should be empty (anonymous cart)
    /// </summary>
    /// <param name="originalCart">Original cart to clone.</param>
    /// <returns>Created shopping cart info.</returns>
    private ShoppingCartInfo CloneShoppingCartInfo(ShoppingCartInfo originalCart)
    {
        using (new CMSActionContext {
            UpdateTimeStamp = false
        })
        {
            ShoppingCartInfo cartClone = ShoppingCartFactory.CreateCart(CurrentSite.SiteID, originalCart.User);

            cartClone.ShoppingCartCurrencyID = originalCart.ShoppingCartCurrencyID;
            cartClone.ShoppingCartLastUpdate = originalCart.ShoppingCartLastUpdate;
            ShoppingCartInfoProvider.SetShoppingCartInfo(cartClone);

            ShoppingCartInfoProvider.CopyShoppingCartItems(originalCart, cartClone);

            // Set the shopping cart items into the database
            foreach (ShoppingCartItemInfo item in cartClone.CartItems)
            {
                ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(item);
            }

            return(cartClone);
        }
    }