public int GetProductStockStatus(int ProductID, object[] ProductOptions, int Quantity)
    {
        WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");

        int        productStockStatus = 1;
        List <int> productOptions     = new List <int>();

        Array.ForEach(ProductOptions, (o) => productOptions.Add(Convert.ToInt32(o)));

        InvertedSoftware.ShoppingCart.DataLayer.DataObjects.Inventory inventory = InvertedSoftware.ShoppingCart.DataLayer.Database.Inventory.GetProductInventory(ProductID, productOptions);
        InventoryAction inventoryAction;

        Enum.TryParse(inventory.InventoryActionID.ToString(), out inventoryAction);

        switch (inventoryAction)
        {
        case InventoryAction.StopSellingOption:
            if (inventory.ProductAmountInStock < Quantity)
            {
                productStockStatus = 0;
            }
            break;

        case InventoryAction.StopSellingProduct:
            if (inventory.ProductAmountInStock < Quantity)
            {
                productStockStatus = 0;
            }
            break;

        case InventoryAction.ShowPreOrderOption:
            if (inventory.ProductAmountInStock < Quantity)
            {
                productStockStatus = 2;
            }
            break;

        case InventoryAction.ShowPreOrderProduct:
            if (inventory.ProductAmountInStock < Quantity)
            {
                productStockStatus = 2;
            }
            break;

        default:
            productStockStatus = 1;
            break;
        }

        return(productStockStatus);
    }
示例#2
0
    protected void ProductsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Separator)
        {
            if (((e.Item.ItemIndex + 1) * 2 % Columns) != 0)
            {
                e.Item.Visible = false;
            }
        }

        Button      AddButton            = e.Item.FindControl("AddButton") as Button;
        HiddenField ProductIDHiddenField = e.Item.FindControl("ProductIDHiddenField") as HiddenField;

        if (AddButton == null || ProductIDHiddenField == null)
        {
            return;
        }
        if (Products.IsProductOptionsExist(Utils.GetDecodedInt(HttpUtility.UrlDecode(ProductIDHiddenField.Value))))
        {
            AddButton.Text        = "Customize";
            AddButton.CommandName = "Customize";
        }
        else
        {
            //Check Inventory
            InventoryAction inventoryAction;
            InvertedSoftware.ShoppingCart.DataLayer.DataObjects.Inventory inventory = InvertedSoftware.ShoppingCart.DataLayer.Database.Inventory.GetProductInventory(Utils.GetDecodedInt(HttpUtility.UrlDecode(ProductIDHiddenField.Value)), new List <int>());
            Enum.TryParse(inventory.InventoryActionID.ToString(), out inventoryAction);

            if (inventoryAction == InventoryAction.StopSellingProduct && inventory.ProductAmountInStock == 0)
            {
                AddButton.Enabled = false;
                AddButton.Text    = "Out of Stock.";
            }
            else if (inventoryAction == InventoryAction.ShowPreOrderProduct && inventory.ProductAmountInStock == 0)
            {
                AddButton.Text = "Pre Order.";
            }
        }
    }
示例#3
0
    /// <summary>
    /// For products with no options check inventory on load.
    /// </summary>
    public void CheckProductInventory()
    {
        if (ProductOptionsControl1.HasOptions)
        {
            return;
        }

        InventoryAction inventoryAction;

        InvertedSoftware.ShoppingCart.DataLayer.DataObjects.Inventory inventory = InvertedSoftware.ShoppingCart.DataLayer.Database.Inventory.GetProductInventory(CartProduct.ProductID, new List <int>());
        Enum.TryParse(inventory.InventoryActionID.ToString(), out inventoryAction);

        if (inventoryAction == InventoryAction.StopSellingProduct && inventory.ProductAmountInStock == 0)
        {
            AddButton.Enabled = false;
            AddButton.Text    = "Sorry Out of Stock.";
        }
        else if (inventoryAction == InventoryAction.ShowPreOrderProduct && inventory.ProductAmountInStock == 0)
        {
            AddButton.Text = "Currently out of stock. Click here to pre order.";
        }
    }