1

we are using Magento 2.4.4.

Customers always get confused when they try to set a new shipping address.

They by the logic first need to add a new address and then only can select a different shipping address.

I would like to add an extra text therefore in the Address Book (and also add this extra text per store view and/or translate via the Theme or Core Locale)

It should look like this:

Add extra text to Address Book

Does anyone know how to achieve this?

1 Answer 1

1

You can achieve your requirement by following steps:

Step 1: Create customer_address_index.xml under your theme location like below:

app/design/frontend/Vendor/theme/Magento_Customer/layout/customer_address_index.xml

Add the below code to your customer_address_index.xml:

<?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">
    <referenceBlock name="page.main.title" template="Dapl_OrderAttribute::html/title.phtml"/>
</page>

Step 2: Create title.phtml under your theme location like below:

app/design/frontend/Vendor/theme/Magento_customer/templates/html/title.phtml

Add the below code to your title.phtml:

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

/**
 * @var $block \Magento\Theme\Block\Html\Title
 */
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$titleHtml = '';
if (trim($block->getPageHeading())) {
    $titleHtml = '<span class="base" data-ui-id="page-title-wrapper" '
        . $block->getAddBaseAttribute()
        . '>'
        . $block->escapeHtml($block->getPageHeading())
        . '</span>';
}
?>
<?php if ($titleHtml) : ?>
<div class="page-title-wrapper<?= $block->escapeHtmlAttr($cssClass) ?>">
    <h1 class="page-title"
        <?php if ($block->getId()) : ?> id="<?= $block->escapeHtmlAttr($block->getId()) ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()) : ?>
            aria-labelledby="<?= $block->escapeHtmlAttr($block->getAddBaseAttributeAria()) ?>"
        <?php endif; ?>>
        <?= /* @noEscape */ $titleHtml ?>
        <div style="color:#ff0000; font-size: 14px;"><?= /* @noEscape */ __('To change the shipping address, please first add a new address and then select the new address') ?></div>
    </h1>    
    <?= $block->getChildHtml() ?>
</div>
<?php endif; ?>

Hope this helps! Cheers!

1
  • Thank you @Sukumar. We will check and try and let you know the result.
    – Ben
    Jun 7 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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