Display Stock Availability

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hello,

I'm trying to adjust nopcommerce to my future onlline shop.
To this end, the option available in stock is very important to appear in store.

I have products with variants, and I want to manage the stock because they are different products.
Example:
Fragrance X
  Variant 10 ml-10 €
  Variant 20 ml-20 €

I tried to create in nopcommerce with the following options:

Product Info
    Product Name: Fragrance X
    Product type: Standard Product
    Product template: Variant in Grid
    Published: Yes

Product Variant
    Product variant name: 10 ml
    Product SKU:1
    Manage Stock: Track inventory fot this product
    Stock quantity: 1
    Display Stock Availability: Yes
    Minimum stock quantity: 0
    Allow out of stock orders: Yes
****************************
    Product variant name: 20 ml
    Product SKU:1
    Manage Stock: Track inventory fot this product
    Stock quantity: 0
    Display Stock Availability: Yes
    Minimum stock quantity: 0
    Allow out of stock orders: Yes

In the store appears:

Product Fragrance X
   variant 10 ml - Availability: In stock
   variant 20 ml - Availability: In stock

After many tests I noticed that the option "Allow orders out of stock" is to blame for the mistake. Let me explain:

If I have the option "Allow out of stock orders with value true information that appears is always IN STOCK even though the product has stock = 0
If I have the option "Allow out of stock orders with value false, then the information that appears is correct and based on what is in the product data.

Example:

In the store appears:
   With Allow out of stock orders = false (all variants)
    Product Fragrance X
           variant 10 ml - Availability: In stock
           variant 20 ml - Availability: Out of stock

   With Allow out of stock orders = True (all variants or in variant name 20ml)    Product Fragrance X
           variant 10 ml - Availability: In stock
           variant 20 ml - Availability: In stock

Is bug?

Best regards
13 years ago
Nobody knows the answer. Neither team nop_commerce?
13 years ago
I have the same query - https://www.nopcommerce.com/boards/t/4264/allow-out-of-stock-orders-a-bug-or-just-by-design.aspx

I'd like to see this addressed in the next release.
13 years ago
Hello,

I think I've solved the problem. I'm making some tests to make sure everything is correct.
Tomorrow I already have certainty and post here how I resolved the issue

Best regards
13 years ago
But if we display 'Out of stock', then a customer can think he is not able to purchase a product. But if don't like it and would like to modify this behaviour, then follow the next steps:
1. Open \Templates\Products\OneVariant.ascx.cs file
2. Go to line 98
3. Replace if(productVariant.StockQuantity > 0 || productVariant.AllowOutOfStockOrders) with if(productVariant.StockQuantity > 0)
4. Do the same for Modules\ProductVariantsInGrid.ascx.cs file (line 218)

P.S. More advanced backorer support will be intriduced in upcoming 1.80 release
13 years ago
Hello Andrei,

Thanks for the help.
But the aim is to show that the product does not exist in stock.
Let me explain:

All products are in stock we can dispatch products within a short time (24/48 hours).
If there is not in stock, it will take longer because we have the order to the supplier. There are products that have in stock does not pay, but need arise available for sale.

So when customer buys a product, know it will take longer to receive your order.
About version 1.8 I will test

Best regards.
13 years ago
I think what you want is three flags:

In Stock
Back-Ordered add 1-2 weeks (or something like that)
Out of Stock

The first two being still "orderable".  The last, not.  The only thing you should have to do is edit the label's text so that the customer knows not to expect the item too soon.

I would think that would be relatively easy, you just need to find where the "in-stock" label is and modify the code with a different if statement

If Qty=0 AND AllowOutOfStockOrders=YES
   label="Back Ordered ad 1-2 weeks"
else if Qty=0 AND AllowOutOfStockOrders=NO
   label="Out of Stock"
else
   label="In Stock"

Of course that's not real code and you'll have to access GetLocaleResourceString.  You will probably want to add a record nop_LocaleStringResource for the third option.

