Werbung / Banner buchen
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:

Autor Thema: Problems with $_SESSION['cart'] in custom files  (Gelesen 669 mal)

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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

Offline p3e

  • Experte
  • *****
  • Beiträge: 2.041
    • Teile Beitrag
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?

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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

Offline p3e

  • Experte
  • *****
  • Beiträge: 2.041
    • Teile Beitrag
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?

Offline hpzeller

  • Experte
  • *****
  • Beiträge: 3.012
  • Geschlecht: Männlich
    • Teile Beitrag
    • xos-shop.com | XOS-Shop ist ein umfangreiches "Open Source Webshop-System", welches per Webinterface administriert wird und an die Bedürfnisse des Betreibers angepasst werden kann.
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

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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.

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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.

Offline p3e

  • Experte
  • *****
  • Beiträge: 2.041
    • Teile Beitrag
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

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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

Offline p3e

  • Experte
  • *****
  • Beiträge: 2.041
    • Teile Beitrag
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.

Offline hpzeller

  • Experte
  • *****
  • Beiträge: 3.012
  • Geschlecht: Männlich
    • Teile Beitrag
    • xos-shop.com | XOS-Shop ist ein umfangreiches "Open Source Webshop-System", welches per Webinterface administriert wird und an die Bedürfnisse des Betreibers angepasst werden kann.
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

Offline scremades

  • Neu im Forum
  • *
  • Beiträge: 7
    • Teile Beitrag
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 :)

Safeterms - Sichere Rechtstexte für Online Händler

Teile per facebook Teile per linkedin Teile per twitter