2

I want to add text into the cart showed in the picture, but unfortunately my code does not work. enter image description here

This is my file structure:

enter image description here

Code in ButtonGet.php:

<?php
namespace MassiveArt\ShoppingCart\Block;
class ButtonGet extends \Magento\Framework\View\Element\Template
{
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        array $data = []
    ) {
        parent::__construct($context, $data);
    }

}

Code in get_cart_index.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="minicart.addons">
                <block class="MassiveArt\ShoppingCart\Block\ButtonGet" after="-" name="custom_button" template="MassiveArt_ShoppingCart::button_getcart.phtml" />
        </referenceContainer>
</page>

Code in button_getcart.phtml:

<h1>Hello</h1>

The Rest of my Module is working proberly, but this Text not. Can you help me?

2
  • which position you want to show text ?? Commented Aug 13, 2019 at 13:04
  • before the "view and edit cart" link Commented Aug 13, 2019 at 13:05

1 Answer 1

0

Create File In MassiveArt/ShoppingCart/view/frontend/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="minicart.addons">
            <block class="MassiveArt\ShoppingCart\Block\ButtonGet" name="minicart.movetoquote" template="MassiveArt_ShoppingCart::button_getcart.phtml"/>
        </referenceContainer>
</page>

Create phtml File In MassiveArt/ShoppingCart/view/frontend/templates/button_getcart.phtml

<h1>Hello</h1>
4
  • I did this, but it is not working. Commented Aug 13, 2019 at 13:15
  • create default.xml file as per my answer Commented Aug 13, 2019 at 13:15
  • why cant I name it get_cart_index.xml? Because with the name default.xml it is working. I just not understand why? But thanks a lot. Commented Aug 13, 2019 at 13:18
  • default.xml is always excute so Commented Aug 13, 2019 at 13:20

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.