Back to Top

Display custom block on the checkout cart page in Magento 2

Updated 8 October 2021

Hello Friends!

In Magento 2, sometimes we need to save additional information in quotes or we want to display some information on the cart page on the frontend. So, we can achieve the same by following steps:

1. Create checkout_cart_index.xml file inside the app/code/Vendor/CustomModule/view/frontend/layout/ directory.

<?xml version="1.0"?>
<!-- /**
 * Vendor Desc.
 *
 * @category Vendor
 * @package Vendor_CustomModule
 * @author Vendor
 * @copyright Copyright (c) Vendor
 * @license https://example.com/license.html
 */ -->
 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="checkout.cart.order.actions">
            <block class="Magento\Framework\View\Element\Template" 
                name="checkout.cart.customblock" 
                template="Vendor_CustomModule::customblock.phtml">
            </block>
        </referenceContainer>
    </body>
 </page>

2. Create the customblock.phtml file inside the app/code/Vendor/CustomModule/view/frontend/templates/ directory.

<p style="color:green;">
    Custom Block<br/>
    Write your content Here...OR Create a Form
</p>

3. Look at the result in the following image.

cartCustomBlock

Searching for an experienced
Magento 2 Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home