0

I want to add some text and images below proceed to checkout button on cart page but I am not able to find the file so that I can add my classes and images as well as text.

Please suggest me in which file I will need to update.

Below is attached screenshot please check it:

enter image description here

2 Answers 2

2

enable frontend template hint from admin and you will find the file of your theme for checkout page.

/vendor/magento/module-checkout/view/frontend/templates/cart.phtml
6
  • Already enabled but not getting exactly.
    – akgola
    Oct 17, 2018 at 12:08
  • please choose store scope first then ENABLE template path hint for frontend Oct 17, 2018 at 12:12
  • vendor/magento/module-checkout/view/frontend/templates/onepage/link.phtml proceed to checkout button is coming from this template
    – Akash
    Oct 17, 2018 at 12:12
  • vendor/magento/module-checkout/view/frontend/templates/cart.phtml check if you have same file in your theme folder and edit it. Make sure you take backup before making any changes.
    – Akash
    Oct 17, 2018 at 12:15
  • @John vendor/magento/module-checkout/view/frontend/templates/cart.phtml //this will work for me.thanks
    – akgola
    Oct 17, 2018 at 12:20
0

You can use viewModel to add custom content. You can create custom module for this.

app/code/Anshu/Custom/view/frontend/layout/checkout_cart_index.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block name="customcartblock" template="Anshu_Custom::customcartblock.phtml" after="-">
                <arguments>
                    <argument name="viewModel" xsi:type="object">Anshu\Custom\ViewModel\Customcartblock</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

app/code/Anshu/Custom/ViewModel/Customcartblock.php

<?php

namespace Anshu\Custom\ViewModel;

use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Framework\DataObject;

class Customcartblock extends DataObject implements ArgumentInterface
{
    public function getSomeThing()
    {
        return 'This is the custom text.';
    }
}

app/code/Anshu/Custom/view/frontend/templates/customcartblock.phtml

<?php
$viewModel = $block->getData('viewModel');
var_dump($viewModel->getSomeThing());

This is the sample code. You can modify it according to your requirement.

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.