0

Trying to clean up my logs and I keep getting this error over and over in my exception logs.

[2022-12-27 20:07:39] report.CRITICAL: The element "order_totals" can't have a child because "order_totals" already has a child with alias "ltl_shipping_fee". {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): The element \"order_totals\" can't have a child because \"order_totals\" already has a child with alias \"ltl_shipping_fee\". at /vendor/magento/framework/Data/Structure.php:625)"} []

After greping the keywords order_totals and ltl_shipping_fee I noticed some xml files from one or more of our third party modules. Not really sure what to do to fix this though. I'm pretty stuck on this and need some help.

    <?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>        
        <referenceContainer name="order_totals">
            <block class="FortyFour\Shipping\Block\Sales\Totals\LtlShippingFee" name="ltl_shipping_fee" as="ltl_shipping_fee"/>
            <block class="FortyFour\Shipping\Block\Sales\Totals\QuantityDiscount" name="quantity_discount" as="quantity_discount"/>
        </referenceContainer>
        <referenceBlock name="sales.order.items.renderers.default" template="FortyFour_Shipping::order/items/renderer/default.phtml"/>
        <referenceBlock name="order_items" template="FortyFour_Shipping::order/items.phtml"/>
        <referenceBlock name="order_totals">
            <arguments>
                <argument name="label_properties" xsi:type="string">colspan="8" class="mark"</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>



<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var \Magento\Sales\Block\Order\Items $block */
if ($block->getOrder()->getState() == "complete"):
    $colspan = "";
else:
    $colspan = "colspan=2";
endif;
?>
<div class="table-wrapper order-items">
    <table class="data table table-order-items" id="my-orders-table" summary="<?= /* @escapeNotVerified */ __('Items Ordered') ?>">
        <caption class="table-caption"><?= /* @escapeNotVerified */ __('Items Ordered') ?></caption>
        <thead>
        <?php if($block->isPagerDisplayed()): ?>
            <tr>
                <td colspan="6" data-block="order-items-pager-top" class="order-pager-wrapper order-pager-wrapper-top">
                    <?= $block->getPagerHtml() ?>
                </td>
            </tr>
        <?php endif ?>
        <tr>
            <th class="col name"><?= /* @escapeNotVerified */ __('Product Name') ?></th>
            <th class="col image" <?= $colspan ?>><?= /* @escapeNotVerified */ __('') ?></th>
            <th class="col sku"><?= /* @escapeNotVerified */ __('SKU') ?></th>
            <th class="col price"><?= /* @escapeNotVerified */ __('Price') ?></th>
            <th class="col status"><?= /* @escapeNotVerified */ __('Status') ?></th>
            <th class="col qty"><?= /* @escapeNotVerified */ __('Qty') ?></th>
            <th class="col subtotal"><?= /* @escapeNotVerified */ __('Subtotal') ?></th>
            <th class="col shipping" style="text-align: right"><?= /* @escapeNotVerified */ __('Shipping') ?></th>
            <?php if($block->getOrder()->getState() == "complete"): ?>
            <th class="col actions"><?= /* @escapeNotVerified */ __('Return Item') ?></th>
            <?php endif; ?>
        </tr>
        </thead>
        <?php $items = $block->getOrder()->getAllVisibleItems(); ?>
        <?php $giftMessage = ''?>
        <?php foreach ($items as $item): ?>
            <?php if ($item->getParentItem()) continue; ?>
            <tbody>
            <?= $block->getItemHtml($item) ?>
            <?php if ($this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order_item', $item) && $item->getGiftMessageId()): ?>
                <?php $giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessageForEntity($item); ?>
                <tr>
                    <td class="col options" colspan="5">
                        <a href="#"
                           id="order-item-gift-message-link-<?= /* @escapeNotVerified */ $item->getId() ?>"
                           class="action show"
                           aria-controls="order-item-gift-message-<?= /* @escapeNotVerified */ $item->getId() ?>"
                           data-item-id="<?= /* @escapeNotVerified */ $item->getId() ?>">
                            <?= /* @escapeNotVerified */ __('Gift Message') ?>
                        </a>
                        <?php $giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessageForEntity($item); ?>
                        <div class="order-gift-message" id="order-item-gift-message-<?= /* @escapeNotVerified */ $item->getId() ?>" role="region" aria-expanded="false" tabindex="-1">
                            <a href="#"
                               title="<?= /* @escapeNotVerified */ __('Close') ?>"
                               aria-controls="order-item-gift-message-<?= /* @escapeNotVerified */ $item->getId() ?>"
                               data-item-id="<?= /* @escapeNotVerified */ $item->getId() ?>"
                               class="action close">
                                <?= /* @escapeNotVerified */ __('Close') ?>
                            </a>
                            <dl class="item-options">
                                <dt class="item-sender"><strong class="label"><?= /* @escapeNotVerified */ __('From') ?></strong><?= $block->escapeHtml($giftMessage->getSender()) ?></dt>
                                <dt class="item-recipient"><strong class="label"><?= /* @escapeNotVerified */ __('To') ?></strong><?= $block->escapeHtml($giftMessage->getRecipient()) ?></dt>
                                <dd class="item-message"><?= /* @escapeNotVerified */ $this->helper('Magento\GiftMessage\Helper\Message')->getEscapedGiftMessage($item) ?></dd>
                            </dl>
                        </div>
                    </td>
                </tr>
            <?php endif ?>
            </tbody>
        <?php endforeach; ?>
        <tfoot>
        <?php if($block->isPagerDisplayed()): ?>
            <tr>
                <td colspan="7" data-block="order-items-pager-bottom" class="order-pager-wrapper order-pager-wrapper-bottom">
                    <?= $block->getPagerHtml() ?>
                </td>
            </tr>
        <?php endif ?>
        <?= $block->getChildHtml('order_totals') ?>
        </tfoot>
    </table>
</div>
<?php if ($giftMessage): ?>
    <script type="text/x-magento-init">
    {
        "a.action.show, a.action.close": {
            "giftMessage": {}
        }
    }
</script>
<?php endif; ?>
2
  • Please add the full content of these file in your question, if a file is big, you can paste it in other website which allow paste long code, then post the link here.
    – Tu Van
    Dec 28, 2022 at 1:06
  • Added the two files in question. @TuVan
    – Head
    Dec 28, 2022 at 4:43

1 Answer 1

1

Try to replace your layout xml file to the following:

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="sales.order.items.renderers.default" template="FortyFour_Shipping::order/items/renderer/default.phtml"/>
        <referenceBlock name="order_items" template="FortyFour_Shipping::order/items.phtml"/>
        <referenceBlock name="order_totals">
            <arguments>
                <argument name="label_properties" xsi:type="string">colspan="8" class="mark"</argument>
            </arguments>
            <block class="FortyFour\Shipping\Block\Sales\Totals\LtlShippingFee" name="ltl_shipping_fee" as="ltl_shipping_fee"/>
            <block class="FortyFour\Shipping\Block\Sales\Totals\QuantityDiscount" name="quantity_discount" as="quantity_discount"/>
        </referenceBlock>
    </body>
</page>

Then clear layout cache type.

2
  • We just removed the referenceContainer and added the block class below. I will test this to ensure there is no other issues. Do you think any issues will arise from removing the reference Container? @Tu Van
    – Head
    Dec 28, 2022 at 15:10
  • 1
    I think there are no container named order_totals, looks like that is a mistake from someone. But you should test the page content after the page rendering to make sure nothing was broken.
    – Tu Van
    Dec 28, 2022 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.