【问题标题】:Magento Hide Div ID if Grand Total Less than Dollar Amount如果总计小于美元金额,Magento 隐藏 Div ID
【发布时间】:2013-03-04 18:19:01
【问题描述】:

我正在尝试根据购物车总计隐藏或显示一个 div。例如,如果购物车总计少于 79 美元,我想隐藏 div。我尝试过使用条件语句,但效果不太好。我尝试在 onepage.phtml、review.phtml(放置 div 的位置)和包含我想隐藏的 div 的实际文件中使用以下代码。

<?php
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); 
$subtotal = round($totals["subtotal"]->getValue()); 
$grandtotal = round($totals["grand_total"]->getValue()); 
if ($grandtotal <= '79'){ ?>
     <script type="text/javascript">$('#gifterWrap').hide()</script>
   <?php
    }
?>

任何见解将不胜感激。

编辑:在尝试了下面的一些修复后,我认为错误可能出现在代码的第一部分,在那里我得到了总计小计等。

【问题讨论】:

    标签: magento html hide checkout


    【解决方案1】:

    也许:

     <script language="javascript">
         grandTotal=<?php echo round($totals["grand_total"]->getValue());?>;
         alert(grandTotal); // to check if it's the right value.
         if (grandTotal<=79){
             $('#gifterWrap').css('display', 'none');
         }
     </script>
    

    【讨论】:

    • 由于某种原因,当点击继续按钮时,这导致一步结帐在第 5 步(共 6 步)重定向到购物车的第一页。有什么想法吗?
    • 尝试使用 Firebug 或 Chrome 在 JS 中放置断点。
    【解决方案2】:

    尝试将 '79'(字符串)更改为 79(整数)

    <?php if(79 >= Mage::getModel('checkout/cart')->getQuote()->getGrandTotal()): ?>
         <script type="text/javascript">$('#gifterWrap').hide()</script>
    <?php endif; ?>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 2023-04-07
    • 1970-01-01
    • 2023-04-10
    • 2017-11-11
    相关资源
    最近更新 更多