leonardodestefanis 0 Posted May 28, 2017 (edited) Hi there, I need to integrate a CRM with a Live Chat into my Prestashop. I have this code and I need to modify it to retrieve user information. How can I do? I'm using Prestashop 1.7 <script> window.customerlySettings = { app_id: "3611c5b5", user_id: "REPLACE WITH YOUR USER ID",// Optional name: "REPLACE WITH USER NAME", email: "REPLACE WITH USER EMAIL", }; !function(){function e(){var e=t.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://widget.customerly.io/widget/3611c5b5";var r=t.getElementsByTagName("script")[0];r.parentNode.insertBefore(e,r)}var r=window,t=document,n=function(){n.c(arguments)};r.customerly_queue=[],n.c=function(e){r.customerly_queue.push(e)},r.customerly=n,r.attachEvent?r.attachEvent("onload",e):r.addEventListener("load",e,!1)}(); </script> I tried with "$this->context->customer->id_customer" as Customer ID and "$this->context->customer->email" as Customer Email but it doesn't work. Please help me! Edited May 28, 2017 by leonardodestefanis (see edit history) Share this post Link to post Share on other sites
NemoPS 1,879 Posted May 29, 2017 prestashop.customer should be what you are looking for Share this post Link to post Share on other sites
ventura 1,033 Posted May 29, 2017 Try it with {$customer.id} {l s='%1$s %2$s' sprintf=[$customer.firstname, $customer.lastname]} {$customer.email} Share this post Link to post Share on other sites
NemoPS 1,879 Posted May 29, 2017 @ventura while your suggestion is perfect for templates, he is needing it in the script, isn't it better to just use the global prestashop object? Share this post Link to post Share on other sites
leonardodestefanis 0 Posted May 30, 2017 So how should I put this in the script? Share this post Link to post Share on other sites
ventura 1,033 Posted May 31, 2017 @ventura while your suggestion is perfect for templates, he is needing it in the script, isn't it better to just use the global prestashop object? @Nemops you are right. I didn´t know it this option You know, other option will be pass the .tpl variables to .js via addJsDef like in 1.6 Share this post Link to post Share on other sites
NemoPS 1,879 Posted May 31, 2017 Correct, that is the way I'd have gone on 1.6 Share this post Link to post Share on other sites
leonardodestefanis 0 Posted June 1, 2017 So what should I put into my script in order to retrieve the users information? Share this post Link to post Share on other sites
NemoPS 1,879 Posted June 2, 2017 like prestashop.customer.id Share this post Link to post Share on other sites
leonardodestefanis 0 Posted June 2, 2017 like prestashop.customer.id Sorry but I'm not a tech person, can you explain me how should I customize this code to retrieve customer id and customer email? <script> window.customerlySettings = { app_id: "3611c5b5", user_id: "REPLACE WITH YOUR USER ID",// Optional name: "REPLACE WITH USER NAME", email: "REPLACE WITH USER EMAIL", }; !function(){function e(){var e=t.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://widget.customerly.io/widget/3611c5b5";var r=t.getElementsByTagName("script")[0];r.parentNode.insertBefore(e,r)}var r=window,t=document,n=function(){n.c(arguments)};r.customerly_queue=[],n.c=function(e){r.customerly_queue.push(e)},r.customerly=n,r.attachEvent?r.attachEvent("onload",e):r.addEventListener("load",e,!1)}(); </script> Share this post Link to post Share on other sites
NemoPS 1,879 Posted June 5, 2017 user_id: "prestashop.customer.id",// Optionalemail: "prestashop.customer.email", Share this post Link to post Share on other sites
leonardodestefanis 0 Posted June 7, 2017 user_id: "prestashop.customer.id",// Optional email: "prestashop.customer.email", I've tried but unfortunately it doesn't work..the users' information are not retrieved Share this post Link to post Share on other sites
NemoPS 1,879 Posted June 9, 2017 Sorry, my fault, it's without quotes Share this post Link to post Share on other sites
TAB_Social 0 Posted August 5, 2019 (edited) Hi there, I have a similar concern, with a JavaScript from Intercom. Unfortunately I have no idea about JavaScript or Smarty. I want to change the variables. I also need the customer name, customer email address and the date the account was created. Here is the script (original from Intercom) with the variables I would have to change. <script> window.intercomSettings = { app_id: "123xxx", name: "Jane Doe", // Full name email: "customer@example.com", // Email address created_at: "1312182000" // Signup date as a Unix timestamp }; </script> <script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/123xxx';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();</script> If I insert the variables that are already mentioned here, is that right? <script> window.intercomSettings = { app_id: "XXX", name: "prestashop.customer.firstname prestashop.customer.lastname", // Full name email: "prestashop.customer.email", // Email address created_at: "What here???" // Signup date as a Unix timestamp }; </script> The variables: prestashop.customer.firstname prestashop.customer.lastname I thought up myself because I found similar variables as Smarty. These ones: {$Customer.lastname} {$Customer.FirstName} {$Customer.email} {$Customer.date_add} This looks very similar to those already mentioned here. It looks like they always have the same pattern or schema. just swap the $ sign with prestashop. Would the variable for the account creation time also be in the same pattern? like: prestashop.customer.date_add As I said, I have absolutely no idea, I just saw the pattern. I've already searched the internet, but I understand too little of the code. So I hope someone can please tell me what I have to insert here exactly. Thank you in advance Greetings Michael PS: Please excuse my bad english, i hope everything is understandable. 🤔 Edited August 5, 2019 by TAB_Social (see edit history) Share this post Link to post Share on other sites