Cart Appears Empty After Adding An Item & Visiting A New Page

Problem

A shopper adds an item to the cart, but the cart icon shows as empty when he or she visits a new page.

Cause #1

Header toplinks are not being properly hole punched. This can be verified by following this guide.

Solution #1

Checking the config - design from Magento Admin, we see it uses the default theme_revamp.

In header.phtml we see the following:

<div class="row">
  <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
    <div class="top-sticky-text">
      <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('header_sticky_block')->toHtml(); ?>
    </div>
  </div>
  <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
    <div class="top-links">
      <ul class="top-links-list">
        <?php if ($this->helper('customer')->isLoggedIn()): ?>
        <li><a href="<?php echo $this->getUrl('customer/account/logout'); ?>"><i class="account-icon"></i>Logout</a></li>
        <li><a href="<?php echo $this->getUrl('customer/account'); ?>"><i class="signup-icon"></i>My Account</a></li>
        <?php else: ?>
        <li><a href="<?php echo $this->getUrl('customer/account/login'); ?>"><i class="account-icon"></i>Login</a></li>
        <li><a href="<?php echo $this->getUrl('customer/account/create'); ?>"><i class="signup-icon"></i>Sign up</a></li>
        <?php endif ?>
        <li><a href="<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>"><i class="checkout-icon"></i>Checkout</a></li>
        <li class="bulk-link">
          <a href="<?php echo $this->getUrl('quickshopping'); ?>"><i class="bulkpro-icon"></i>Quick Shop</a>
        </li>
        <li class="search-cart-cart-btn">
          <?php $_cartQty = Mage::getSingleton('checkout/cart')->getSummaryQty()?Mage::getSingleton('checkout/cart')->getSummaryQty():'0'; ?>
          <div id="cart-main" class="search-cart cart-btn <?php if($_cartQty != 0) echo 'color-red'; ?>">
            <div class="div_link-cart">
              <div class="div_link-cart_inner"><?php echo $this->__('<a href="%s" id="topcartlink" class="top-cart"><i class="cart-icon"></i><span class="item-cart"> %s </span>items </a>', $this->getUrl('checkout/cart'),$_cartQty) ?>
                <div id="top_cart_sidebar" style="display: none"><?php echo $this->getChildHtml('em0050_cart_sidebar_top');?>
                </div>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</div>

Create a new template toprow.phtml in /home/user1/public_html/app/design/frontend/default/theme_revamp/template/page/html with the following content:

<div class="row">
  <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
    <div class="top-sticky-text">
      <?php 
      if (!$this->helper('customer')->isLoggedIn()) {
      echo $this->getLayout()->createBlock('cms/block')->setBlockId('header_sticky_block')->toHtml(); 
      } ?>
    </div>
  </div>
  <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
    <div class="top-links">
      <ul class="top-links-list">
        <?php if ($this->helper('customer')->isLoggedIn()): ?>
        <li><a href="<?php echo $this->getUrl('customer/account/logout'); ?>"><i class="account-icon"></i>Logout</a></li>
        <li><a href="<?php echo $this->getUrl('customer/account'); ?>"><i class="signup-icon"></i>My Account</a></li>
        <?php else: ?>
        <li><a href="<?php echo $this->getUrl('customer/account/login'); ?>"><i class="account-icon"></i>Login</a></li>
        <li><a href="<?php echo $this->getUrl('customer/account/create'); ?>"><i class="signup-icon"></i>Sign up</a></li>
        <?php endif ?>
        <li><a href="<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>"><i class="checkout-icon"></i>Checkout</a></li>
        <li class="bulk-link">
          <a href="<?php echo $this->getUrl('quickshopping'); ?>"><i class="bulkpro-icon"></i>Quick Shop</a>
        </li>
        <li class="search-cart-cart-btn">
          <?php $_cartQty = Mage::getSingleton('checkout/cart')->getSummaryQty()?Mage::getSingleton('checkout/cart')->getSummaryQty():'0'; ?>
          <div id="cart-main" class="search-cart cart-btn <?php if($_cartQty != 0) echo 'color-red'; ?>">
            <div class="div_link-cart">
              <div class="div_link-cart_inner"><?php echo $this->__('<a href="%s" id="topcartlink" class="top-cart"><i class="cart-icon"></i><span class="item-cart"> %s </span>items </a>', $this->getUrl('checkout/cart'),$_cartQty) ?>
                <div id="top_cart_sidebar" style="display: none"><?php echo $this->getChildHtml('em0050_cart_sidebar_top');?>
                </div>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</div>

Now update the releated part of header.phtml:

32 <div class="top-bar">
33   <div class="container">
34     <?php echo $this->getChildHtml('toprow'); ?>
35   </div>
36 </div>

In the layout file, add the new block inside the header section:

[/home/user1/public_html/app/design/frontend/default/theme_revamp/layout]# vi page.xml

<block type="core/template" name="toprow" as="toprow" template="page/html/toprow.phtml" />

Finally, in the LiteMage configuration, change the following:

  • Add toprow in Customized Block Names for “toplinks” Tag
  • Flush Product and Categories When Product Qty Changes = Flush product and categories only when stock status change
  • Separate cache copy per customer group = Yes
  • Track recently Viewed = No

Flush both LiteMage and Magento caches.

Cause #2

In this case, the user encounters similar problem. The store is using rwd theme, but overrides default ajaxcart by plumrocket. After further investigation, PlumRocket Ajax cart seems incompatible with LiteMage. Disable it and the problem goes away.

Solution #2

If you use PlumRocket - Ajax Cart or similar extension, Go to Magento admin panel. Configuration - PlumRocket - Ajax Cart → Enable Extension = No. It is suggested that you use rwd default ajax cart when using LiteMage.

  • Admin
  • Last modified: 2017/05/15 17:49
  • by Jackson Zhang