I am using commerce checkout progress module for showing the checkout progress to the user.
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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI am using commerce checkout progress module for showing the checkout progress to the user.
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.
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) {
unset($items['payment']);
}