Profile Comments/Notes

I’m looking to retrieve and store data in the Profile Comments field using the User Profile Address module.

In the mod_commerce_address table it looks like this field is called “notes”, however in the shipping-address-fields.twig template I can’t figure out what the placeholder should be, I’ve tried: {{ address_shipping_notes }} and a few others.

I’ve also noticed in the default setup if the “Save this address on my profile” is checked then whatever is already in the Comments filed on the profile is erased.

The address_{type}_{field} placeholders contain what the customer entered/selected, so those may be empty if there’s not already provided. Those would be used in the inputs as the value and should be notes. Internally, Commerce is mapping that to the comment field on the user profile.

This should work:

    <div class="c-field {% if error_shipping_notes %}error{% endif %}">
        <label for="address-shipping-notes">{{ lex('commerce.address.notes') }}</label>
        <input type="text" name="address[shipping][notes]" id="address-shipping-notes" value="{{ address_shipping_notes }}">
        {% if error_shipping_notes %}<span class="c-field-error">{{ error_shipping_notes }}</span>{% endif %}

Hi Mark,

I’m just getting around to working on the Commerce implementation again and I’m still running into the problem where the notes/comments field’s content gets overwritten with a blank value at the Address step of the Checkout.

Even, if I omit the shipping notes field entirely from the template, the existing notes/comment field value is still overwritten.

What I’m really looking for is for the notes/comments field in the user’s profile to not be updated or changed at all at the Address step of the Checkout.

See below for my shipping-address-fields.twig and address.twig files.

<div class="row g-3 mt-1">
    <div class="col-md-12 bg-light-input {% if error_shipping_fullname %}error{% endif %}">
        <label for="address-shipping-fullname" class="form-label">Your name *</label>
        <input class="form-control" type="text" name="address[shipping][fullname]" id="address-shipping-fullname" value="{{ address_shipping_fullname }}">
        {% if error_shipping_fullname %}<span class="c-field-error">{{ error_shipping_fullname }}</span>{% endif %}

    <div class="col-md-6 bg-light-input {% if error_shipping_email %}error{% endif %}">
        <label for="address-shipping-email" class="form-label">Email address *</label>
        <input class="form-control" type="text" name="address[shipping][email]" id="address-shipping-email" value="{{ address_shipping_email }}">
        {% if error_shipping_email %}<span class="c-field-error">{{ error_shipping_email }}</span>{% endif %}

    <div class="col-md-6 bg-light-input {% if error_shipping_phone %}error{% endif %}">
        <label for="address-shipping-phone" class="form-label">Phone number <span class="caption">(Optional)</span></label>
        <input class="form-control" type="text" name="address[shipping][phone]" id="address-shipping-phone" value="{{ address_shipping_phone }}">
        {% if error_shipping_phone %}<span class="c-field-error">{{ error_shipping_phone }}</span>{% endif %}

    <div class="col-md-12 bg-light-input {% if error_shipping_address1 %}error{% endif %}">
        <label for="address-shipping-address1">{{ lex('commerce.address.address') }}</label>
        <input class="form-control" name="address[shipping][address1]" id="address-shipping-address1" value="{{ address_shipping_address1 }}" >
        {% if error_shipping_address1 %}<span class="c-field-error">{{ error_shipping_address1 }}</span>{% endif %}
    <div class="col-md-12 bg-light-input {% if error_shipping_address2 %}error{% endif %}">
        <label class="form-label" for="address-shipping-address2">{{ lex('commerce.address.address2') }} <small>{{ lex('commerce.address.optional') }}</small></label>
        <input class="form-control" name="address[shipping][address2]" id="address-shipping-address2" value="{{ address_shipping_address2 }}">
        {% if error_shipping_address2 %}<span class="c-field-error">{{ error_shipping_address2 }}</span>{% endif %}

    <div class="col-md-6 bg-light-input {% if error_shipping_country %}error{% endif %}">
        <label for="address-shipping-country" class="form-label">Country *</label>
        <select class="form-select js-choice" name="address[shipping][country]" id="address-shipping-country" aria-label=".form-select-lg" >
            <option value=""></option>
            {% for country in countries %}
                <option value="{{ country.iso }}" {% if address_shipping_country == country.iso %}selected="selected"{% endif %}>{{ country.shortname }}</option>
            {% endfor %}
        {% if error_shipping_country %}<span class="c-field-error">{{ error_shipping_country }}</span>{% endif %}

    <div class="col-md-6 bg-light-input  {% if error_shipping_state %}error{% endif %}">
        <label for="address-shipping-state" class="form-label">Select state, province, county *</label>
        <input class="form-control" type="text" name="address[shipping][state]" id="address-shipping-state" value="{{ address_shipping_state }}">
        {% if error_shipping_state %}<span class="c-field-error">{{ error_shipping_state }}</span>{% endif %}
    <div class="col-md-6 bg-light-input {% if error_shipping_city %}error{% endif %}">
        <label class="form-label" for="address-shipping-city">{{ lex('') }}</label>
        <input class="form-control" type="text" name="address[shipping][city]" id="address-shipping-city" value="{{ address_shipping_city }}">
        {% if error_shipping_city %}<span class="c-field-error">{{ error_shipping_city }}</span>{% endif %}
    <div class="col-md-6 bg-light-input {% if error_shipping_zip %}error{% endif %}">
        <label class="form-label" for="address-shipping-zip">Post/Zip Code</label>
        <input class="form-control" type="text" name="address[shipping][zip]" id="address-shipping-zip" value="{{ address_shipping_zip }}">
        {% if error_shipping_zip %}<span class="c-field-error">{{ error_shipping_zip }}</span>{% endif %}

    <div class="c-field {% if error_shipping_notes %}error{% endif %}">
        <label class="form-label" for="address-shipping-notes">{{ lex('commerce.address.notes') }}</label>
        <input class="form-control" type="text" name="address[shipping][notes]" id="address-shipping-notes" value="{{ address_shipping_notes }}">
        {% if error_shipping_notes %}<span class="c-field-error">{{ error_shipping_notes }}</span>{% endif %}

    <div class="c-field">
        <label for="address-shipping-remember">
            <input type="checkbox" name="address[shipping][remember]" id="address-shipping-remember" value="0">
            {{ lex('commerce.remember_address') }}

    {% if user_profile_address_prefilled %}
        <div class="c-field">
            <label for="address-shipping-update-profile">
                <input type="checkbox" name="address[shipping][properties][update_profile]" id="address-shipping-update-profile" value="1" checked="checked">
                {{ lex('commerce.module.userprofileaddress.remember_address') }}
    {% endif %}

