Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    help question Google Checkout Session Challenge (brainstorming needed)

    Google Checkout now works very nicely on my website (still the test site and GCO's sandbox).

    One troubling issue, however, is the fact that a customer that made a purchase using GCO without logging into my website, cannot return for a 2nd or 3rd download after an hour or so. Instead, she receives "Session Expired". This is despite the browser not been closed and valid and despite Cart Expiration Time (Minutes) set to NONE in the GCO admin page.

    Being able to download a purchased product several times over a week is a feature that I offer to my customers, in case something went wrong with the first download (or the customer simply misplaced the downloaded file).

    I contacted the Google Checkout API Support and they realized pretty quickly that this is not a bug but rather a result of two conflicting requirements:
    1. Checkout without having to log in.
    2. Preserve sessions to some extent (at least until the download link expires).


    The solution that was proposed by Google Checkout API Support was to place the GCO button after the login pages (yes, this was allowed by them since I only sell digital content).

    The challenge now is: How to implement this?

    I noticed that the GCO module is smart enough to enable/disable the GCO button depending on some conditions. Can I just add another condition that checks whether a customer is logged in?

    Any ideas how to accomplish that?

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Google Checkout Session Challenge (brainstorming needed)

    I'd agree with the analysis that this isn't a bug. If a customer doesn't create an account and login, then allowing them to come back to where they were is a tad difficult.

    I believe that it is not Zen cart, but your PHP configuration that determines the length of your session and therefore how long data hangs around for. Zen Cart uses cookies where possible, but these are set to expire with the session, which makes sense for security reasons.

    You could extend the session length in your php configuration (depending upon how much access your web host gives you to it), though this would also increase the risk to those of your customers who use public or shared computers.

    You can test for whether a customer is logged in by using a condition such as
    PHP Code:
    if (isset($_SESSION['customer_id']) && $_SESSION['customer_id'] != '') {
      
    your code in here

    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Google Checkout Session Challenge (brainstorming needed)

    kuroi, you are amazing. In one pithy reply you answered several questions that I had. Thank you!

    Indeed, since the GCO module is a little more than a few lines of code, I would be leery to introduce extensive modifications modifications to it. Therefore, disabling the GCO button if the user is not logged in seems the safest workaround.

    Quote Originally Posted by kuroi View Post
    You can test for whether a customer is logged in by using a condition such as
    PHP Code:
    if (isset($_SESSION['customer_id']) && $_SESSION['customer_id'] != '') {
      
    your code in here

    This is exactly the tip that I needed for testing whether a customer is logged in.

    Now, I need to find out how to disable the GCO button. My initial search found two relevant spots:

    Quote Originally Posted by googlecheckout/gcheckout.php, line 229
    PHP Code:
      if(in_array($products[$i]['category'], $resticted_categories)) {
        
    $Gcart->SetButtonVariant(false);
        
    $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_RESTRICTED_CATEGORY;
        break;
      } 
    Quote Originally Posted by googlecheckout/library/googlecart.php, line 937
    PHP Code:
        function SetButtonVariant($variant) {
          switch (
    $variant) {
            case 
    false:
                
    $this->variant "disabled";
                break;
            case 
    true:
            default:
                
    $this->variant "text";
                break;
          }
        } 
    I will continue to explore this and, once tested and working properly, I will post the solution here for the benefit of all.

    In the meanwhile, additional insights, comments or ideas are welcome of course.

  4. #4
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Default Re: Google Checkout Session Challenge (brainstorming needed)

    Quote Originally Posted by kuroi View Post
    You can test for whether a customer is logged in by using a condition such as
    PHP Code:
    if (isset($_SESSION['customer_id']) && $_SESSION['customer_id'] != '') {
      
    your code in here

    I finally got to looking again into this problem (sorry, GCO is not the highest priority on my list) and I discovered that before a customer logs in, 'customer_id' is not even defined...

    Which mean the above condition cannot be properly evaluated and needs to be modified to something like this:

    PHP Code:
    if (isset($customer_id) && $customer_id != ''  && isset($_SESSION['customer_id']) && $_SESSION['customer_id'] != '') {
      
    your code in here

    I will report back when I have more information.

  5. #5
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Google Checkout Session Challenge (brainstorming needed)

    Quote Originally Posted by zcnb View Post
    I finally got to looking again into this problem (sorry, GCO is not the highest priority on my list) and I discovered that before a customer logs in, 'customer_id' is not even defined...

    Which mean the above condition cannot be properly evaluated
    It can and is evaluated properly throughout Zen Cart. The point of the isset component of the condition is to test whether the customer_id entry has been defined in the session array. If it hasn't, the customer's not logged in. If it is, then they almost certainly are, but I recommend the extra check in case the array component has been emptied but not properly reset (shouldn't happen but best to be safe).
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  6. #6
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Google Checkout Session Challenge (brainstorming needed)

    Quote Originally Posted by kuroi View Post
    It can and is evaluated properly throughout Zen Cart. The point of the isset component of the condition is to test whether the customer_id entry has been defined in the session array. If it hasn't, the customer's not logged in. If it is, then they almost certainly are, but I recommend the extra check in case the array component has been emptied but not properly reset (shouldn't happen but best to be safe).
    Thanks for correcting me, Kuroi - you are right in that it is evaluated properly without having to add the conditions for $customer_id that I added.

    Now it's my turn to correct your original posting . Instead of:
    PHP Code:
    if (isset($_SESSION['customer_id']) && $_SESSION['customer_id'] != '') {
      
    your code in here

    It should be:
    PHP Code:
    if (!isset($_SESSION['customer_id']) || $_SESSION['customer_id'] == '') {
      
    your code in here

    Do you notice the slight difference and why it didn't work for me in the first place?

    It works now.

  7. #7
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Google Checkout Session Challenge (brainstorming needed)

    So now that this modification is tested working, here is a description of what needs be done.

    But first please note this disclaimer: this change may violate Google Checkout policies, so before implementing this in your store you must receive explicit permission in writing from Google to incorporate this.

    OK - here goes:

    1. Add line 28 in includes\languages\english\modules\payment\googlecheckout.php:
    PHP Code:
    define('GOOGLECHECKOUT_STRING_WARN_CUSTOMER_NOT_LOGGED_IN''To enable the Google Checkout button please log in'); 
    2. Add line 91 in includes\languages\english\modules\payment\gcheckout.php:
    PHP Code:
    if (!isset($_SESSION['customer_id']) || $_SESSION['customer_id'] == '') {
      
    $Gcart->SetButtonVariant(false);
      
    $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_CUSTOMER_NOT_LOGGED_IN 

    The main remaining problem right now is the text underneath the grayed out button ("disabled") that says "Not available for these items" when in fact the reason for being disabled is that the customer has not logged in yet.

    Also, I find it very confusing for the customer to see two competing buttons below the shopping cart:
    1. "Go to Checkout"
    2. "Or login to use Google Checkout"

    These are two incompatible checkout schemes which will very likely to confuse customers.

    Thus, it will take me a while before introducing GCO to my operational site...

  8. #8
    Join Date
    May 2009
    Posts
    16
    Plugin Contributions
    0

    Default Re: Google Checkout Session Challenge (brainstorming needed)

    There is a post someplace around page 70 or so of this thread to instructs you how to hide the zen cart checkout button. The example is there, but I can not figure out which lines to comment out and to keep the PHP file running. I have attempted several combinations.

    The last thing I did was change the actual graphic to a blank file. If a customer gets luck enough to click on exactly the correct spot on the screen, then they will end up in the zen checkout mode, but 99% will never get that far.

    This simple end around solution worked for me.

    The folks at zen and the folks at google need to get together and clean up several issues with this plugin.

    The other major is, as you have mentioned, the ability to purchase a product through the store without forcing a customer to register and log in.

    Dave Bruner

  9. #9
    Join Date
    May 2009
    Posts
    16
    Plugin Contributions
    0

    Default Re: Google Checkout Session Challenge (brainstorming needed)

    Quote Originally Posted by zcnb View Post

    1. Add line 28 in includes\languages\english\modules\payment\googlecheckout.php:
    PHP Code:
    define('GOOGLECHECKOUT_STRING_WARN_CUSTOMER_NOT_LOGGED_IN''To enable the Google Checkout button please log in'); 
    2. Add line 91 in includes\languages\english\modules\payment\gcheckout.php:
    PHP Code:
    if (!isset($_SESSION['customer_id']) || $_SESSION['customer_id'] == '') {
      
    $Gcart->SetButtonVariant(false);
      
    $Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_CUSTOMER_NOT_LOGGED_IN 

    What file are you modifing in the second instance above? There is no file named "Gcheckout.php" . Are you adding a line 91 to the googlecheckout file as in the first change, or is this a different file and you got the directory and filename incorrect?
    Last edited by DaveCB; 14 Jun 2009 at 04:09 PM. Reason: spelling

  10. #10
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Google Checkout Session Challenge (brainstorming needed)

    Quote Originally Posted by DaveCB View Post
    What file are you modifing in the second instance above? There is no file named "Gcheckout.php" . Are you adding a line 91 to the googlecheckout file as in the first change, or is this a different file and you got the directory and filename incorrect?
    Sorry. I had a typo in the directory name. The filename gcheckout.php is correct. However it is in the directory /googlecheckout and not as written above.

 

 

Similar Threads

  1. Replies: 4
    Last Post: 19 Nov 2009, 04:59 AM
  2. Google Checkout returning Whoops! Your session has expired.
    By g3steve in forum Addon Payment Modules
    Replies: 4
    Last Post: 14 Jul 2009, 06:36 PM
  3. Replies: 1
    Last Post: 31 May 2009, 02:06 AM
  4. Free SSL is all that's needed for Google Checkout, and Paypal
    By birdoasis in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 28 Mar 2007, 11:16 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