2

I have moved my cart sidebar to the header using the code below in my local xml. I am now struggling to display crosssells inside this mini cart and am seeking guidance (they display fine on the actual cart page, and I have re-indexed several times).

<default>
    <reference name="left"><action method="unsetChild"><name>cart_sidebar</name></action></reference>
    <reference name="right"><action method="unsetChild"><name>cart_sidebar</name></action></reference>
    <reference name="header">               
        <block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/topcart.phtml"/>
        <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>
    </reference>
</default>

Products are added to this top cart using ajax (however crosssells don't display in mini cart at any time). I have tried to include the cross sells within my topcart.phtml file using

<?php echo $this->getChildHtml('crosssell') ?>

I have also tried the following in my local.xml to no avail

<checkout_cart_index>
        <reference name="header">
                <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>
     </reference>
    </checkout_cart_index>

And have also experimented using a crosssellhead.phtml file in my themes checkout cart template folder.

Thanks

  • Have you tried debugging the function Mage_Checkout_Block_Cart_Crosssell::getItems as this is what should do the loading of items – David Manners Dec 3 '14 at 11:08
2

I just tried this way and works for me:

 <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>

Add this code in header.phtml or other file where you want to show the crossells

<div class="top-panel mini-cart pp-shopping-block" data-role="pp-shopping">

      // Calls the mini cart
      <?php echo $this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout/cart/sidebar.phtml')->toHtml();?>

      // Calls Cross-Sells
      <?php echo $this->getLayout()->createBlock('checkout/cart_crosssell')->setTemplate('checkout/cart/crosssell.phtml')->toHtml();?>

</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.