I tried to create a layout and phtml template and a block for add something to cart view page.
I added something, but When I want to choose referenceBlock the content disappear.
Actually I'm going to add some column like price and number to cart table view, but I think it could not find the block! I appreciate any help of you
Here is my code:
MagenCheckout/CheckoutField/Block/Productpoint.php`
<?php
namespace MagenCheckout\CheckoutField\Block;
class Productpoint extends \Magento\Framework\View\Element\Template
{
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [])
{
parent::__construct($context, $data);
}
}
MagenCheckout/CheckoutField/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MagenCheckout_CheckoutField" setup_version="0.0.8">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
MagenCheckout/CheckoutField/view/frontend/layout/checkout_cart_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.form">
<block class="MagenCheckout\CheckoutField\Block\Productpoint" name="cart_item_addional_info" template="MagenCheckout_CheckoutField::checkout/cart/productpoint.phtml"/>
</referenceBlock>
</body>
</page>
MagenCheckout/CheckoutField/view/frontend/templates/checkout/cart/productpoint.phtml
<p>
<?php echo 'Your Discount'; ?>
</p>
MagenCheckout/CheckoutField/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE, 'MagenCheckout_CheckoutField',
__DIR__
);
vendor/magento/module-checkout/view/frontend/templates/cart/item/default.phtml. Please refer to topics about override template file like this topic to do it yourself :) – Quan Le Sep 26 '17 at 09:26checkout.cart.item.rendererswhich has no name and use default.phtml as template inmodule-checkout/view/frontend/layout/path – M Taheri Sep 26 '17 at 12:07