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)
Link to comment
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

Link to comment
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>
Link to comment
Share on other sites

  • 2 years later...

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: "[email protected]", // 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)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...