开发者

magento hide buy now button if stock level = 0

开发者 https://www.devze.com 2023-01-20 13:47 出处:网络
We have a custom attribute that our previous developer (recently disappeared) has created in the magento admin area. This is a getIn_stock attribute which is reading from the point of sale system to c

We have a custom attribute that our previous developer (recently disappeared) has created in the magento admin area. This is a getIn_stock attribute which is reading from the point of sale system to check stock levels. It is returning either a 1 (in stock) or a 0 (out of stock). I have been digging around to see how I can display different content based on the output of this attribute. I found a thread that was based on the product 开发者_C百科price equaling 0 and tried to use it on the getIn_stock attribute but no luck. The following displays 'In Stock' even if the attribute returns a value of 0.

<?php if($_product->getIn_stock==0): ?>
                <?php echo 'Out of stock'; ?>
<?php else: ?>
<p>In Stock</p>
<?php endif; ?>

Any advice would be a great help. Thank you in advance :)


put var_dump($_product->getIn_stock); right before your if() clause and see what actual value is in the property.

0

精彩评论

暂无评论...
验证码 换一张
取 消