Page 1 of 1

Getting guest customer's data from session variable: no data is returned!!

Posted: Thu Nov 16, 2017 9:22 pm
by mfadel
Hello everyone,
I am trying to inculde guest customer's data in Terms and condition page make it as a contract in Check out page,
my controller
contract.php

Code: Select all

		if (isset($this->session->data['guest']['firstname'])) {
				$data['firstname'] = $this->session->data['payment_address']['firstname'];
			} else {
				$data['firstname'] = '';
			}
                 }
my view: contract.twig

Code: Select all

            <strong> {{ firstname }}  </strong><br>
but it doesn't show anything? What did I miss?

Re: Getting guest customer's data from session variable: no data is returned!!

Posted: Thu Nov 16, 2017 10:05 pm
by straightlight
Your posted enquiry and codes above are incomplete. It does not indicate with OC version you're using nor at which moment during checkout you are wanting to implement your contract controller file. However, the way you describe the problem above is that you should rather use a return statement with your controller in order for a core checkout controller to obtain that first name by using something like:

Code: Select all

$data['contract_firstname'] = $this->load->controller('checkout/contract');
Then, somewhere in the checkout TWIG file where, again, the enquiry above does not mention where during checkout you'd like to implement your contract, you could use:

Code: Select all

{% if contract_firstname %}
{{ contract_firstname }}
{% endif %}