Skip to content

Commit 7178e72

Browse files
authored
Merge pull request #33 from BitBagCommerce/UC-26-customer-info
[UC-26] Change usercom_customer_info values
2 parents 0954583 + 778e108 commit 7178e72

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

templates/Scripts/_userComScripts.html.twig

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,34 @@
22
{% set active = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_USER')%}
33
{% set visitor = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_VISITOR')%}
44
{% set customer = sylius.customer|default(null) %}
5-
<script data-cfasync="false">const user_com_customer_info= {
6-
name: "{{ customer.name|default(null) }}",
7-
user_id: "{{ customer.email|default(null) }}",
8-
email: "{{ customer.email|default(null) }}",
9-
gender: {{ null != customer ? genderMap[customer.gender] : genderMap['u'] }},
10-
status: {{ null != customer ? active : visitor }},
11-
phone_number: "{{ customer.phone_number|default(null)}}",
12-
}
13-
</script>
5+
{% if customer is not null %}
6+
<script data-cfasync="false">
7+
const user_com_customer_info = {
8+
{% if customer.fullName is not empty %}
9+
name: "{{ customer.fullName }}",
10+
{% endif %}
11+
{% if customer.email is not empty %}
12+
user_id: "{{ customer.email }}",
13+
email: "{{ customer.email }}",
14+
{% endif %}
15+
{% if customer.phoneNumber is not empty %}
16+
phone_number: "{{ customer.phoneNumber }}",
17+
{% endif %}
18+
{% if customer.gender in genderMap and genderMap[customer.gender] in [2, 3] %}
19+
gender: {{ genderMap[customer.gender] }},
20+
{% else %}
21+
gender: undefined,
22+
{% endif %}
23+
status: {{ active }}
24+
};
25+
</script>
26+
{% else %}
27+
<script data-cfasync="false">
28+
const user_com_customer_info = {
29+
status: {{ visitor }}
30+
};
31+
</script>
32+
{% endif %}
1433
{% set apiAwareResource = getUserComApiAwareResource() %}
1534

1635
{% if null != apiAwareResource and null != apiAwareResource.userComGTMContainerId %}

0 commit comments

Comments
 (0)