1

I am having problems with understanding if my hook is activating/running. I have watched and read many things about hooks but until I get something to work I am very confused.

I'm trying to use the hook here: http://api.drupalcommerce.org/api/Drupal%20Commerce/sites!all!modules!commerce!modules!checkout!commerce_checkout.api.php/function/hook_commerce_checkout_pane_info_alter/DC

/*  Hello World
*/
function commerce_admam_commerce_checkout_pane_info_alter(&$checkout_pane) 
{
dpm("hi");
}

All I want to have happen on checkout is to see if that message shows up. I have tried other hooks as well. MY filename is commerce_admam.module and it's enabled in the backend. I can move the dpm() out of the hook and it fires off the message (everywhere though because its running it all the time)

1 Answer 1

2

dpm and dsm can be a little tricky in some hooks, and you may need to time a cache clear with a page reload to see them fire.

Better to use something like watchdog or actually alter the page content.

Your function looks good, so try this from the example module. More chance of seeing the effect:

function checkout_pane_example_commerce_checkout_pane_info_alter(&$panes) {
  if (!empty($panes['cart_contents'])) {
    // Change the title of the "Cart Contents" pane.
    $panes['cart_contents']['title'] = t('Your big wonderful shopping cart brimming over with shopaholic nonsense');
  }
}
4
  • Thank you very much mediaashley, your code wasn't showing up either and then I cleared cached. Slightly offtopic, but is clearing the cache everytime commonplace for drupal developers? I have everything unchecked too in the performance panel. Thx again
    – SD Dev
    Jan 13, 2016 at 11:29
  • 1
    Haha! Sorry, I didn't realise you were that new :D. Short answer, yes! Whenever something isn't there, doesn't work, or you have to blow your nose… clear the cache. The first response to any Drupal question is "have you cleared the cache?" If you have a function that is working, like this one now is, or you edit a template file, you shouldn't need to clear the cache to see changes. If you add something new, then you do. Sometimes you need to clear the registry too. You should set up Drush, then these are as easy as drush cc all and drush rr. drush cc will show you all the caches too, Jan 13, 2016 at 11:35
  • haha thank you I have drush setup and its a lot easier then going to the dang panel everytime. Have a good one
    – SD Dev
    Jan 13, 2016 at 11:39
  • @SDDev as an alternative to using watchdog() (which you can view via drush but is still a bit cumbersome imho) you can use dd() (comes with devel) which writes to a file called drupal_debug.txt in the temp directory (as configured in Drupal).
    – Andy
    Jan 13, 2016 at 11:51

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.