如果库存水平 = 0,magento 隐藏立即购买按钮
我们有一个自定义属性,是我们以前的开发人员(最近消失了)在 magento 管理区域中创建的。这是一个 getIn_stock 属性,它从销售点系统读取以检查库存水平。它返回 1(有货)或 0(缺货)。我一直在研究如何根据此属性的输出显示不同的内容。我发现一个基于产品价格等于 0 的线程,并尝试在 getIn_stock 属性上使用它,但没有成功。即使属性返回值 0,以下内容也会显示“In Stock”。
<?php if($_product->getIn_stock==0): ?>
<?php echo 'Out of stock'; ?>
<?php else: ?>
<p>In Stock</p>
<?php endif; ?>
任何建议都会有很大帮助。先感谢您 :)
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 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
var_dump($_product->getIn_stock);
放在if()
子句之前,查看属性中的实际值。put
var_dump($_product->getIn_stock);
right before yourif()
clause and see what actual value is in the property.