Marktplatz - Eine große Auswahl an neuen und hilfreichen Modulen sowie modernen Templates für die modified eCommerce Shopsoftware
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Problems with $_SESSION['cart'] in custom files

    scremades

    • Neu im Forum
    • Beiträge: 7
    Problems with $_SESSION['cart'] in custom files
    am: 07. November 2018, 17:40:21
    Hello,

    I´m working with ajax to update quantity and price without reload the page in shopping cart.
    I created a file inside /extra/modules/ajax/cartFunctions.php and I'm calling this file throught $.get function in a js file that I created.

    The problem is that $_SESSION['cart'] is empty inside cartFunctions.php. I've included application_top inside this one but I can't recove the session. I only have this problem in this file.

    Any idea?

    Thanks in advance

    Linkback: https://www.modified-shop.org/forum/index.php?topic=39680.0

    p3e

    • Experte
    • Beiträge: 2.396
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #1 am: 08. November 2018, 07:18:12
    It would be easier to find the error by seeing what you have done so far. Can you zip your new files and changes and post them here?

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #2 am: 08. November 2018, 09:51:44
    Thanks for your answer.
    I explain the files... I have inside templates folder the order_details.html, this one has a button with an id and this id has an action inside a file named ourFunctions.js. This file call to the ajax.php file and inside call to the cartFunctions inside includes/extra/ajax.

    Inside this file I need to recover the $_SESSION['cart] to modify the products quantity but this one is empty.

    Thanks so much

    p3e

    • Experte
    • Beiträge: 2.396
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #3 am: 08. November 2018, 17:41:16
    I haven't tested it but why do you use
    Code: PHP  [Auswählen]
    require_once (DIR_WS_INCLUDES.'application_top.php');
    in the file \includes\extra\ajax\cartFunctions.php? The application_top.php was already started in ajax.php?
    Is there any error reporting? Have you checked the logs?

    hpzeller

    • Experte
    • Beiträge: 4.130
    • Geschlecht:
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #4 am: 08. November 2018, 21:33:43
    Der response type ist nicht definiert in templates/mate-tee/assets/js/ourFunctions.js Standard ist json.

    Code: Javascript  [Auswählen]
            $.get('http://localhost:8888/mate-tee/ajax.php', { ext: 'cartFunctions', productsID: productID, quantity: add, speed: 1 }, function (data) {
                console.log(data);
            })
     

    teste mal diesen Code

    Code: Javascript  [Auswählen]
            $.get('http://localhost:8888/mate-tee/ajax.php', { ext: 'cartFunctions', productsID: productID, quantity: add, speed: 1, type: 'html' }, function (data) {
                console.log(data);
            })
     

    oder diesen Code.

    Code: Javascript  [Auswählen]
            $.get('ajax.php', { ext: 'cartFunctions', productsID: productID, quantity: add, speed: 1, type: 'html' }, function (data) {
                console.log(data);
            })
     

    Gruss
    Hasnpeter

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #5 am: 09. November 2018, 08:48:24
    I haven't tested it but why do you use
    Code: PHP  [Auswählen]
    require_once (DIR_WS_INCLUDES.'application_top.php');
    in the file \includes\extra\ajax\cartFunctions.php? The application_top.php was already started in ajax.php?
    Is there any error reporting? Have you checked the logs?

    Because I want to use the shop functions to add cart and if I don't include application_top the page is blank, it´s like the application_top is missed.

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #6 am: 09. November 2018, 08:53:43
    Thanks hpzeller by your answer but my problem is that $_SESSION['cart'] is empty when I call this one from cartFunctions, if I make a print inside shopping cart works fine but if I press + button to add a quantity and this button calls to the other function this session is empty.

    p3e

    • Experte
    • Beiträge: 2.396
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #7 am: 09. November 2018, 09:23:04
    The application_top.php is included in ajax.php already. This should work.

    You need the error reporting to find the reason for the blank side. Switch on the error message in the backend so that it is displayed:
    Admin -> Adv. Configuration -> Logging Options -> Error reporting -> all

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #8 am: 09. November 2018, 09:25:02
    I found the mistake, I was passing the param speed and this one in ajax makes the include to configure.php not application_top but I'm still having the same problem, the cart session is empty when this one enter to the cartFunctions.php

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #9 am: 09. November 2018, 09:44:34
    Well... the problem in this case is Chrome... I've tested the shopping cart in Firefox and works fine, maybe Chrome and local server doesn't works fine.

    Thanks for all

    p3e

    • Experte
    • Beiträge: 2.396
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #10 am: 09. November 2018, 09:46:20
    Clear the cache in Chrome and test again.

    hpzeller

    • Experte
    • Beiträge: 4.130
    • Geschlecht:
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #11 am: 09. November 2018, 10:27:27
    Well... the problem in this case is Chrome... I've tested the shopping cart in Firefox and works fine, maybe Chrome and local server doesn't works fine.

    Möglicherweise erklärt das hier -> https://bugs.chromium.org/p/chromium/issues/detail?id=56211 dein Problem.

    Gruss
    Hanspeter

    scremades

    • Neu im Forum
    • Beiträge: 7
    Re: Problems with $_SESSION['cart'] in custom files
    Antwort #12 am: 09. November 2018, 11:11:00
    I've uploaded the website to a test server and works fine :)
    2 Antworten
    2514 Aufrufe
    17. Februar 2010, 17:28:29 von jpfeifer
    4 Antworten
    2297 Aufrufe
    28. Februar 2013, 12:34:57 von p3e
    11 Antworten
    2765 Aufrufe
    07. Mai 2020, 08:57:33 von JWi