Ok, I wrote down the steps I took to get multiple USPS shipping options working for me. I DID NOT try it with other non-USPS shipping modules, so your mileage may vary. I should note, I tried GldRush98's responsehandler.php, but as a direct replacement, it did not work. I also tried roku's fix, but that did not work for me either.
Here's the steps I took:
- Installed fresh ZC 1.3.6
- Installed fresh GCO 1.0.5 (overwriting any existing ZC files)
- Modified includes/modules/payment/googlecheckout.php
- Added Media Mail in array
- Commented out Bound Printed Material and Library
- Note: I moved the ")," at end of Library line to new uncommented line
- ZC Admin->Modules->Shipping->USPS->Install
- Entered in Web Tools User ID
- Changed Shipping methods (only left express, priority, first class, parcel and media selected)
- ZC Admin-> Uninstalled all other shipping modules
- ZC Admin->Modules->Payment->GoogleCheckout->Install
- Entered Merchant ID/Key
- Set fallback prices for shipping methods
- ZC Admin->Configuration->Postal Code
- Set Postal Code
- ZC Admin->Catalog->Categories/Products
- Added new test category and test products
- sandbox.google.com Admin->Settings->Integration
- Set API Callback URL
- **TEST #1**
- Went to new store front-end, added test product (weight was 1lb) to cart
- Clicked Estimate Shipping button:
Express - $25.50
Priority - $5.60
Parcel Post - $5.35
Media Mail - $3.03- Clicked Google Checkout button
- Shipping & Handling dropdown on Google Checkout page contained:
Express - $22.20
First Class - $22.20
Priority - $22.20
Parcel Post - $22.20
Media Mail - $22.20- None of the numbers match and First Class shouldn't be available!
- Modified googlecheckout/responsehandler.php (line 353)
changed:to:Code:global $googlepayment, $order, $db;Code:global $googlepayment, $order, $db, $total_weight;- **TEST #2**
- Shipping & Handling dropdown NOW contains:
Express - $25.50
First Class - $25.50
Priority - $25.50
Parcel Post - $25.50
Media Mail - $25.50- At least one of the numbers match but still not right, and it's still showing First Class as available!
- Modified googlecheckout/responsehandler.php (lines 422-441)
replaced:
with:Code:if(isset($data[$root]['calculate']['shipping'])) { $shipping = get_arr_result($data[$root]['calculate']['shipping']['method']); foreach($shipping as $curr_ship) { $name = $curr_ship['name']; //Compute the price for this shipping method and address id list($a, $method_name) = explode(': ',$name); //print_r($order); $methods_hash[$method_name][0]. $methods_hash[$method_name][2]."\n"; $quotes = $shipping_modules->quote($methods_hash[$method_name][0], $methods_hash[$method_name][2]); //print_r($shipping_modules); $price = $quotes[0]['methods'][0]['cost']; $shippable = "true"; //if there is a problem with the method, i mark it as non-shippable if(!isset($quotes[0]['methods'][0]['cost']) || isset($quotes[0]['error'])) { $shippable = "false"; $price = "0"; }
Code:if(isset($data[$root]['calculate']['shipping'])) { $shipping = get_arr_result($data[$root]['calculate']['shipping']['method']); //Let's just get all the quotes at once $quotes = $shipping_modules->quote(); foreach($shipping as $curr_ship) { $name = $curr_ship['name']; list($a, $method_name) = explode(': ',$name); $quote_id=0; // Not all methods are returned, such as First Class if // weight >13oz, so need to marked as not shippable below while (($quotes[0]['methods'][$quote_id]['id'] != $methods_hash[$method_name][0]) && $quote_id<count($quotes[0]['methods'])) { $quote_id++; } $price = $quotes[0]['methods'][$quote_id]['cost']; $shippable = "true"; if(!isset($quotes[0]['methods'][$quote_id]['cost']) || isset($quotes[0]['error'])) { $shippable = "false"; $price = "0"; }- **TEST #3**
- Shipping & Handling dropdown NOW contains:
Express - $25.50
Priority - $5.60
Parcel Post - $5.35
Media Mail - $3.03- Finally, Google Checkout matches the Zen Cart shipping estimate!
I'm sure there's a more "programmatically correct" way to deal with it, unfortunately my PHP skills are lacking. Again, I have not tested it with other shipping modules enabled so it may not play nicely with others. Also, I didn't get a chance to try it out with tax so I'm not sure if it works with tax. I plan to have a look at that later.
Happy New Year!
Shawn
Bookmarks