Skip to content

Customers templating

Ibexa Commerce provides a global Twig variable ses which is available in all templates. The variable provides the profile method which contains information about the current customer.

If the user has a customer number, Ibexa Commerce automatically fetches customer information from the ERP. The data is stored in the session and is provided by the variable ses.profile. Subsequent calls do not initiate a new request to the ERP because the data from the ERP is cached and handled by the Symfony session handlers.

Ibexa Commerce provides a standard template for displaying customer data: SilversolutionsEshopBundle/Resources/views/details.html.twig.

Getting customer profile data

As ses.profile in the template returns the currently logged-in profile, you are able to use all read-only members from the CustomerProfileData implementation.

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Current customer number: {{ ses.profile.sesUser.customerNumber }}
All delivery addresses:  {% set deliveryAddresses = ses.deliveryParty %}
E-Mail address:          {{ ses.profile.sesUser.email }}


{% if ses.profile.sesUser.isLoggedIn %}
    Hello customer #{{ ses.profile.sesUser.customerNumber }}.

    {% if ses.profile.sesUser.contact.isBlocked %}
        Sorry, but you are blocked!
    {% endif %}
{% endif %}


{% if ses.profile.sesUser.isAnonymous %}
    <p>Anonymous user</p>
{% endif %}

You can use any data from CustomerProfileData, see example in the model.

Getting data from a buyer party

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{% set buyerParty = ses.defaultBuyerAddress %}
{% if buyerParty.SesExtension.value.Gliederungskennzeichen is defined and buyerParty.SesExtension.value.Gliederungskennzeichen == '1' %}

{% endif %}


{% set invoiceAddress = ses.defaultInvoiceParty %}


{% set deliveryAddress = ses.defaultDeliveryParty %}

To output the telephone number of the contact, point to the member variable $phoneNumber of the Contact.

1
Phone number of contact {{ ses.profile.sesUser.contact.phoneNumber }}

Read the Docs