简体   繁体   English

magento产品页面的phtml代码

[英]phtml code for magento product page

I want to insert some text directly below the tier price html if there is tier price info for item. 如果要提供商品的分级价格信息,我想在分级价格html下方直接插入一些文本。 So I am looking for code for a if then. 所以我正在寻找一个if的代码。 This is what I have so far but it is not working. 到目前为止,这是我所拥有的,但是没有用。 I am getting TEST for every product and not just for the tier price products. 我对每种产品都进行了测试,而不仅仅是对价格较高的产品进行了测试。

<?php if ($this->getTierPriceHtml()):?>
<h2><?php echo $this->__('TEST') ?></h2>
<?php endif; ?>

If you inspect the value returned by 如果检查由返回的值

$this->getTierPriceHtml()

when it is empty you will see that it is returning blank html with lots of spaces.Thats why when you cneck for 当它为空时,您会看到它返回带有很多空格的空白html。这就是为什么当您

if ($this->getTierPriceHtml()):

always return true because there is blank spaces. 总是返回true,因为有空格。

So first check like below 所以先检查如下

       $tier = $this->getTierPriceHtml();                    
                             $string = preg_replace('/\s+/', '', $tier);//This will remove all spaces
                             if($string!=""){
                                 echo $this->__('TEST');
                              }

Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM