'only x left threshold' option not working
-
11-10-2020 - |
Question
I have set the threshold to 7, I've set a simple product to quantity 2 and manage stock etc is on, it's also in stock. The setting 'Display products availability in stock in the frontend' is set to yes, they're all set correctly on store view/website level etc.
Yet it doesn't display the message, it doesn't even seem to be pulling in the template file that the message is in (cataloginventory/stockqty/default.phtml) although I don't even know how it would pull in this file as it exists in cataloginventory not catalog, also I can't find any reference to it in catalog.xml
Solution
It works like below,
If you open file app\design\frontend\base\default\layout\cataloginventory.xml
<PRODUCT_TYPE_simple>
<reference name="product.info.simple.extra">
<block type="cataloginventory/stockqty_default" template="cataloginventory/stockqty/default.phtml"/>
</reference>
</PRODUCT_TYPE_simple>
Here the tag PRODUCT_TYPE_simple
defines that it is used for simple products. Inside this tag you can find a reference
tag with name product.info.simple.extra
This will check a block with the name product.info.simple.extra
and add the template file cataloginventory/stockqty/default.phtml inside it.
Now, if you search where the block with name product.info.simple.extra
is defined, you will get your catalog.xml file.
If you check app\design\frontend\rwd\YOUR_THEME\layout\catalog.xml you will find below code.
<PRODUCT_TYPE_simple translate="label" module="catalog">
<label>Catalog Product View (Simple)</label>
<reference name="product.info">
<block type="catalog/product_view_type_simple" name="product.info.simple" as="product_type_data" template="catalog/product/view/type/default.phtml">
<block type="core/text_list" name="product.info.simple.extra" as="product_type_data_extra" translate="label">
<label>Product Extra Info</label>
</block>
</block>
<block type="catalog/product_view_type_simple" name="product.info.availability" as="product_type_availability" template="catalog/product/view/type/availability/default.phtml" />
</reference>
</PRODUCT_TYPE_simple>
Here, you can see the block with name product.info.simple.extra
So, the first file cataloginventory.xml will add the template to this block.
Please check your catalog.xml if you have a block with name product.info.simple.extra
inside it which is responsible for adding the message on product view page.