Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2005
    Location
    Chicago, IL USA
    Posts
    1,587
    Plugin Contributions
    29

    Default Fatal error: Using $this

    I think this is a result of upgrading the PHP5. The entire error is:

    Fatal error: Using $this when not in object context in /home/customcr/public_html/includes/modules/create_account.php on line 414

    This is the only reference to 'this' I find in that file:

    if (is_array($this->contents)) { // if items in cart, then by pass create account success

    Is there a simple fix to make this work with PHP 5?

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

    Default Re: Fatal error: Using $this

    Which version of Zen Cart are your using? Do you have installed any mods that change the create account module?
    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
    Oct 2005
    Location
    Chicago, IL USA
    Posts
    1,587
    Plugin Contributions
    29

    Default Re: Fatal error: Using $this

    Zen is 1.3.7 and yes, I do have the process modified. The block of code causing the problems, it seems, is:

    //The following bypasses the Create Account Success page if items are in the cart.
    if (is_array($this->contents)) { // if items in cart, then by pass create account success
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); // Redirects the user to the "Shipping Information" part of the checkout (more streamlined).
    } else { // no items in cart to show create account success page
    zen_redirect(zen_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL')); // Original line of code that redirects the user to the "create account success" page. Adds another step to the checkout process, and is not needed for a mroe streamlined approach.
    }
    // *******************************************************************************

    To clarify, we upgraded from PHP 4 to PHP5.

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

    Default Re: Fatal error: Using $this

    The code is nonsense and I doubt that it ever worked as intended. But PHP 4 may have been prepared to say, "no, this nonsense isn't an array" whereas PHP 5 is being more strict about an attempt to refer to a class that hasn't been set up abd throwing its hands up in horror.

    You could try replacing the is_array($this->contents) with isset($_SESSION['cart'])

    I suspect that this would test much what the custom code you have there was supposed to check, but as I don't have it, you would need to test the change carefully at your end.
    Kuroi Web Design and Development | Twitter

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

  5. #5
    Join Date
    Oct 2005
    Location
    Chicago, IL USA
    Posts
    1,587
    Plugin Contributions
    29

    Default Re: Fatal error: Using $this

    Thanks very much, that seems to have done the trick!!

  6. #6
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Fatal error: Using $this

    Note: v1.3.8 already does the create-account-success bypass for you. No need for customizing the code.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: Fatal error: Using $this

    DrByte raises a good point. In 1.3.8 this bypass is handled in a completely different way in a completely different place (i.e. modules/pages/create_account_success/header_php.php. So if you were to upgrade to 1.3.8, I would recommend making sure that the extra bit of code about which you asked is removed completely.
    Kuroi Web Design and Development | Twitter

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

  8. #8
    Join Date
    Oct 2005
    Location
    Chicago, IL USA
    Posts
    1,587
    Plugin Contributions
    29

    Default Re: Fatal error: Using $this

    I looked in a few other Zen cart installs I have, all 1.3.7, and did not find that same bit of code in any of them. They all had:

    zen_redirect(zen_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

    I replaced it all with the code above and it''s working just fine. I'm not really sure where that other code came from.

  9. #9
    Join Date
    Nov 2004
    Location
    West Mids, England
    Posts
    203
    Plugin Contributions
    1

    Default Re: Fatal error: Using $this

    Hi, just had the same problem after upgrading to php5.

    This section of code:

    if (is_array($this->contents)) { // if items in cart, then by pass create account success
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); // Redirects the
    user to the "Shipping Information" part of the checkout (more streamlined).
    } else { // no items in cart to show create account success page
    zen_redirect(zen_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL')); //
    Original line of code that redirects the user to the "create account success" page. Adds another
    step to the checkout process, and is not needed for a more streamlined approach.
    }

    Is from: 20 Surefire Ways to Increase Sales Using Zen Cart. by:
    Eric Leuenberger
    http://www.zencartoptimization.com
    Zen Forum ID: econcepts

    Obviously conflicts with php5.

    It was a way of streamlining the checkout process.

    I shall let him know. Not sure if he has updated the code recently.

    Thanks Kuroi, your alteration worked for me too.

    Craig

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

    Default Re: Fatal error: Using $this

    Thanks Craig, it's useful to know where this snippet originated.
    Kuroi Web Design and Development | Twitter

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

 

 

Similar Threads

  1. Replies: 6
    Last Post: 15 Oct 2013, 08:33 PM
  2. Fatal error: Using $this when not in object context (one-page-checkout)
    By gsdcypher in forum All Other Contributions/Addons
    Replies: 14
    Last Post: 28 Feb 2008, 08:08 AM
  3. Got This Fatal error using links manager
    By weezee in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 1 Sep 2007, 05:52 AM
  4. Fatal error (using PHP 5.2.0)
    By benamin in forum General Questions
    Replies: 8
    Last Post: 3 Dec 2006, 03:22 PM

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