Jump to content

Recommended Posts

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 by leonardodestefanis (see edit history)

Share this post


Link to post
Share on other sites

prestashop.customer should be what you are looking for

Share this post


Link to post
Share on other sites

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

@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

@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

Correct, that is the way I'd have gone on 1.6 :)

Share this post


Link to post
Share on other sites

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

user_id: "prestashop.customer.id",// Optional
email: "prestashop.customer.email",

Share this post


Link to post
Share on other sites

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
Posted (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 by TAB_Social (see edit history)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More