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.
Is there a way to add this to the shipping module under fixed shipping ?
LikeLike
I'm not sure I follow. You mean multiple flat rate shipping methods? I found WebAppShops' MatrixRate Shipping extension the easiest way to do that.
LikeLike