5

I am trying to change "Shopping Cart" to "Basket" on both the h1.page-title and in the <title> tag itself.

Where can I change this?

4

You can change this directly in the checkout i18l file:

app/code/Magento/Checkout/i18n/en_US.csv

in your theme, like:

app/design/frontend/Vendor/theme/i18n/en_US.csv

Just change string translation like this:

"Shopping Cart","Basket"

Result:

result

Or you can create a language pack https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-i18n.html

To translate a minicart title you must run setup:static-content:deploy with required parameters (More Info in DevDocs). After that translations must present in the js-translation.json file (pub/static/frontend/Vendor/theme/en_US/js-translation.json):

js-translation file example

and result will be visible on the frontend:

result on the frontend

| improve this answer | |
1

I found in my case where I needed to change the <title/> tag, an "after" plugin can be used on the cart Index->execute(); controller method.

The page title is set in

\** \Magento\Checkout\Controller\Cart\Index **\
    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->set(__('Shopping Cart'));
        return $resultPage;
    }

Here is my plugin afterExecute()

/**
 * Custom cart index page
 *
 * @return \Magento\Framework\View\Result\Page
 */
public function afterExecute(
    \Magento\Checkout\Controller\Cart\Index $cartIndex,
    $resultPage
)
{
    /** @var \Magento\Framework\View\Result\Page $resultPage */
    $resultPage = $this->resultPageFactory->create();
    $resultPage->getConfig()->getTitle()->set(__('TITLE TAG CONTENT HERE'));

    $titleBlock = $resultPage->getLayout()->getBlock('page.main.title');
    if ($titleBlock) {
        $titleBlock->setPageTitle(
            __('PAGE CONTENT TITLE HERE')
        );
    }
    return $resultPage;
}
| improve this answer | |
1

The best and easiest solution that I found and that will not affect the default MAGENTO 2 structure (just changed under my theme) is by Prashant Valanda on "How to modify page title?" article.

Basically you just need to add this code in your XML file. In this case checkout_cart_index.xml:

<referenceBlock name="page.main.title">
    <action method="setPageTitle">
        <argument translate="true" name="title" xsi:type="string">Basket</argument>
    </action>
</referenceBlock>

After change doesn't forget to flush the cache.

php bin/magento cache:flush
| improve this answer | |

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.