0

I have overridden

\vendor\magento\module-checkout\CustomerData\Cart.php

file in my custom plugin using di.xml using below code:

<preference for="Magento\Checkout\CustomerData\Cart"
                 type="Vendor\Package\CustomerData\Cart" />

It's working too. I can get SectionData defined in my custom Cart.php file in Minicart successfully.

but this removes Total from my Minicart which was working fine with default Cart.php.

Please suggest if i am doing something wrong in overriding file.

Reference image

0

I solved this issue by following method:

File: di.xml

 <type name="Magento\Checkout\CustomerData\Cart">
      <plugin name="CustomMiniCart" type="Vendor\Package\CustomerData\Cart" sortOrder="1"/>
 </type>

File:Vendor\Package\CustomerData\Cart.php

namespace Vendor\Package\CustomerData;
class Cart
{
    public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)
    {

        $result['customdata1'] = $customvalue1;
        $result['customdata2'] =  $customvalue2;
        return $result;
    }  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.