I have an e-Commerce site (Drupal 8 and Ubercart) and I have a block that shows how many items and what dollar value are in the shopping cart. This is useful if the user is buying something and has items in the shopping cart, but if not, it seems to be, at best, unnecessary. I'm looking for ways to basically do an "If/Then/else", "If" the shopping cart has something in it, "Then" display this block, "Else" don't show the block.

Thanks in advance for your help.

Comments

sachinsuryavanshi’s picture

Hi,

Since you want conditional base and dynamic content to show and hide in a block.
I will suggest to go for custom block and handle UI with result data set.

OR

Create views as block for your block and then
1. Go to the advanced tab of you view
2. Add contextual filters
3. Select Global: Null
4. WHEN THE FILTER VALUE IS NOT AVAILABLE: Select 'Hide view'

Thanks,
Sachin