20110921 Wednesday September 21, 2011

Magento: Google Checkout Button in Side Cart

I haven't written any articles in a while, and thought I should write a quick one about a Magento 'fix' I needed to do today.  Magento isn't the cleanest and most straight-forward software to extend, so I usually find myself doing a quick search to see if anyone has already tackled whatever customization a customer is asking for.  This time, I only found bad examples of how to do this.

The best way to extend Magento in order to future-proof your modifications is to define overrides in a local.xml layout and doing everything you possibly can to avoid hacking up or overriding any default layouts or templates.  Adding the Google Checkout button to the side bar cart is a typical example where I found several people outlining how to hack up existing templates to accomplish this.

None of this is necessary.

Following is the local.xml modifications that will insert Google Checkout into the cart side bar.

<!--?xml version="1.0" encoding="UTF-8"?-->
<layout>
  <default>
    <!-- Add google checkout link in side cart -->
    <reference name="cart_sidebar.extra_actions">
      <block type="googlecheckout/link" name="googlecheckout.partner.cart_sidebar.shortcut" template="googlecheckout/link.phtml" before="-">
    </block></reference>
  </default>
</layout>

Please make sure you comment what your modifications to local.xml do. It's not always intuitive months later, and I might have to work on it after you do. :)

Posted at September 21, 2011 by Cott in General Add a Comment

Recent Entries