Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Bug with Google Checkout :: FIX included

    Ok, so this is a little hard to explain, as I've only just found this in a live site, and not had chance to reproduce in a test environment, but here goes.....

    When Google re-builds the sessions to calculate shipping costs, it doesn't recreate the session variable correctly, and this leads to incorrect shipping costs being shown in certain circumstances.

    For some reason, the code assigns the $_SESSION['cart'] to an independant variable, $cart, and then uses this to perform all class functions. This is wrong for starters, as all shipping modules use the SESSION variable, rather than a local variable to calculate weights etc. So, firstly, this $cart variable should be changed to use the $_SESSION['cart'] variable instead.

    Secondly, when products are returned from Google to check the shipping costs, they are unserialised, and put into the $order->products array. This is fine for the actual shipping modules and their calculations, however, the function zen_get_shipping_enabled() uses the SESSION['cart']->contents to check if the order is free shipping. As the SESSION variable has been badly re-created, and no products exist, it therefore believes that the order should be shipped for free.

    So, my fix, which needs to be fully tested is as follows:

    in googlecheckout/responsehandler.php

    Line 704 or there abouts, you will find $order->products = $products.

    After this line, paste:
    Code:
      foreach($products as $product) {
        if (!isset($_SESSION['cart']->contents[$product['id']])) {
    	  if (isset($product['attributes'])) {
    	    $attributes = array();
    		foreach($product['attributes'] as $attribute) {
    		  if (strstr('chk_', $attribute['option_id'])) {
    		    $option = explode('chk_', $attribute['option_id']);
    		    $attributes[$attribute['option_id']] = array($attribute['value_id'] => $attribute['value_id']);
    		  }elseif ($attribute['value_id'] == PRODUCTS_OPTIONS_VALUES_TEXT_ID) {
    		    $attributes[TEXT_PREFIX.$attribute['option_id']] = $attribute['value'];
    		  } else {
    		    $attributes[$attribute['option_id']] = $attribute['value_id'];
    		  }
    		}
    	    $_SESSION['cart']->add_cart($product['id'], $product['qty'], $attributes);
    	  } else {
    	    $_SESSION['cart']->add_cart($product['id'], $product['qty']);
    	  }
    	}
      }
      $total_weight = $_SESSION['cart']->show_weight();
      $total_count = $_SESSION['cart']->count_contents();
    You'll see that the next two lines have been replaced with the last two lines above, which use the SESSION variable, rather than the $cart variable.

    Like I said, this fixes a HUGE issue with two of our stores, and I'm not sure that it is the best fix. I think maybe the SESSION['cart'] variable should have the products allocated before the $order variable is defined, and the $order will then auto-populate when the class is initiated, but I haven't tested this as yet.

    If you have any questions, or comments regarding this code, PLEASE, let's keep it in the thread, rather than through PM!

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  2. #2
    Join Date
    Feb 2009
    Posts
    166
    Plugin Contributions
    0

    Default Re: Bug with Google Checkout :: FIX included

    Happy to test it on 1.38a. Could you give some examples of calculation errors that your fix repairs so I can try to reproduce them. Is there a particular shipping method that needs to be chosen in GC, what shipping modules should enabled in ZC, any particular carriers, etc.
    Last edited by slomojojo; 27 Apr 2010 at 07:58 PM. Reason: typo

  3. #3
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Bug with Google Checkout :: FIX included

    When Free Shipping is enabled as a shipping method, any shipping method which uses zen_get_shipping_enabled() appears to be affected.

    I believe that most modules use this function call in determining whether or not the module is enabled.

    We have a cart where some products are marked as free shipping, and some are standard rates, and this is where we found the problem to occur on our site.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  4. #4
    Join Date
    Feb 2009
    Posts
    166
    Plugin Contributions
    0

    Default Re: Bug with Google Checkout :: FIX included

    Here's a sentence I never thought I'd be typing: I couldn't create any shipping errors in GC. I made up some test products with free shipping and tried every combination I could think of, but GC worked flawlessly.

    I'm using USPS and merchant calculated shipping, ZC 1.38a and PHP 5.29.

    Anyway, I applied the fix to my responsehandler.php just to check it and it didn't affect GC in any way; no errors or problems.

    Sorry I couldn't be of more help.

  5. #5
    Join Date
    Jan 2010
    Posts
    7
    Plugin Contributions
    0

    Default Re: Bug with Google Checkout :: FIX included

    Just fyi, I was having a similar issue with Google Checkout trying to get merchant calculated shipping rates and having session issues, and the fix for me turned out to be going back to the version of spiders.txt in use before upgrading to 1.3.9. Something in the new spiders.txt is stopping google from creating a session in this case. Or you can turn on the option to allow spiders to create sessions. Not sure if this is the same problem you're having, but just in case.

 

 

Similar Threads

  1. Google Checkout v1.4.7 - Possible Bug with Shipping
    By stonecoldinc in forum Addon Shipping Modules
    Replies: 1
    Last Post: 16 Oct 2011, 10:25 PM
  2. $1.00 expedited shipping bug? Google Checkout
    By nonfinite in forum Addon Payment Modules
    Replies: 11
    Last Post: 11 Jul 2009, 06:41 PM
  3. [Duplicate] Small what's new bug with fix
    By netweblogic in forum Bug Reports
    Replies: 3
    Last Post: 30 Oct 2008, 07:36 PM
  4. xss fix vs google checkout - how do I do this?
    By fats1964 in forum General Questions
    Replies: 0
    Last Post: 5 Jul 2007, 05:04 PM
  5. emergency help needed... to fix Google Checkout
    By g0d4lm1ty in forum Addon Payment Modules
    Replies: 1
    Last Post: 31 Jan 2007, 03:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR