Post by 3PO2017 » Sat Mar 17, 2018 9:12 pm

Hi,
I try with below code and i was able to show customer email on order success page but was displaying on random place.

in success.php
if (isset($this->ses
sion->data['guest'])) {
$data['customer_email'] = $this->session->data['guest']['email']; // Guest user's email
} elseif($this->customer->isLogged()) {
$data['customer_email'] = $this->customer->getEmail(); // Customer's email
}


in success.twig

{% if (customer_email is defined) %}
<input name="email" type="hidden" value="{{ customer_email }}">
{% endif %}

i using a custom checkout success message text to cannot it at desired place.

any can help me about how to use sprintf function to display it at desired place.

New member

Posts

Joined
Fri Feb 24, 2017 10:27 pm

Post by straightlight » Sat Mar 17, 2018 9:58 pm

No OC version posted. Although, you do not need to use sprintf to display the email address since you are already using the $data['customer_email'] and the {{ customer_email }} variable.

However, if you'd add a text definition into the success language file, it would be for example:

Code: Select all

$data['text_email_success'] = sprintf($this->language->get('text_email_success'), html_entity_decode($data['customer_email'], ENT_QUOTES, 'UTF-8'));
Then, in your success.twig file: {{ text_email_success }}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Post by 3PO2017 » Sun Mar 18, 2018 1:10 pm

Hi,
Thank you for reply.
OC version is 3.0.2 , using {{cusomer_email}} in twig file its working but i cannot but it in customer location as i created a custom success page.

New member

Posts

Joined
Fri Feb 24, 2017 10:27 pm

Post by 3PO2017 » Sun Mar 18, 2018 1:34 pm

i want to use %s so i can place it anywhere on success page using language file.

I tried with sprintf code provide by you it shows white page.

New member

Posts

Joined
Fri Feb 24, 2017 10:27 pm

Post by straightlight » Sun Mar 18, 2018 10:57 pm

Look in the error logs regarding the white page. Your displayed error logs are not currently enabled on your server. You can also enforce the display errors from Opencart by following this topic: viewtopic.php?f=190&t=201899&p=713113#p713113

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Users browsing this forum: Bing [Bot], niagato and 428 guests