Hi, there seems to be a bit of a problem with the shopping cart block still rendering even though the cart is empty. It seems to be adding the classes so the following html is outputted:

I'm new to D8 and twig, but when I dump the content variable in the region.html.twig template, I get the following:

object(Drupal\Core\Render\Markup)#3741 (1) { ["string":protected]=> string(170) "" }

Any ideas anyone?

Comments

roblog created an issue. See original summary.

TR’s picture

Status: Active » Postponed (maintainer needs more info)

You're going to have to provide more information - I don't know what you're looking at and why you think something is wrong.

By default, the cart block will always render. When the cart is empty, you should still see the block with the block title. The body should either be expanded or collapsed depending on your settings, and the body should display the string "There are no products in your shopping cart". The template that controls the cart block display is uc_cart/templates/uc-cart-block.html.twig

If you have gone into the block settings at /admin/structure/block/manage/shoppingcart and selected the option "Hide block if cart is empty.", then the block won't display when the cart is empty. I have checked this on a live site with the Bartik theme, and no markup is output for the cart block if this option is checked and the cart is empty. Bartik, the default theme, doesn't have its own region.html.twig. But if you look at the "stable" theme in its region.html.twig, you will see a conditional which tests if the content variable is empty and only generates markup if it is not empty. (An empty string, "", evaluates to false, or empty). If you are writing your own region.html.twig you should do something similar.

TR’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further information provided.