I have created a module with Custom/Module as {Namespace/Modulename},
app/code/Custom/Module/etc/di.xml
file,
<type name="Magento\Checkout\Block\Cart\AbstractCart">
<plugin name="qty_hide" type="Custom\Module\Plugin\Cart\AbstractCart" sortOrder="1"/>
</type>
Create plugin file at below location in your module,
app/code/Custom/Module/Plugin/Cart/AbstractCart.php
<?php
namespace deca\Servicefee\Plugin\Cart;
class AbstractCart
{
/*
* Override cart/item/default.phtml file
* \Magento\Checkout\Block\Cart\AbstractCart $subject
* $result
*/
public function afterGetItemRenderer(\Magento\Checkout\Block\Cart\AbstractCart $subject, $result)
{
$result->setTemplate('Custom_Module::cart/item/default.phtml');
return $result;
}
}
Finally created default.phtml template file in my module view folder,
app/code/Custom/Module/view/frontend/templates/cart/item/default.phtml
But geting below error `
1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Custom_Module::cart/item/default.phtml' in module: 'Magento_Checkout' block's name: 'checkout.cart.item.renderers.simple'
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Custom_Module::cart/item/default.phtml' in module: 'Magento_Checkout' block's name: 'checkout.cart.item.renderers.simple'
#0 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView(false)
#1 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#2 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-checkout/Block/Cart/AbstractCart.php(134): Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml(37): Magento\Checkout\Block\Cart\AbstractCart->getItemHtml(Object(Magento\Quote\Model\Quote\Item))
#4 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/home/193246.cl...')
#5 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart\Grid\Interceptor), '/home/193246.cl...', Array)
#6 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView('/home/193246.cl...')
#7 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#8 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(558): Magento\Framework\View\Element\AbstractBlock->toHtml()
#9 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(534): Magento\Framework\View\Layout->_renderBlock('checkout.cart.f...')
#10 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.f...')
#11 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart.f...')
#12 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('checkout.cart.c...')
#13 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.c...')
#14 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart.c...')
#15 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('checkout.cart.i...')
#16 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.i...')
#17 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(507): Magento\Framework\View\Layout->renderElement('checkout.cart.i...', true)
#18 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-checkout/view/frontend/templates/cart.phtml(15): Magento\Framework\View\Element\AbstractBlock->getChildHtml('with-items')
#19 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/home/193246.cl...')
#20 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart\Interceptor), '/home/193246.cl...', Array)
#21 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView('/home/193246.cl...')
#22 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#23 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(558): Magento\Framework\View\Element\AbstractBlock->toHtml()
#24 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(534): Magento\Framework\View\Layout->_renderBlock('checkout.cart')
#25 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart')
#26 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('checkout.cart')
#27 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('content')
#28 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('content')
#29 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('content')
#30 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('main')
#31 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('main')
#32 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('main')
#33 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('columns')
#34 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('columns')
#35 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('columns')
#36 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('main.content')
#37 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('main.content')
#38 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('main.content')
#39 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('page.wrapper')
#40 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper')
#41 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(585): Magento\Framework\View\Layout->renderElement('page.wrapper')
#42 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(536): Magento\Framework\View\Layout->_renderContainer('root')
#43 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(489): Magento\Framework\View\Layout->renderNonCachedElement('root')
#44 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout.php(954): Magento\Framework\View\Layout->renderElement('root')
#45 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput()
#46 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', Array)
#47 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}()
#48 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/generated/code/Magento/Framework/View/Layout/Interceptor.php(39): Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', Array, Array)
#49 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Result/Page.php(257): Magento\Framework\View\Layout\Interceptor->getOutput()
#50 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Result/Layout.php(170): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#51 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#52 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#53 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#54 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#55 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#56 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#57 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#58 {main}
`