Post by JNeuhoff » Wed Feb 17, 2010 4:08 am

If you send me a PM with your FTP and Opencart login details I can take a look at it.
Have you also signed up for a sandbox seller account, too, so that I can do some trials to narrow down the error?

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by will » Wed Feb 17, 2010 9:00 pm

Hi there,

I was hoping to use this for a UK site, but have also found some issues with shipping calculations, similar to those that have been described already (shipping is always GBP 0.00 when it should have a value!)

I am using "Merchant Calculated Shipping" set to Yes.
My testing was against the 'sandbox' Google Checkout, not the live service.

I have had a quick look at the code, specifically the callback method in:
catalog/controller/checkout/gcheckout.php (line 410 onwards):

Code: Select all

410: 				foreach($addresses as $curr_address) {
411:					$curr_id = $curr_address['id'];
412:					$country = $curr_address['country-code']['VALUE'];
413:					$city = $curr_address['city']['VALUE'];
414:					$region = $curr_address['region']['VALUE'];
415:					$postal_code = $curr_address['postal-code']['VALUE'];
416:					$address = $this->recreateAddress( $country, $city, $region, $postal_code );
417:					if (!isset($address['country_id'])) {
418:						continue;
419:					}
420:					if (!isset($address['zone_id'])) {
421:						continue;
422:					}
My testing always bails at line 420 / 421, because 'zone_id' is not set.

Hence, the address is skipped and no shipping value is returned to Google.

As I say, I've just had a quick look, but it appears that the code is looking up OpenCart's zone_id based on the address passed back by Google (using the findZoneByCountryIdAndRegionName function). I'm a bit concerned here, because - unless I'm missing something - the 'region' passed back from Google must exactly match a zone in OpenCart's zone_id table...

In real life, for the UK at least, this is unlikely to happen. Unlike OpenCart, Google allows free-type for the region - so "Hertfordshire" or "Herts" are possibilities for the 'region' passed to the callback.

I admit I haven't looked at Google's APIs yet, so perhaps they are standardising user addresses?

Anyway, because the site I'm working on is UK-based, and ships to all regions of the UK at the same rate, I think I can hack this by manually setting the zone_id (horrible, dirty hack!) - perhaps it might help others narrow down the zero-value shipping problems.

Newbie

Posts

Joined
Wed Feb 17, 2010 7:18 pm

Post by JNeuhoff » Wed Feb 17, 2010 10:04 pm

As I say, I've just had a quick look, but it appears that the code is looking up OpenCart's zone_id based on the address passed back by Google (using the findZoneByCountryIdAndRegionName function). I'm a bit concerned here, because - unless I'm missing something - the 'region' passed back from Google must exactly match a zone in OpenCart's zone_id table...
Good point. Maybe the findZoneByCountryIdAndRegionName function can be modified to use the SQL LIKE operator for substring matches. The Google Checkout account signup uses indeed a free text field for entering the county name, if the selected country is United Kingdom, unlike for the United States where a selectable dropdown list is presented with the states names.

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by will » Thu Feb 18, 2010 12:18 am

That would help, but I don't think it is robust enough for production - there are still opportunities for failing to match up a zone_id - for example, misspelt county/region names, or the user not including a region in their shipping address - I don't think it is mandatory for the UK version of Google Checkout.

The only robust solution I can see would require a zone_id lookup based on the postcode, which is easier said than done...

I wonder if, as an intermediate (easier!) solution, an admin setting for "Default Shipping Geo Zone" (not sure that's quite the right name) could be used, so that when zone_id lookup fails, a default can be assigned? (I.e. looking up the first zone_id that falls into the specified Geo Zone)

I presume (sorry, haven't had a chance to look) that there is some way of returning an error back to Google when a country / zone lookup fails, otherwise some lucky customers get free shipping!!

Of course if you can use Google Checkout to do the calculations, then this isn't an issue - and I would like to say "thank you" for the code. The Checkout protocol makes it quite difficult to make this module work in every different usage scenario!

Newbie

Posts

Joined
Wed Feb 17, 2010 7:18 pm

Post by JNeuhoff » Thu Feb 18, 2010 6:20 am

The only robust solution I can see would require a zone_id lookup based on the postcode, which is easier said than done...
You are right. However, I can't find any free table converting UK postcodes to UK counties. The Royal Mail has one, but charges a lot of money for it, it is not free.

I could enforce the rule in the Google Checkout module for the shipping methods geo-zones, that is, if the latter includes the UK, than all UK counties are to be included, or else the checkout icon will be grayed out, that is, no fast checkout possible via Google Checkout.

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JNeuhoff » Sat Feb 20, 2010 2:58 am

I have now fixed the issue with the shipping method's geo zones: If a Geo Zone is UK-based, it must always include all UK counties. Reason: Google does not require the specification of a county during its account signup, unlike OpenCart.

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Qphoria » Sun May 02, 2010 7:24 am

JNeuhoff wrote: To Qphoria: It seems your shipping By Product may not use the common Opencart standards for returning the shipping quote. I assume it returns a single quote, hence your shipping module should end something like this in the getQuote($country_id, $zone_id, $postcode = '') function
I just read this now for the first time.

It does use the normal quote return method as it would have to for it to work on the shipping page. But it does require the cart products. It does a foreach on this->cart->getProducts() to get the shipping rate from each item in the cart and totals it all together to return the single quote. So it is dynamically calculated rate at the time when getQuote is called. I assume Gcheckout only supports pulled defined rates from the database because it has that data available.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Mon May 03, 2010 7:24 pm

It does use the normal quote return method as it would have to for it to work on the shipping page. But it does require the cart products. It does a foreach on this->cart->getProducts() to get the shipping rate from each item in the cart and totals it all together to return the single quote. So it is dynamically calculated rate at the time when getQuote is called. I assume Gcheckout only supports pulled defined rates from the database because it has that data available.
The Google Checkout does restore the shopping cart during a merchant calculation callback from Google, however it expects your shipping method to end like this in the getQuote method (where xxxx is the name of your shipping method):

Code: Select all

			$quote_data['xxxx'] = array(
				'id'           => 'xxxx.xxxx',
				'title'        => $this->language->get('text_description'),
				'cost'         => $this->config->get('xxxx_cost') * $this->cart->countProducts(),
				'tax_class_id' => $this->config->get('xxxx_tax_class_id'),
				'text'         => $this->currency->format($this->tax->calculate($cost, $this->config->get('xxxx_tax_class_id'), $this->config->get('config_tax')))
			);

			$method_data = array(
				'id'         => 'xxxx',
				'title'      => $this->language->get('text_title'),
				'quote'      => $quote_data,
				'sort_order' => $this->config->get('xxxx_sort_order'),
				'error'      => FALSE
			);
		}
		return $method_data;

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by misticjeff » Tue Aug 31, 2010 3:38 pm

I've just done a test install of 1.4.9 and tried the latest GC module for 1.4.8.8. Everything works except:


Issue #1
If I set "Merchant Calculated Shipping" to "No" and then click on "save" I get the following error:
Notice: Undefined index: gcheckout_merchant_calculation_url in /home/xxxxxxx/public_html/admin/controller/module/gcheckout.php on line 196Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/admin/index.php:72) in /home/xxxxxxx/public_html/system/engine/controller.php on line 27
Issue #2
If I set "Merchant Calculated Shipping" to "Yes" and use an "http://" callback URL the module will save. However, If I then add an item to my cart and proceed to GC, I'm presented with all the information except for shipping methods and prices.

I realize this hasn't been written or tested for 1.4.9 and that I'm not using an "https://" URL but am wondering if anyone could point me in the right direction.


Thanks

Jeff

Newbie

Posts

Joined
Tue Aug 31, 2010 3:27 pm

Post by JNeuhoff » Tue Aug 31, 2010 7:54 pm

Hi Jeff,
Issue #1
If I set "Merchant Calculated Shipping" to "No" and then click on "save" I get the following error:
Now fixed, try it again, using the latest version.
Issue #2
If I set "Merchant Calculated Shipping" to "Yes" and use an "http://" callback URL the module will save. However, If I then add an item to my cart and proceed to GC, I'm presented with all the information except for shipping methods and prices.
Usage of a 'http://' protocol for the merchant calculation callback is only possibly for sandbox accounts. You should always use the 'https://' protocol for a production site, hence you need a SSL on your site.

Please note I haven't tested it yet for Opencart 1.4.9, so it may or may not work on 1.4.9.

MHC Web Design
Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * TrustPilot Reviews * Google Rich Snippets * Google Tag Manager * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by misticjeff » Tue Aug 31, 2010 10:49 pm

JNeuhoff wrote:Hi Jeff,
Issue #1
If I set "Merchant Calculated Shipping" to "No" and then click on "save" I get the following error:
Now fixed, try it again, using the latest version.
Issue #2
If I set "Merchant Calculated Shipping" to "Yes" and use an "http://" callback URL the module will save. However, If I then add an item to my cart and proceed to GC, I'm presented with all the information except for shipping methods and prices.
Usage of a 'http://' protocol for the merchant calculation callback is only possibly for sandbox accounts. You should always use the 'https://' protocol for a production site, hence you need a SSL on your site.

Please note I haven't tested it yet for Opencart 1.4.9, so it may or may not work on 1.4.9.
Thanks a ton.... that worked like a charm...

As soon as I get the test site migrated over to the production site, i'll test the SSL callback and report back.

Jeff

Newbie

Posts

Joined
Tue Aug 31, 2010 3:27 pm

Post by tvieira24 » Sun Dec 05, 2010 4:23 am

Any plans on allowing this to work with UPS? I use both weight based shipping (0 = Free Shipping) & UPS and only weight based works with GC, UPS just returns 0.00's when using merchant calculated.

I set GC to use its own shipping tables but theres no way to set Weight = 0 to get free shipping in GC. It's one or the other & I need both :(

Newbie

Posts

Joined
Sun Dec 05, 2010 4:04 am

Post by sambamu » Mon Jan 17, 2011 7:55 am

I got this warning message when tried to checkout using google checkout. Using opencart version 1.4.9.3 and installed google checkout version opencart-1-4-9-12-gcheckout.zip

Code: Select all

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found in /home/www/*********/test/catalog/controller/checkout/gcheckout.php on line 319Warning: simplexml_load_string() [function.simplexml-load-string]: Failed to connect to 72.14.213.115: Permission denied in /home/www/**********/test/catalog/controller/checkout/gcheckout.php on line 319Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/www/*********/test/catalog/controller/checkout/gcheckout.php on line 319Notice: Trying to get property of non-object in /home/www/*********/test/catalog/controller/checkout/gcheckout.php on line 320

Newbie

Posts

Joined
Mon Jan 17, 2011 7:49 am
Who is online

Users browsing this forum: No registered users and 5 guests