Automatically Set Order ID in Crisp Chat User Data

Prerequisite

You are using https://crisp.chat/

Function

Customer order ID will be set in chat session user data automatically.

Implementation

Add below code in /templates/<TemplateName>/account_order.html

<script>
var cusemail = '%%GLOBAL_CurrentCustomerEmail%%';
var cusorder = '%%GLOBAL_OrderId%%';
if(cusemail != ''){
    $crisp.push(["set", "user:email", ["%%GLOBAL_CurrentCustomerEmail%%"]]);
    $crisp.push(["set", "user:nickname", ["%%GLOBAL_CurrentCustomerFirstName%% %%GLOBAL_CurrentCustomerLastName%%"]]);
}
if(cusorder != ''){
    $crisp.push(["set", "session:data", ["Order", "%%GLOBAL_OrderId%%"]]);
}
$crisp.push(["set", "session:segments", [["moddiy"]]]);
</script>

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *