Magento - How to get cart items total in header.phtml

前端 未结 7 1331
孤街浪徒
孤街浪徒 2021-02-05 12:11

I am using Magento eCommerce and I have modified my header.phtml via the Blank template. Code, this is my code but it shows blank.

 

        
7条回答
  •  长情又很酷
    2021-02-05 12:34

    There was an answer to a link before by someone called SUHUR I think, I was going to reward him with the answer but it seems he deleted his own post?

    He linked to this: http://nothingtopost.wordpress.com/tag/how-to-get-total-cart-item-in-magento/

    I modified my code and this works now on .phtml files.

    helper('checkout/cart')->getSummaryCount();  //get total items in cart
          $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
          if($count==0)
          {
            echo $this->__('(0 ITEMS)',$count);
          }
          if($count==1)
          {
            echo $this->__('(1 ITEM)',$count);
          }
          if($count>1)
          {
            echo $this->__('(%s ITMES)',$count);
          }
          echo $this->__('', $this->helper('core')->formatPrice($total, false));
        ?>
    

提交回复
热议问题