【问题标题】:phtml code for magento product pagemagento产品页面的phtml代码
【发布时间】:2015-01-14 04:38:30
【问题描述】:

如果项目有等级价格信息,我想在等级价格 html 下方直接插入一些文本。所以我正在寻找一个 if 的代码。这是我到目前为止所拥有的,但它不起作用。我正在为每种产品进行测试,而不仅仅是针对平价产品。

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

【问题讨论】:

    标签: magento php


    【解决方案1】:

    如果您检查由

    返回的值
    $this->getTierPriceHtml()
    

    当它为空时,您会看到它返回带有大量空格的空白 html。这就是为什么当您点击时

    if ($this->getTierPriceHtml()):
    

    总是返回 true,因为有空格。

    所以首先检查如下

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

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-27
      • 2016-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多