How to create additional Google Checkout flat rate shipping methods in Magento

Magento gives you 3 slots for adding Flat Rate shipping methods to Google Checkout.  I needed more (7 to be exact).  Here’s how you can add more.

The steps are pretty simple: add the additional flat rates to the database, add them to the GoogleCheckout module’s system.xml and config.xml files, and then update the Mage_GoogleCheckout_Model_Api_Xml_Checkout model so that it loops through all the configs.

Step 1

Add the additional flat rates to the database.  The SQL will look like this:

INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`) VALUES ('default', '0', 'google/checkout_shipping_flatrate/title_4');
INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`) VALUES ('default', '0', 'google/checkout_shipping_flatrate/price_4');
INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`) VALUES ('default', '0', 'google/checkout_shipping_flatrate/sallowspecific_4');
INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`) VALUES ('default', '0', 'google/checkout_shipping_flatrate/specificcountry_4');

Add the table prefix as necessary.

Step 2

Add the additional rows to app/code/core/Mage/GoogleCheckout/etc/config.xml around line 179:

Step 3

Open app/code/core/Mage/GoogleCheckout/etc/system.xml and copy lines ~404-440 and paste them right after. You want to change any lines ending in _3 to _4, “Rate 3” to “Rate 4”, and make sure all the sort orders start with “5” instead of “4” (50, 52, 54, etc). See the image below for example:

Step 4

Last step. The model doesn’t know in advance how many flat rate shipping methods there are, so it loops through a pre-defined number. We have to increase that number. By default there are 3 flat rate shipping methods in the GCO settings, so the code says $i

Modify the _getFlatRateShippingXml() method in Mage_GoogleCheckout_Model_Api_Xml_Checkout so that it loops through the extra configs you added:

The line numbers in the above illustration won’t match app/code/core/Mage/GoogleCheckout/Model/Api/Xml/Checkout.php because I’m using an override for the Mage_GoogleCheckout_Model_Api_Xml_Checkout model. My override is located at app/code/local/[MyName]/GoogleCheckout/Model/Api/Xml/Checkout.php. Check out this post for instructions on creating an override.

All done

You should now see something like this in System > Configuration > Google API > Google Checkout Shipping – Flat Rate:

Rinse and repeat these steps for as many additional flat rate methods as you want to add.

Advertisements

2 thoughts on “How to create additional Google Checkout flat rate shipping methods in Magento

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s