How to add a Google Checkout button to any page in Magento

Image representing Magento as depicted in Crun...
Image via CrunchBase

This post answers a very simple question I had, one I could not find an answer for.  I needed to add additional Google Checkout buttons to Magento‘s onepage checkout and maybe the sidebar cart.  I found other people asking the same thing, and answers ranged from cryptic to unhelpful.  But I did find a solution.

Step 1

Add this snippet to the template file where you want the Google Checkout button to appear:

getLayout()->createBlock('googlecheckout/link')->setTemplate('googlecheckout/link.phtml')->toHtml(); ?>

This uses the standard Google Checkout button that’s used everywhere else, so if you customize the way the GCO button looks using the googlecheckout/link.phtml file your changes will show up everywhere you use it.  This is great because it reduces the duplication of code.  But what if you want to use a slightly modified GCO button somewhere?

Step 2

There is no step 2.

Bonus Points

If you want to use a modified version of the standard googlecheckout/link.phtml file it really is as simple as copying app/design/frontend/base/default/template/googlecheckout/link.phtml to app/design/frontend/[your_interface]/[your_theme]/template/googlecheckout/[my_custom_link].phtml

Then, use the same block of code as above but reference your custom link template:

getLayout()->createBlock('googlecheckout/link')->setTemplate('googlecheckout/[my_custom_link].phtml')->toHtml(); ?>

It should go without saying, change [your_interface], [your_theme], and [my_custom_link] to the appropriate values for your site.In the end, I spent less time finding my own answer than I spent searching forum threads and blog posts.  This is the opposite of what I normally experience when looking for Magento help online.  Go figure.

9 thoughts on “How to add a Google Checkout button to any page in Magento

  1. what is the name and path of the file that needs this added inorder to show up in the "payment information" section of the onepage checkout? I had no luck adding it to onepage.phtml


    1. Ben,

      The overall files for this page are located in app/design/frontend///template/checkout/onepage/

      Magento templates can be confusing, specific components of the onepage checkout may be located elsewhere depending on what component it is. To make it even more confusing, if a specific template file isn’t defined for a theme it will fallback to the default/base template. So if you’re not seeing the file in app/design/frontend/default/modern/template/* try app/design/frontend/base/default/template/*

      Google Checkout template files are located app/design/frontend/base/default/template/googlecheckout for example, and Authorize.Net in app/design/frontend/base/default/template/authorizenet even though they get shown on the one-page checkout.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s