0

How can I set a Drupal Commerce shopping cart block to only display if it contains items? I'd like to hide the cart block when the cart is empty.

  • Please explain your answer so that someone in the community can understand. – niksmac Nov 25 '12 at 14:30
5

Here is the solution. Add these lines in template.php file of a theme you`re using. Change THEMENAME on the name of your theme.

function THEMENAME_commerce_cart_empty_block() {
  return '';
}
1

The solution that worked for me is not just hiding this "your shopping cart is empty" but also hiding all possible long list of items. And you can accomplish this using views:

  • create two fields of text links, one for view cart and another for checkout.
  • Add another field to display the total amount. Look for "add commerce order: order total" I got this idea from this
  • Filter criteria: commerce order to >=1. This will make block disappear when the order is greater than 1.
  • Apply some css.

drupal commerce: create block to display total order with links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.