Skip to content

Commit ec0e694

Browse files
committed
Add changes in script
1 parent 7abd1cf commit ec0e694

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

templates/_userComScripts.html.twig

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
{% set channel = sylius.channel %}
21

3-
{% if null != channel.userComApiKey and null != channel.userComUrl%}
4-
{% set customer = sylius.customer|default(null) %}
5-
{% set genderMap = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::GENDER_MAP')%}
6-
{% set active = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_USER')%}
7-
{% set visitor = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_VISITOR')%}
8-
9-
<script data-cfasync="false">window.civchat = {
10-
apiKey: "{{ user_com_frontend_api_key }}",
11-
name: "{{ customer.name|default(null) }}",
12-
user_id: "{{ customer.email|default(null) }}",
13-
email: "{{ customer.email|default(null) }}",
14-
gender: {{ null != customer ? genderMap[customer.gender] : genderMap['u'] }},
15-
status: {{ null != customer ? active : visitor }},
16-
phone_number: "{{ customer.phone_number|default(null)}}",
17-
}
18-
19-
{% set routes = constant('BitBag\\SyliusUserComPlugin\\EventSubscriber\\CustomerProfileUpdatedSubscriberInterface::API_INTEGRATION_ROUTES')%}
20-
</script>
21-
<script data-cfasync="false" src={{ channel.userComUrl ~ "widget.js" }}>
22-
{% if null == sylius.customer and app.request.attributes.get('_route') in routes %}
23-
UE.resetAuth({'apiKey': {{ user_com_frontend_api_key}}})
24-
{% endif %}
25-
</script>
26-
{% endif %}
2+
{% set genderMap = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::GENDER_MAP')%}
3+
{% set active = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_USER')%}
4+
{% set visitor = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_VISITOR')%}
5+
{% set customer = sylius.customer|default(null) %}
6+
<script data-cfasync="false">const user_com_customer_info= {
7+
name: "{{ customer.name|default(null) }}",
8+
user_id: "{{ customer.email|default(null) }}",
9+
email: "{{ customer.email|default(null) }}",
10+
gender: {{ null != customer ? genderMap[customer.gender] : genderMap['u'] }},
11+
status: {{ null != customer ? active : visitor }},
12+
phone_number: "{{ customer.phone_number|default(null)}}",
13+
}
14+
</script>
2715

2816
<!-- Google tag (gtag.js), plugin provided by Spinbits -->
2917
<script async src="https://www.googletagmanager.com/gtag/js?id={{ id }}{{ url_suffix|raw }}"></script>

0 commit comments

Comments
 (0)