and I’m not sure if this is useful, but here’s the address.twig file too:

<form class="row g-4 g-sm-5 pt-1 mb-4" method="POST" action="{{ current_url }}">
    <div class="col-md-8 mb-4 mb-sm-0">
        <div class="card bg-transparent">
            <div class="card-header border-bottom d-flex justify-content-between align-items-center px-0 pb-3">
                <h4 class="card-title mb-0">Your Address</h4>
                {% if order.total_quantity != 1 %}
                    {{ lex('commerce.cart_header', { 'items': order.total_quantity }) }}
                {% else %}
                    {{ lex('commerce.cart_header_single') }}
                {% endif %}
        <div class="card card-body  p-4">
            <input type="hidden" name="add_address" value="1">
            {% if previously_used_shipping|length > 0 %}
                {% for address in previously_used_shipping %}
                    {% include "frontend/checkout/partial/previous-address.twig" with {
                        address: address,
                        type: 'shipping',
                        current_address: address_shipping_user_address
                    } %}
                {% endfor %}
                <div class="form-check">
                    <input type="radio"
                           {% if address_shipping_id == 'new' %}checked="checked"{% endif %}
                    <label for="shipping-address-new">
                        <b>{{ lex('commerce.add_new_address') }}</b>
            {% endif %}
                {% include 'frontend/checkout/partial/shipping-address-fields.twig' %}
            {% if previously_used_shipping|length > 0 %}
            {% endif %}
    <div class="col-md-4">
        {% include 'frontend/checkout/partial/summary.twig' %}

Hm, so you’re saying that {{ address_shipping_notes }} is not being pre-filled with the comments for you?

Right now we don’t offer much in terms of configuration for this module as it has been largely replaced with the separate user addresses, which offer a lot more flexibility to have different billing/shipping addresses.

Perhaps you are submitting both a shipping and billing address with the update_profile field enabled? Because there’s only one profile that could end up overwriting itself.