In my last post I showed how to correct the problem that was causing Magento to generate invalid XML for Google Checkout. In this post I will show how to fix another Magento problem with Free Shipping over $X and Google Checkout.
The issue is that even though free shipping shows correctly on the webstore – when Google Checkout makes the merchant calculation callback free shipping is not returned as an option when it should be.
The fix is actually a very simple one-liner. When calculating the available rates for the cart page Magento forms a request like this:
(from app/code/core/Mage/Sales/Model/Quote/Address.php around line 502)
$request->setDestStreet($this->getStreet(-1)); $request->setDestCity($this->getCity()); $request->setDestPostcode($this->getPostcode()); $request->setPackageValue($this->getBaseSubtotal()); $request->setPackageValueWithDiscount($this->getBaseSubtotalWithDiscount()); $request->setPackageWeight($this->getWeight()); $request->setPackageQty($this->getItemQty());
However in the Shipping model (app/code/core/Mage/Shipping/Model/Shipping.php) a request is built without this call:
Which means the free shipping calculation never gets the right value and so never returns true. The fix is to just add that line into app/code/core/Mage/Shipping/Model/Shipping.php around line 157.
This should cause your free shipping to calculate correctly in Magento when Google Checkout makes a merchant calculation request.
With the two fixes I have outlined here, the Google Checkout intergration on my webstore now works perfectly well. I’m very happy with the results. It is much better than using the flat rate Google Checkout shipping option – which is what I had been doing.
On the Magento forums I have read about a lot of the problems people are having with Google Checkout callbacks and the calculations in general. In my next post I will try to create a simple checklist that will help you to troubleshoot google checkout problems.
Edit: This is still an issue in Magento 1.2.1.