Cart is Being Punched But Still Not Loading Properly

Problem

LiteMage debug shows the cart being punched but it is still not working properly.

Cause

The cart was actually being loaded via the footer element and not the header element. This caused the cart to be loaded in an invalid order and caused it to not load the correct information.

Solution

Find the cart code in footer.phtml and move it to header.phtml. In addition to this make sure that the values inside local.xml pertaining to the cart are moved from the footer block to the header block. After the changes are done in the code, be sure to flush LiteMage and Layout cache.

For example, move the following code from footer.phtml to header.phtml:

<nav role="navigation">
    <ul id="navigation-menu" class="navigation-menu">
        <li class="mobile-search hide-for-large-up">
            <form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
                <input type="search" name="q" id="search" placeholder="Search ...">
            </form>
        </li>

        <?php
            $navigation = $this->getLayout()->createBlock('cms/block')->setBlockId('main_navigation_menu')->toHtml();
            $brands_pulldown = $this->getChildHtml('brand_selector');
            $navigation = str_replace("[[BRAND PULLDOWN]]", $brands_pulldown, $navigation);
            echo $navigation;
        ?>
        <li class="has-children shopping-bag hide-for-small-only">
            <a href="#" class="">Shopping Bag</a>

            <ul class="secondary-nav is-hidden">
                <li class="go-back"><a href="#0">Menu</a></li>
                <li class="see-all"><a href="/checkout/cart/">View your bag</a></li>

                <li class="has-children">
                    <a href="/checkout/cart/">Items in your bag</a>

                    <ul class="is-hidden">
                        <li class="go-back"><a href="#0">Items in Your bag</a></li>
                        <li class="see-all"><a href="/checkout/cart/">View Shopping Bag</a></li>
                        <?php echo $this->getChildHtml('cart_sidebar');?>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</nav>

Similarly, for local.xml move the following from the footer block to header block:

           <block type="checkout/cart_sidebar" name="cart_sidebar" as="cart_sidebar" template="checkout/cart/sidebar.phtml" >
                <action method="unsetData"><key>cache_lifetime</key></action>
           </block>
  • Admin
  • Last modified: 2017/05/08 21:56
  • by Lisa Clarke