Results 1 to 10 of 10

Hybrid View

  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,445
    Plugin Contributions
    81

    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.

 

 

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