Right... Looking at the issue of retrieving the shipping cost information, I've realised I spoke waaaaay too soon.
The problem is that the feeds are country specific but the shipping system in Google Checkout can drill down to states/provinces and even specific zip codes which creates a massive problem if all I want is a single quote (the cheapest presumably) for just the one country.
So, we have a number of problems...
The shipping quote system relies on you have a FULL shipping address as part of the getAvailableShippingMethods() function to get an array of methods and quotes. In fact it seems to rely very heavily on whether or not you have an order with address, etc... Hmm... The word "nightmare" springs to mind.
It should be possible to modify the function to use a $shippingZoneId if provided to the function (and not get a new address) but it will mean that anyone using the feed will need to have a country specific shipping zone and method setup for each of their target feed countries. Somehow I can't think this would be a massive problem but it won't be fun.
However, the function relies on being passed the items for which the quote is being generated... The information comes from this line:
Code: Select all
list($shippingQuoteItems, $fixedShippingCost) = $this->getShippingQuoteItems();
Looking at it further I think this might be the way forward...
- Custom function looks for a Shipping Zone that is a country based zone for the feeds target country and grabs that as $shippingZoneId
- We call getAvailableShippingMethods(true, true, array($productData, $shippingZoneId)
- This is modified to:
- Send $productData to getShippingQuoteItems() so it in turn will use this instead of getItems()
- Use the $shippingZoneId and not attempt to identify it from an address (which we don't have)
The above is VERY rough and I'd need to play to see if I could actually generate a quote instance without needing address information, otherwise I'm going to have to pass arrays rather than use the existing object calls, etc... Somehow I doubt it, but we'll see...
Right once we've done ALL that, we have all the quotes handily returned to us by getAvailableShippingMethods() as an array in order of cost so we should then be able to grab the first array field price as:
$shippingQuotes[0]['price']
Quite a lot to get my head around... See, told you it was a bad idea to say that it was all going to be "easy"... Stooopid!!
