How to add a custom text block in shopping cart in magento 2?

enter image description here

2 Answers 2


Go to below file


if above file not your theme then override in your theme after change

and find this code like :

                <?php if ($block->hasProductUrl()):?>
                    <a class="cart-product" href="<?= /* @escapeNotVerified */ $block->getProductUrl() ?>"><?= $block->escapeHtml($block->getProductName()) ?></a>
                <?php else: ?>
                    <?= $block->escapeHtml($block->getProductName()) ?>
                <?php endif; ?>

after add your logic

  • how to add in custom module May 15, 2019 at 11:13

First you need to add the following to your config.xml under the <config> tag:


Then you need to create your layout file app/design/frontend/base/default/layout/expressdelivery.xml with the following content:

<?xml version="0.1.0">
<layout version="0.1.0">

         <reference name="checkout.cart">
              <block type="core/template" name="extra_block" template="link/to/your/template" />


Then in your app/design/frontend/<your_package>/<your_theme>/template/checkout/cart.phtml you'll need to add the following code:

<?php echo $this->getChildHtml('extra_block'); ?>

Before this code:

<?php echo $this->getChildHtml('crosssell') ?>

You can refer this links too

How to add custom block at the /checkout/cart/ page?

How do you add a custom block in checkout/cart page in magento2?

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.