Show IN STOCK even if stock is ZERO and using Backorders with "Allow qty below 0"...

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 года назад
Hi!

NC 3.90

In \Views\Shared\_ProductBox.cshtml to show the stocks availability I use following code:

<div class="productIDandStock">
    <!--Product ID-->
    <div class="productId">@T("productid"): @Model.Id</div>
    <!-- Availability -->
    @if (productQuantity < 1)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }
   </div>


I have a plugin to control all stocks (Suppliers, Incoming Products, Returning and etc..).
There are some products which I don't currently have in stock, but I want to allow customers buy them. Anf if thete is a customer for this product, then I create Purchase from supplier and then receive it and the quantity will be updated.
So, I put following settings in inventory management:
Inventory method — Track inventory
Stock quantity — 0
Display availability — Checked  
Low stock activity — Nothing  
Backorders  — Allow qty below 0


So, in this case it shows OUT OF STOCK... I need it to show IN STOCK like as if there are some stocks of this product.

How can I do it?

Is there any solution like this maybe? :) I am not much coder :)
<!-- Availability -->
    @if (productQuantity < 1) (backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1) (backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }


Don't laugh at me! :) And thanks in advance. Hope someone helps me!
2 года назад
<!-- Availability -->
    @if (productQuantity < 1) (backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1) (backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }



Hmm, as i can see you miss the && in if's
you can try with it
<!-- Availability -->
    @if (productQuantity < 1) && (backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1) && (backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }
2 года назад
musoviich wrote:
Hmm, as i can see you miss the && in if's
you can try with it
<!-- Availability -->
    @if (productQuantity < 1) && (backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1) && (backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }


It doesn't work.
2 года назад
Let me get this right, you want to show 'In Stock' if qty < 0 and backorders true, and of course if qty > 1?

If so, then:


<!-- Availability -->
    @if (productQuantity < 1 && backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1 && backorders = true || productQuantity < 1 && backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }
2 года назад
untiedshoes wrote:
Let me get this right, you want to show 'In Stock' if qty < 0 and backorders true, and of course if qty > 1?

If so, then:


<!-- Availability -->
    @if (productQuantity < 1 && backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1 && backorders = true || productQuantity < 1 && backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }


I want to show IN STOCK if quantity is ZERO or LESS (minus) and if Backorders "Allow qty below 0" is selected.

If Backorders "Allow qty below 0" is NOT selected and quantity is ZERO or less, then show OUT OF STOCK.

If Backorders "Allow qty below 0" is NOT selected and quantity is more than 1, then show IN STOCK.

You can see Backorders in Inventory Management when editing a product.
2 года назад
untiedshoes wrote:
Let me get this right, you want to show 'In Stock' if qty < 0 and backorders true, and of course if qty > 1?

If so, then:


<!-- Availability -->
    @if (productQuantity < 1 && backorders = false)
    {
      <div class="out-of-stock">@T("products.availability.outofstock")</div>
    }
    @if (productQuantity > 1 && backorders = true || productQuantity < 1 && backorders = true)
    {
      <div class="in-stock">@T("products.availability.instock")</div>
   }


Did you check it yourself? :) It doesn't work...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.