Hiding an Empty Cart with a Custom Helper

Learn to add different checks to the cart by using custom helper methods.

Hiding empty cart

The customer has one last request. Right now, even carts with nothing in them are displayed in the sidebar. Can we arrange for the cart to appear only when it has some content? But of course!

In fact, we have a number of options. The simplest is to include the HTML for the cart only if the cart has something in it. We can do this completely within the _cart partial:

Get hands-on with 1400+ tech skills courses.