Hi,
I need to create a new product flag which says something like "24h" or "available".
I made a few changes in ProductPresenter.php (i'm using Prestashop 1.7.2.4) and created it with the condition that it should appear if product quantity is not zero.
Now it works but not for all products. Flag won't appear if product has combinations and quantity of default combination is 0 (when default combination quantity is 1 or more than it works as it should).
Any help?
Expert Answer
Hello
I am not sure what you exactly added / changed in ProductPresenter.php core file but this what you expect can be done without core modifications.
You can use static function to get product's stock:
StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute = null, $id_shop = null)
so in smarty template file that is responsible for product miniature (on list of products) you can use code like:
{if StockAvailable::getStockAvailableIdByProductId($product.id_product, null, Context::getContext()->shop->id) > 0} do something {/if}
0 comments:
Post a Comment