Ejemplo n.º 1
0
    protected void uxAddToCartButton_Click(object sender, EventArgs e)
    {
        PromotionSelected promotion = new PromotionSelected(StoreContext.Culture, new StoreRetriever().GetCurrentStoreID());

        promotion.SetPromotionGroupID = PromotionGroupID;
        bool isSuccess = true;

        foreach (DataListItem item in uxList.Items)
        {
            if (item.FindControl("uxGroup") != null)
            {
                Mobile_Components_PromotionProductGroup group = (Mobile_Components_PromotionProductGroup)item.FindControl("uxGroup");
                if (group.IsSelectedProduct)
                {
                    string   productGroup = group.GetSelectedOption;
                    string[] groupInfo    = productGroup.Split(':');

                    IList <string> options = new List <string>();
                    foreach (string option in groupInfo[1].Split(','))
                    {
                        if (option.Trim() == "")
                        {
                            continue;
                        }
                        options.Add(option);
                    }
                    Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, groupInfo[0], new StoreRetriever().GetCurrentStoreID());
                    promotion.AddSelectedPromotionItem(group.PromotionSubGroupID, product, options);
                }
                else
                {
                    isSuccess = false;
                }
            }
        }
        if (!isSuccess)
        {
            return;
        }

        // Check Inventory
        isSuccess = CheckOutOfStock(promotion.PromotionSelectedItems);
        if (!isSuccess)
        {
            return;
        }
        // Check Free Shipping
        isSuccess = PromotionSelected.CheckCanAddItemToCart(StoreContext.ShoppingCart, promotion);
        if (isSuccess)
        {
            PromotionSelected.AddPromotionItem(StoreContext.ShoppingCart, promotion, 1);
            Response.Redirect("ShoppingCart.aspx");
        }
        else
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=" + promotion.GetPromotionGroup().PromotionGroupID);
        }
    }
Ejemplo n.º 2
0
    protected void uxAddToCartButton_Click(object sender, EventArgs e)
    {
        PromotionSelected promotion = new PromotionSelected(StoreContext.Culture, new StoreRetriever().GetCurrentStoreID());

        promotion.SetPromotionGroupID = PromotionGroupID;
        bool isSuccess = true;

        foreach (DataListItem item in uxList.Items)
        {
            if (item.FindControl("uxGroup") != null)
            {
                Components_PromotionProductGroup group = (Components_PromotionProductGroup)item.FindControl("uxGroup");
                if (group.IsSelectedProduct)
                {
                    string   productGroup = group.GetSelectedOption;
                    string[] groupInfo    = productGroup.Split(':');

                    IList <string> options = new List <string>();
                    foreach (string option in groupInfo[1].Split(','))
                    {
                        if (option.Trim() == "")
                        {
                            continue;
                        }
                        options.Add(option);
                    }
                    Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, groupInfo[0], new StoreRetriever().GetCurrentStoreID());
                    promotion.AddSelectedPromotionItem(group.PromotionSubGroupID, product, options);
                }
                else
                {
                    isSuccess = false;
                }
            }
        }
        if (!isSuccess)
        {
            return;
        }

        // Check Inventory
        isSuccess = CheckOutOfStock(promotion.PromotionSelectedItems);
        if (!isSuccess)
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=0&PromotionStock=1");
        }
        // Check Free Shipping
        isSuccess = CartItemPromotion.CheckCanAddItemToCart(StoreContext.ShoppingCart, promotion);
        if (isSuccess)
        {
            PromotionSelected.AddPromotionItem(StoreContext.ShoppingCart, promotion, 1);

            bool enableNotification = ConvertUtilities.ToBoolean(DataAccessContext.Configurations.GetValue("EnableAddToCartNotification", StoreContext.CurrentStore));
            if (UrlManager.IsMobileDevice(Request))
            {
                enableNotification = false;
            }
            if (enableNotification)
            {
                uxAddToCartNotification.Show(promotion, 1);
            }
            else
            {
                Response.Redirect("ShoppingCart.aspx");
            }
        }
        else
        {
            Response.Redirect("AddShoppingCartNotComplete.aspx?ProductID=0&FreeShiping=1");
        }
    }