33 votes
Accepted

I want to customize my minicart in Magento 2. I need to add 3 attributes

You can create a module to do this. It will use a plugin to add the attributes to the data array which is read by the knockout js template. Then we need to override the template to display these ...
user avatar
  • 8,819
26 votes
Accepted

Mini-Cart displaying Configurable Product Image instead of simple Product Image Magento 2

You have to do setting from admin panel. GO to Admin panel, Stores -> Configuration -> Sales -> Checkout -> Shopping Cart -> Configurable Product Image Set Product Thumbnail itself from ...
user avatar
20 votes

Magento 2, Change On hover instead of 'click' for mini cart

In the file magento\vendor\magento\module-checkout\view\frontend\templates\cart\minicart.phtml (or an override magento\app\design\frontend\Custom\YourTheme\Magento_Checkout\templates\cart\minicart....
user avatar
  • 1,227
19 votes
Accepted

How to update minicart view using AJAX?

You can try the below code. require([ 'Magento_Customer/js/customer-data' ], function (customerData) { var sections = ['cart']; customerData.invalidate(...
user avatar
17 votes
Accepted

Magento 2 Get Cart Quote Total in minicart.phtml

You have to just keep below line in your minicart.phtml file to get updated subtotal , This Below line is workig for all cases if cache is enable its working fine, <span data-bind="html: ...
user avatar
17 votes
Accepted

How to add "Empty Cart" button to minicart

I have just created a proper module for your question: We need to declare the custom js component and html template: app/code/Vendor/MiniCart/view/frontend/layout/default.xml <?xml version="1.0"?...
user avatar
14 votes
Accepted

remove items from cart in controller - magento2

Your custom controller should be: namespace Gworks\Cart\Controller\Items; use Magento\Framework\App\Action\Context; use Magento\Checkout\Model\Cart as CustomerCart; class Remove extends \Magento\...
user avatar
  • 34.4k
13 votes
Accepted

Adding quantity increment button in cart and mini cart

app/code/Amsi/UserManagement/view/frontend/templates/cart/item/default.phtml I have added For both increment and decrementing quantity. You can add the button ...
user avatar
  • 1,714
12 votes
Accepted

Getting the product SKU in the header mini-cart

As far as I know, the header minicart will get the data from customer data vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js define([ 'uiComponent', 'Magento_Customer/js/...
user avatar
12 votes

Magento 2 Open minicart when item is added

It can be done by simply modifying minicart.js file. Navigate to vendor/magento/Magento_Checkout/view/web/js/view/minicart.js Create override of the file by copy it in your theme folder. Under ...
user avatar
12 votes
Accepted

Magento 2 show normal price with special price on minicart

You dont need to override Renderer.php file in core and you should never do in core. You can just changes in sidebar.phtml file and set your changes. You can get price from below method: $finalPrice ...
user avatar
10 votes

Magento 2 - How to show tax and shipping costs in mini-cart pop up

To show additional stuff or costs in the minicart (like taxes or shipping costs), you need to understand where the data in the minicart comes from. The Customer Data Section Pool If you add a ...
user avatar
  • 11.7k
9 votes

Magento 2 Add to cart frontend event listener

When something is added to the cart, the local storage information is updated and you can subscribe to a knockout observable in the cart section of the customer data to be notified when it's content ...
user avatar
  • 261
9 votes

Magento 2 Get Cart Quote Total in minicart.phtml

We had a similar question from a client. where he wanted to show "[quantity] item [subtotal]" in a styled cart block instead of the default cart icon in the minicart. We found this question here but ...
user avatar
8 votes
Accepted

Magento 2 : How do i ONLY display the number currently in cart?

try this $helper = $this->helper('\Magento\Checkout\Helper\Cart'); echo $helper->getItemsCount();
user avatar
  • 32.1k
8 votes

how to add minicart in custom header block in magento2

Not Tried but you can add directly in phtml with below code <?php echo $this->getLayout() ->createBlock('Magento\Checkout\Block\Cart\Sidebar') ->setTemplate('...
user avatar
  • 32.1k
8 votes

Magento 2: Order Summary expanded on page load?

The full list of options for the collapsible widget can be seen on the dev docs here. Finding the code Navigate to vendor/magento/module-checkout/view/frontend/web/template/summary/cart-items.html ...
user avatar
  • 15.3k
8 votes

Magento 2 minicart does not clear items after checkout

There is a temporary solution for you, we need to override vendor/magento/module-checkout/view/frontend/web/js/view/payment/default.js because if we take a look at this file, we can see: /** ...
user avatar
8 votes
Accepted

Magento 2 : Show cart items total to header cart link

You can display cart items sub-total to header minicart link. Add below code to minicart.phtml to display cart items total <span data-bind="html: getCartParam('subtotal')"></span> php ...
user avatar
8 votes
Accepted

Magento 2 Minicart - Display line item subtotal rather than unit price

You can set line item subtotal using below way, You dont need to use of knockout js anyway you can just setup your goal using below way, You can get item qty using $qty = $item->getQty(); Now just ...
user avatar
8 votes

How to modify minicart.js Magento 2?

You'd better extend the minicart component. For example: app/code/vendor/module/view/frontend/requirejs-config.js var config = { 'config': { 'mixins': { 'Magento_Checkout/js/...
user avatar
  • 760
8 votes

Magento 2.1.9 frontend font icon extend

You need open this website https://icomoon.io/app/#/select Click on Import Icon purple button on the top choose your Luma-Icons.svg file from luma them. You will get all icon Where you can add, edit ...
user avatar
7 votes

Getting the product SKU in the header mini-cart

Firstly, very good explanation from @Khoa TruongDinh about the flow of getting item in minicart template. how can I change them around to add or remove product details? I found a way how you can ...
user avatar
7 votes
Accepted

move minicart to after catalog.topnav magento 2

Why you don't try to move it with xml update. Add this to default.xml layout in your theme: <move element="minicart" destination="navigation.sections" /> The navigation.sections block is ...
user avatar
7 votes
Accepted

How to add Cancel/Ok button within Minicart and remove popup

First of all please override sidebar.js file in your custom theme. So In theme, add a js file sidebar.js to app\design\frontend\[NAMESPACE]\[THEME]\Magento_Checkout\web\js\sidebar.js if not exist ...
user avatar
  • 5,244
7 votes
Accepted

Plus, Minus, automatic cart update on Magento 2.3.3

Override default.html from vendor\magento\module-checkout\view\frontend\web\template\minicart\item\default.html to app\design\yourvendor\yourtheme\Magento_Checkout\web\template\minicart\item\...
user avatar
  • 3,200
6 votes

Form Key Error when removing a product from Mini cart

You have two options, Disable form keys for the remove action. There is no real risk in doing this, the CSRF protection the form keys add have limited scope for damage when removed on cart actions. ...
user avatar
  • 17.5k
6 votes
Accepted

How to override magento-checkout CustomerData/Cart.php?

registration.php file, filepath app/code/Package/Modulename/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar:...
user avatar
6 votes

Magento 2 Get Cart Quote Total in minicart.phtml

This above code will works on the page load, but will not work with magento2 ajax add to cart as it uses Knockout JS now. For that you should use - Override the magento class "\Magento\Checkout\...
user avatar
6 votes
Accepted

Magento2, echo product attribute in minicart

I found the answer to my question in this link DefaultItem.php <?php namespace Your\Module\Plugin; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product; use ...
user avatar
  • 2,009

Only top scored, non community-wiki answers of a minimum length are eligible