I am using commerce checkout progress module for showing the checkout progress to the user.enter image description here

I am showing this block in cart page also. I want to hide this block if the cart is empty. How can I achieve it?


The Drupal cart is a view. As such, only the view is aware of the amount of products in the cart and it might be tricky to get the amount of products in the cart. (it can be done by using php, load the order, count the products etc... but it would involve some coding.)

I suppose the easiest way would be to alter the Drupal commerce cart view. Then use the Views Block Area module to place the progress block in the Views header. If you leave the Display even if the View has no results unchecked. It should not render on empty carts.

Additionally you will have to remove the cart page block you set via the blocks administration page from the cart page.

enter image description here

You can do that by showing the block on all page except cart. The View will take care of it on that page.


Finally found the solution for this. Below code removes the payment tab.

function example_module_commerce_checkout_progress_items_alter(&$items) {

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.