skip to Main Content

I need to add “out of stock” string next to product option when product are out of stock on this list. Can someone help me? Link to img ->1

2

Answers


  1. Magento having that as default functionality.

    You can see the code in the below path.

    vendor/magento/module-catalog/view/frontend/templates/product/list.phtml
    

    Below is the default Magento code

    <?php if ($_product->isAvailable()):?>
        <div class="stock available">
            <span><?= $escaper->escapeHtml(__('In stock')) ?></span>
        </div>
    <?php else:?>
        <div class="stock unavailable">
            <span><?= $escaper->escapeHtml(__('Out of stock')) ?></span>
        </div>
    <?php endif; ?>
    

    If you have overridden this file in your theme and didn’t have this code then you can add this code in your overridden file.

    Like :- app/design/frontend/THEME/NAME/Magento_Catalog/templates/product/list.phtml

    Please check and let me know if any query for the same.

    Thank you.

    Login or Signup to reply.
  2. Magento has default functionality to show out of stock at frontend with label.
    we have admin configuration for it.
    store => configuration => catalog

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search