{% if (tracking_code) %} in commerce-shipment-confirmation.html.twig needs work.

Created on 18 February 2022, almost 3 years ago
Updated 16 March 2023, over 1 year ago

Problem/Motivation

Tracking information: prints from commerce-shipment-confirmation.html.twig even when there is no tracking code.

It is parented under an attempt to check if the tracking code is not empty:

        {% if (tracking_code) %}
          {% block tracking_info %}
            <tr>
              <td style="font-weight: bold; padding-top:15px; padding-bottom: 15px; text-align: left; vertical-align: top; border-top: 1px solid #cccccc">
                {{ 'Tracking information:'|t }}

https://git.drupalcode.org/project/commerce_shipping/-/blob/8.x-2.x/temp...

I'm guessing the reason that checking the variable tracking_code doesn't work is because it is checking the view mode, rather than the entity's field itself.
https://git.drupalcode.org/project/commerce_shipping/-/blob/8.x-2.x/src/...

Checking the tracking_code itself directly off the entity, and explicitly checking that it's not empty works. {% if shipment_entity.tracking_code is not empty %}

Also, we shouldn't only thank people for their order if it has a tracking code.
https://git.drupalcode.org/project/commerce_shipping/-/blob/8.x-2.x/temp...

Steps to reproduce

Send an email with no tracking code.

Proposed resolution

Fix it.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024