Redeem Now
Read More
Read now
Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-hyperlocal-marketplace-guide

    How to add more product information on checkout cart in magento2

    How to add more product information on checkout cart in magento2 – IF there is a need to add some more information on per products in checkout cart page in magento2 and have difficulty to implement it then the solution is here. You can easily add custom information to cart products by following this post. For this just need to do some easy changes here-

    1. Step 1 – Call your block and template file to checkout_cart_index.xml inside your magento2 module layout folder.
    2. Step 2 – Now Prepare the block file –
    3. Step 3 – Prepare additional information template file additionalinfo.phtml –
    4. Now you will see the cart page like –

    So in this way you can display additional product information to your cart page.

    . . .

    Leave a Comment

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


    9 comments

  • sethhu
    i copy you file and change the namespace,but it’s not working for me,the error is Notice: Undefined index: class in /var/www/html/magento/vendor/magento/framework/View/Layout/Generator/Block.php on line 213.but use your module,it’s working… XD….
  • Michał Michalski
    Don’t know where should I put those files.
    • Pooja Sahu
      Hello Michal,
      In the given post we are creating a module Webkul_Grid, and here we explained if there is need to add some additional info per item in checkout cart page then how we can add this. So for this we are creating a file checkout_cart_index.xml in path Webkul/Grid/view/frontend/layout/ and then creating a block file AdditionalProInfo.php in path WebkulGridBlockAdditionalProInfo and a template file additionalinfo.phtml in path Webkul/Grid/view/frontend/template .
      Here Vendor name – Webkul, Module name – Grid
      Hope now you understand the location of files. If still have issue please feel free to ask.
      Thanks!
      • Michał Michalski
        Thank you for reply. It seems that I did everything correctly. So why do I get this error:

        Notice: Undefined index: class in /home/xxxxxx/NetBeansProjects/meblomat/vendor/magento/framework/View/Layout/Generator/Block.php on line 213
        #0 /home/xxxxxxx/NetBeansProjects/meblomat/vendor/magento/framework/View/Layout/Generator/Block.php(213): MagentoFrameworkAppErrorHandler->handler(8, ‘Undefined index…’, ‘/home/xxxxxx/N…’, 213, Array)

        • Pooja Sahu
          Hello Michal,
          It looks like there is some error in your module’s block file, so please debug your block file properly.
          Thanks!
          • Michał Michalski
            I really doubt that I made mistake. Here is my code:

            <?php
            namespace CodemakeConfiguratorFurnitureBlock;

            /**
            * AdditionalProInfo
            */
            class AdditionalProInfo extends MagentoFrameworkViewElementTemplate
            {
            /**
            * @param MagentoFrameworkViewElementTemplateContext $context
            * @param array $data
            */
            public function __construct(
            MagentoFrameworkViewElementTemplateContext $context,
            array $data = []
            ) {
            parent::__construct($context, $data);
            }

            /**
            * @return $this
            */
            protected function _prepareLayout()
            {
            parent::_prepareLayout();
            }

            /**
            * @return additional information data
            */
            public function getAdditionalData()
            {
            // Do your code here
            return "Additional Informations";
            }
            }

          • Pooja Sahu
            Hello Michal,
            Please follow the module https://github.com/webkul/magento2_cartPageAdditionalInfo .
            Thanks!
          • Michał Michalski
            Although I can’t use this module in my vendor directory(yes I have changed namespaces). I suppose I have a bug somewhere in my code. So I will use it in a separate vendor.
            Thank you very much.
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close