Post by arosesiej » Wed Sep 23, 2015 11:07 pm

What kind of information can I pull from $this->session->data?

I know that data is an array, but what sub-arrays lie within data? Can't find any real documentation on this?

Also, what would be the variables that contain a customer's(logged in or not) country, region, post code if they entered it into the "Estimate Shipping" on Cart page? I notice that it gets carried over to the Checkout page.

How can I access these?

New member

Posts

Joined
Thu Jun 25, 2015 8:52 pm

Post by Johnathan » Thu Sep 24, 2015 12:46 am

The format and structure of $this->session->data changes from version to version, so the easiest way is just to print it out so you can see it. I usually do something like this in the /catalog/controller/common/header.php file:

Code: Select all

echo '<!--'; print_r($this->session->data); echo '-->'; 
That will hide it from the rendered HTML, but still show it in the source, so you can see what the session variables are on a given page.

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by arosesiej » Thu Sep 24, 2015 1:09 am

Okay, thank you.

Now, what array is the customer's postal code, region, and country stored in? Is that something that gets cleared or is it saved for the session?

New member

Posts

Joined
Thu Jun 25, 2015 8:52 pm

Post by Johnathan » Thu Sep 24, 2015 11:25 pm

It's different depending on your version, so the best way to tell is just to add that code and then look for the data in there. I believe in the latest versions it's usually something like:

Code: Select all

$this->session->data['shipping_country_id']
$this->session->data['shipping_zone_id']
$this->session->data['shipping_postcode']

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by straightlight » Sun Oct 04, 2015 9:55 pm

Take note that the payment_ versus shipping_ also implies into the session data in order to capture the country, zone and postcode.

Tired of paying for service fees to export your database from other databases over Opencart?

Try those extensions for FREE: http://www.opencart.com/index.php?route ... aightlight

Regards,
Straightlight


Expert Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by power7714 » Wed Feb 15, 2017 2:09 pm

Does printing the session variables like this still work with version 2.3?

Newbie

Posts

Joined
Thu Feb 02, 2017 12:09 pm

Post by Johnathan » Thu Feb 16, 2017 12:20 am

It works in all versions. The session data variable has been consistent since OpenCart 1.4, at the very least:

$this->session->data

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 21 guests