We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12089
    • 27 Posts
    I’m trying to integrate into Modx the jquery shopping cart jCart and can’t seem to get the sessions working correctly. The cart work and you can add products to it but as soon as you leave the page and come back to it all the items in the cart are gone. As soon as you add one more item they all come back.
    Demo page
    http://f3.hexagone.ca/produits.html?recherche=&business_dept=Footwear&sub_dept=&gender=

    I’ve created a snippet with the following code. I’ve commented out the Session_start since it is already started by Modx.
    <?php
    // INCLUDE JCART BEFORE SESSION START
    include 'assets/snippets/jcart/jcart.php';
    
    // START SESSION
    //session_start();
    
    // INITIALIZE JCART AFTER SESSION START
    $cart =& $_SESSION['jcart']; if(!is_object($cart)) $cart = new jcart();
    
    $cart->display_cart($jcart);
    
    ?>
    


    I’ve tried moving the include to be run before any HTML output at the top of the template file but get a parse error instead.

    « MODx Parse Error »

    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: extract() [function.extract]: First argument should be an array
    Error type/ Nr.: Warning - 2
    File: /home/hexagone/public_html/f3/assets/snippets/jcart/jcart.php
    Line: 244
    Line 244 source: extract($jcart);

    Parser timing
    MySQL: 0.1998 s (38 Requests)
    PHP: 0.2750 s
    Total: 0.4748 s

    Thanks for any help you can provide.
      Hexagone3internet -  marketing - advertisinghexacontact.comEmail marketing service
      • 22303 MODX Staff
      • 10,725 Posts
      As the error describes, on line 244 of your include of assets/snippets/jcart/jcart.php you have an extract() call that expects an array, but it is not getting what it expects in the $jcart variable (i.e. it’s not an array).
        • 18913
        • 654 Posts
        Does this help?
        http://conceptlogic.com/jcart/help/viewtopic.php?f=7&t=6

        If so and you get this working in MODx, I’d be interested in seeing the steps you used to get it to work. It’s been on a "to-do" list ...
        MattC
          • 12089
          • 27 Posts
          Quote from: OpenGeek at Mar 26, 2010, 08:19 AM

          As the error describes, on line 244 of your include of assets/snippets/jcart/jcart.php you have an extract() call that expects an array, but it is not getting what it expects in the $jcart variable (i.e. it’s not an array).

          Hi OpenGeek, from what I could track down the $jcart variable isn’t set properly because the session isn’t properly set-up. The jcart class should be initiated before the session_start() but when I put my include file to execute before any other code (I put it at the top of the index.php file to test it out) I get the the parse error.
            Hexagone3internet -  marketing - advertisinghexacontact.comEmail marketing service
            • 12089
            • 27 Posts
            Quote from: mconsidine at Mar 26, 2010, 09:31 AM

            Does this help?
            http://conceptlogic.com/jcart/help/viewtopic.php?f=7&t=6

            If so and you get this working in MODx, I’d be interested in seeing the steps you used to get it to work. It’s been on a "to-do" list ...
            MattC

            Yes I had seen that and the register_global is set to off in my php.ini so that wasn’t the cause of my problem.
              Hexagone3internet -  marketing - advertisinghexacontact.comEmail marketing service
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: hexagone at Mar 26, 2010, 06:46 PM

              The jcart class should be initiated before the session_start() but when I put my include file to execute before any other code (I put it at the top of the index.php file to test it out) I get the the parse error.
              Yeah, that’s not possible; MODx starts the session before any Snippets or Plugins are ever executed.