|
2 | 2 | {% set active = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_USER')%} |
3 | 3 | {% set visitor = constant('BitBag\\SyliusUserComPlugin\\Builder\\Payload\\CustomerPayloadBuilderInterface::STATUS_VISITOR')%} |
4 | 4 | {% 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 %} |
14 | 33 | {% set apiAwareResource = getUserComApiAwareResource() %} |
15 | 34 |
|
16 | 35 | {% if null != apiAwareResource and null != apiAwareResource.userComGTMContainerId %} |
|
0 commit comments