I'll look at it a bit more and see if I can find exactly what needs changing and get back...  if you don't beat me to it.
13 years ago
Backorder function – or how to get Allow Out Of Stock Orders to work properly.
Works for v1.60.  This shows the item out of stock with a custom message and also adds a message to the shopping cart to show it is out of stock.  The custom message on the product page and the message in the shopping cart are configurable localised resource strings.

To show out of stock with custom message on the product page:

In Modules/ProductVariantsInGrid.ascx.cs, find this block of code (approx line 218):

                        if (productVariant.StockQuantity > 0 || productVariant.AllowOutOfStockOrders)
                        {
                            lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.InStock"));
                        }
                        else
                        {
                            lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.OutOfStock"));

                        }
Comment it out and insert this code:


// Start custom code to show out of stock but can allow an order to be placed
                        if (productVariant.StockQuantity <= 0 && productVariant.AllowOutOfStockOrders)
                        {
                            lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.OutOfStockAllowed"));
                        }
                        else if (productVariant.StockQuantity > 0)
                        {
                            lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.InStock"));
                        }
                        else
                        {
                            lblStockAvailablity.Text = string.Format(GetLocaleResourceString("Products.Availability"), GetLocaleResourceString("Products.OutOfStock"));
                        }
                        //End custom code


Now in your database find and open the table Nop_LocaleResourceString.  Add the following entry:

LanguageID = 7
ResourceName = Products.OutOfStockAllowed
ResourceValue = Awaiting stock.  Please order and it will be despatched asap.

Obviously 7 is for English and you can set the ResourceValue to whatever custom message you want to display for the availability label, such as "Not usually held in stock.  Will be ordered specifically, allow 2 days".  Note this message is the same for every productvariant so should be generic.

To show a message in the shopping cart for an item which is out of stock but allowed to be ordered:


Open Modules/OrderSummary.ascx.cs and in the function called ValidateCartItems find the following block of code:


if (warnings.Count > 0)
                        {
                            hasErrors = true;
                            if (pnlWarnings != null && lblWarning != null)
                            {
                                pnlWarnings.Visible = true;
                                lblWarning.Visible = true;

                                var addToCartWarningsSb = new StringBuilder();
                                for (int i = 0; i < warnings.Count; i++)
                                {
                                    addToCartWarningsSb.Append(Server.HtmlEncode(warnings[i]));
                                    if (i != warnings.Count - 1)
                                    {
                                        addToCartWarningsSb.Append("<br />");
                                    }
                                }

                                lblWarning.Text = addToCartWarningsSb.ToString();
                            }
                        }



Insert this code after it:


                        // Start custom code here to check for allow out of stock order and add warning
                        ProductVariant pv = ProductManager.GetProductVariantById(sci.ProductVariantId);
                        if ((pv.AllowOutOfStockOrders && pv.StockQuantity <= 0) || (pv.AllowOutOfStockOrders && pv.StockQuantity < sci.Quantity ))
                        {
                            pnlWarnings.Visible = true;
                            lblWarning.Visible = true;
                            lblWarning.Text = string.Format(GetLocaleResourceString("ShoppingCart.AllowOutOfStockOrder"));
                        }
                        // End custom code



Build, upload the changed files and the nopCommerce.dll

Now in your database find and open the table Nop_LocaleResourceString.  Add the following entry:

LanguageID = 7
ResourceName = ShoppingCart.AllowOutOfStockOrder
ResourceValue = This item will be despatched once received in stock

Obviously again this is for English and you can set the ResourceValue to whatever custom message you want to display such as "Expected to be despatched in 2 days".

You can see the result for the product at the link below.  Add this product to your cart and click checkout to view the shopping cart warning – please note this is a live site so abandon your cart and don't place any orders!

http://www.waterware.co.uk/products/340-m31-battery-upgrade-pack.aspx
13 years ago
Thanks steveeb and diggers.

Andrei's Commentary, I managed to resolve the situation.
Diggers, information to the customer that the product does not exist in stock in OrderSummary is a magnificent idea.

Thank you!
13 years ago
Hello again.

The changed version (v1.8) and now I do not know how to achieve the same result.
Can anyone help?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.