I have a Commerce Demo site that uses the off canvas flyout cart and I am using the Commerce Simple Stock module to stop items being sold if they are out of stock.

The module changes the stock number and prevents the item being loaded to the cart if already purchased. It sends user/status messages and removes the add to cart button using commerce_simple_stock_form_commerce_order_item_add_to_cart_form_alter().

This hook doesn't work for the Commerce Demo form.

The theme hook for the Add to cart button in Commerce Demo is commerce_cart_flyout_add_to_cart_button().

The stock status messages show on the admin pages but not on the product page itself.

How do I hook the stock status message from the module to the product page?

  • 1
    What do you mean by "hook the stock status message from the module to the product page"? It's not clear to me what the goal is. Jan 13, 2021 at 8:58
  • 1
    Do you see any system messages on your product page? I.e. is the issue really that no system messages appear on those pages?
    – sonfd
    Jan 13, 2021 at 11:05
  • @sonfd The system messages are showing up when you go to the admin panel but not on the actual product page itself. It is as though the template for the product is not picking up the system message
    – Robbozinoz
    Jan 14, 2021 at 0:40
  • @PatrickKenny the template that is showing the product (which includes the add to cart button) is not showing the system message that the stock level is at 0. This system message is showing on other parts of the site but not the page I want it to.
    – Robbozinoz
    Jan 14, 2021 at 0:43

1 Answer 1


System Messages are printed to the page via a block (Block: Messages, Category: System).

Screenshot of the Drupal "Place Block" dialogue showing the "System Messages" block

If the messages block isn't aren't appearing on a particular page:

  1. Check to make sure the block is added to a region in the active theme for the page in question.
  2. Check to make sure any visibility settings for the block are configured correctly for the target audience
  3. Make sure that your theme actually renders the region that you added the block to.

If you're still not seeing the messages block:

  1. Create a static custom block (something that should always appear) and place it in the region.
  2. Test with the block added to a region you know is rendering, i.e. the main content region.
  3. Inspect the source html of the page to make sure the html is actually missing and isn't just being hidden by css.
  4. Enable twig_debug and verify that the page is built with the templates you think it is. Check each template (Page, Region, Block, potentially others, but it would likely be one of these that's the issue) and make sure the template is properly rendering what it needs to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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