Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
BBG
GldRush98: Glad to hear you have GCO 1.0.5 working properly! I'm sorry for not responding, I assumed I'd have Internet access over the holidays while I was away, unfortunately that was not the case
dhan99: How I have it set up is most likely different that what you want, I currently have it set up to offer only Priority Mail shipping unless the shopping cart contains all books- then I offer Media Mail and Priority Mail as shipping options. Since I only offer a second shipping method in certain cases, I had to hack and slash my way through a few php files- and left an ugly mess.
I'm going to check out ropu's latest fix and GldRush98's responsehandler on a fresh 1.0.5 yet this extended weekend to get multiple USPS options working w/o my hacks for Media Mail. I'll report back my progress and try my best to take notes. :)
Shawn
Happy New Year, Shawn. I just took a closer look at the responsehandler.php file from GldRush98 and I don't think it would work correctly. It seems to me $total_weight in process_merchant_calculation_callback() would need to be declared global in order for it to be picked up in the shipping function. Also, the $total_weight calculation assumes product_id's can be found in root/shopping-cart/items/item/merchant-item-id entry in the XML from Google, but in all the XML I've seen so far, the merchant-item-id entry simply doesn't exist and the product_id's can be found only in root/shopping-cart/merchant-private-data/product-data. Is it that Google API has changed at some point? Does anybody know? Logically one would think there should be a "merchant-item-id" inside <item>, which corresponds to product_id in ZenCart, but in reality it is simply not there. So I guess we will need to parse the ID's from product-data.
[FONT=monospace][/FONT]
Re: Google Checkout module for Zen Cart (beta)
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:
Code:
global $googlepayment, $order, $db;
to:
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:
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";
}
with:
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
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
BBG
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:
Code:
global $googlepayment, $order, $db;
to:
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:
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";
}
with:
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
Yep, it seems to work correctly for me as well. Thanks very much for the detailed explanation. (And it is simpler to get $total_weight from _SESSION, as it is done in original v1.0.5 Google Checkout code, instead of trying to calculate from google XML.)
Re: Google Checkout module for Zen Cart (beta)
I was hoping international shipping would work, but no. If address in buyer's google checkout account is not US location (I tried a UK address), when reaching the google checkout page there will be an error message saying "XXXX online store does not ship to this address." This is true even if I set to use flat rate only.
So does that mean international buyers cannot really use Google Checkout?
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
dhan99
I was hoping international shipping would work, but no. If address in buyer's google checkout account is not US location (I tried a UK address), when reaching the google checkout page there will be an error message saying "XXXX online store does not ship to this address." This is true even if I set to use flat rate only.
So does that mean international buyers cannot really use Google Checkout?
I just tried some bigger companies that use Google Checkout and found none of them seem to ship to that UK address (I am pretty sure that address itself is valid):
- General Nutrition Centers does not ship to this address.
- Buy.com does not ship to this address.
- PETCO Animal Supplies, Inc. does not ship to this address.
- Toys"R"Us & Babies"R"Us does not ship to this address.
So is this a current Google Checkout limitation, despite their claim that "Google Checkout merchants can ship goods inside and outside the United States."? (see https://checkout.google.com/support/...871&topic=8664)
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
dhan99
I just tried some bigger companies that use Google Checkout and found none of them seem to ship to that UK address (I am pretty sure that address itself is valid):
- General Nutrition Centers does not ship to this address.
- Buy.com does not ship to this address.
- PETCO Animal Supplies, Inc. does not ship to this address.
- Toys"R"Us & Babies"R"Us does not ship to this address.
So is this a current Google Checkout limitation, despite their claim that "Google Checkout merchants can ship goods inside and outside the United States."? (see
https://checkout.google.com/support/...871&topic=8664)
Try a canadian address - I'm sure they ship to Canada at least :P
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
samad64
Try a canadian address - I'm sure they ship to Canada at least :P
Nope. Tried a Canadian address and still got the same thing. I think those shops would gladly ship to Canadian addresses if the buyer choose one of their traditional checkout methods, not the fancy Google checkout. I guess it is a limitation for the time being. See http://code.google.com/apis/checkout...ationalization
Maybe the limitation is such that if there is any shipping related tag in the initial shopping cart posted to google, and if the destination address (from buyer's Google account) is non-US, the buyer will see that "does not ship to this address" error. But what about flat-rate? What's the reason even a flat-rate cannot work for shipping outside US? I hope somebody can show us a work-around, such as flat international rate for all non-US destinations and USPS/Fedex/UPS for domestic ones....but on second thought, that probably won't work either (if my understanding of this limitation is correct): as long as shipping costs depend on ship-to address in any way, we are going to run into the same wall. So, can we reach the conclusion: if you want to ship outside the US, you cannot use Google Checkout?
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
dhan99
Maybe the limitation is such that if there is any shipping related tag in the initial shopping cart posted to google, and if the destination address (from buyer's Google account) is non-US, the buyer will see that "does not ship to this address" error. But what about flat-rate? What's the reason even a flat-rate cannot work for shipping outside US? I hope somebody can show us a work-around, such as flat international rate for all non-US destinations and USPS/Fedex/UPS for domestic ones....but on second thought, that probably won't work either (if my understanding of this limitation is correct): as long as shipping costs depend on ship-to address in any way, we are going to run into the same wall. So, can we reach the conclusion: if you want to ship outside the US, you cannot use Google Checkout?
The workaround for international shipping appears to be to find out BEFORE the customer clicks the Google Checkout where it's being shipped to. If it's a non-US address, add the shipping fee as a shopping cart item and omit the shipping-methods block from the XML sent to Google Checkout.
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
BBG
The workaround for international shipping appears to be to find out BEFORE the customer clicks the Google Checkout where it's being shipped to. If it's a non-US address, add the shipping fee as a shopping cart item and omit the shipping-methods block from the XML sent to Google Checkout.
Yep, we could add a checkbox right underneath the Google Checkout button (if it is enabled), with a label saying "Check this box if you are shipping outside U.S.". And get some javascript in there so that the action of checking that box would trigger what you just said --constructing a new shopping cart with the shipping-methods block taken out and an additional shipping fee item added.
Re: Google Checkout module for Zen Cart (beta)
Quote:
Originally Posted by
dhan99
Yep, we could add a checkbox right underneath the Google Checkout button (if it is enabled), with a label saying "Check this box if you are shipping outside U.S.". And get some javascript in there so that the action of checking that box would trigger what you just said --constructing a new shopping cart with the shipping-methods block taken out and an additional shipping fee item added.
I was thinking of prompting the user when they first add an item to the shopping cart, something like "Please enter your shipping location so we can calculate shipping costs". Although, I'm not sure if that would violate Google's TOS. As a bonus, for US addresses, you could also send Google the calculated shipping values (instead of the fallback guesstimates) if you knew where it was being shipped to- although I've never seen the live callback timeout yet <knock on wood>.