Добавить дополнительный столбец к таблице в модуле-twig-е

Главные вкладки

Аватар пользователя kompospec kompospec 8 января 2022 в 6:53

Д9
Добавить дополнительный столбец к таблице в модуле-twig-е

Дописал прям в Модуль:

{{ order_item.getTitle }}

Работает.

1. При обновлении модуля - слетит;
2. Не правильно это - ковырять чужой код.

Как правильно? Спасибо.

Лучший ответ

Аватар пользователя marassa marassa 8 января 2022 в 7:37
2

По идее если свой шаблон с точно таким же именем в точно такой же поддиректории положить в свою кастомную тему, то подхватываться будет именно он вместо контрибного из модуля.

Комментарии

Аватар пользователя kompospec kompospec 8 января 2022 в 7:01

файл целиком:

{#
/**
 * @file
 * Default theme implementation for the checkout order summary.
 *
 * The rendered order totals come from commerce-order-total-summary.html.twig.
 * See commerce-order-receipt.html.twig for examples of manual total theming.
 *
 * Available variables:
 * - order_entity: The order entity.
 * - checkout_step: The current checkout step.
 * - totals: An array of order total values with the following keys:
 *   - subtotal: The order subtotal price.
 *   - adjustments: An array of adjustment totals:
 *     - type: The adjustment type.
 *     - label: The adjustment label.
 *     - total: The adjustment total price.
 *     - weight: The adjustment weight, taken from the adjustment type.
 *   - total: The order total price.
 * - rendered_totals: The rendered order totals.
 */

#}
<div{{ attributes.addClass('checkout-order-summary') }}>
  {% block order_items %}
    <table>
      <tbody>
      {% for order_item in order_entity.getItems %}
        <tr>
          <td>{{ order_item.getTitle }} </td>
          <td>{{ order_item.getQuantity|number_format }}&nbsp;x</td>
          {% if order_item.hasPurchasedEntity %}
            <td>{{ order_item.getPurchasedEntity|commerce_entity_render('summary') }}</td>
          {% else %}
            <td>{{- order_item.label -}}</td>
          {% endif %}
          <td>{{- order_item.getTotalPrice|commerce_price_format -}}</td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  {% endblock %}
  {% block totals %}
    {{ rendered_totals }}
  {% endblock %}
</div>
Аватар пользователя marassa marassa 8 января 2022 в 7:37
2

По идее если свой шаблон с точно таким же именем в точно такой же поддиректории положить в свою кастомную тему, то подхватываться будет именно он вместо контрибного из модуля.

Аватар пользователя kompospec kompospec 8 января 2022 в 12:07

marassa wrote:
По идее если свой шаблон с точно таким же именем в точно такой же поддиректории положить в свою кастомную тему, то подхватываться будет именно он вместо контрибного из модуля.

Сработало! Спасибо вам огромнешее.