Managing Magento 2 Mini Cart

Suppose we have the following two requirements:

  •  disable window scroll if the Mini Cart block is activated
  •  do not display more than three items

These are minor requirements, and not particularly practical, but, once done, you will have some insides in Magento 2 UI components.

Our use case is: add any product to the cart and position yourself on any front-end page (but not the checkout).

pic-1

You will notice in the right upper corner the Minicart is showing a count of the items in cart. Clicking on that cart icon results in displaying the block with full details.

pic-2

Clicking then away closes that block.

The following few articles will guide you through achieving the two simple requirements that are imagined with the idea to try to offer more than one approach and/or solution.

Assuming you’ve completed the articles listed above, I will touch on two more interesting topics to try to complete the picture for the front-end implementation

Finally, you must have noticed by now that neither there is one solution to a given problem,  nor a clear end of how some default software like Knockout is extended and thus used.

That is why it is likely that very little from here could be applicable to your next problem directly, but I certainly hope I have helped you to better understand the insides about the Magento 2.2 Minicart.

Thank you for reading.