1

When viewing my shopping cart there is an header "Shopping Cart", looks like this:

shopping cart title

How can I add an button (or just a "a href link which has div inside it" would also be good enough) in that header part?

For example I would like to get "Continue shopping" which redirects to homepage when pressed.

In the end I want something like this:

result

Thank you very much!

1 Answer 1

0

Override vendor/magento/module-theme/view/frontend/templates/html/title.phtml file in your active theme and update it like below.

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

// @codingStandardsIgnoreFile

/**
 * @var $block \Magento\Theme\Block\Html\Title
 */
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = '';
if (trim($block->getPageHeading())) {
    $title = '<span class="base" data-ui-id="page-title-wrapper" ' .  $block->getAddBaseAttribute() . '>'
        . $block->escapeHtml($block->getPageHeading()) . '</span>';
}
?>
<?php if ($title): ?>
<div class="page-title-wrapper<?= /* @escapeNotVerified */ $cssClass ?>">
    <h1 class="page-title"
        <?php if ($block->getId()): ?> id="<?= /* @escapeNotVerified */ $block->getId() ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()): ?>
            aria-labelledby="<?= /* @escapeNotVerified */ $block->getAddBaseAttributeAria() ?>"
        <?php endif; ?>>
        <?= /* @escapeNotVerified */ $title ?>
    </h1>
    <?= $block->getChildHtml() ?>
    <?php if($block->escapeHtml($block->getPageHeading()) == "Shopping Cart") { ?><span><button>MyButton</button></span> <?php } ?> 
</div>
<?php endif; ?>

Let me know if any further help needed.

0

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.