1

I need to send out a PDF via mail upon order completion, and according to DrupalContrib, I can use hook_commerce_checkout($order) to achieve this.

this is my module code:

<?php

function pdf_checkout_commerce_checkout_complete($order) {
  // No example.
  \Drupal::logger('pdf_checkout')->info('Hook called.');
}

My problem is, that it is never called, I've tried everything from just sending a log message when it is used, to creating a new, clean, module just to test it.
None of it has worked.

Is the hook still being used in Commerce 2.x? If not, what should I look at instead to achieve a similar effect?

Thanks in advance.

  • can you please show your exact code in the custom module ? – O V Apr 3 '17 at 10:22
  • @OlegVidenov, added, it's not much, as I've disabled my previous module and now only run this extremely short one, it only serves the purpose to send a log message if the hook is called, which it doesn't. – Dion S. Jensen Apr 3 '17 at 11:01
  • that is weird. drupalcontrib.org/api/drupal/… , can you just as test add if any code there is still executed ? – O V Apr 3 '17 at 12:20
  • as a test, can you make some syntax error in your module, just to ensure the code is being read at all – O V Apr 3 '17 at 12:21
  • @OlegVidenov, removed the semicolon, gave me a ParseError: syntax error message about it, so the module is being read. I can Zip and link my module, but it is literally only the code mentioned above. – Dion S. Jensen Apr 3 '17 at 12:40
3

Is the hook still being used in Commerce 2.x?

No.

If not, what should I look at instead to achieve a similar effect?

Commerce 8.x-2.x depends on the state_machine module which has events that are triggered when an order is placed (=checkout complete) as well as other state changes.

See Assigning (adding) an entity reference when an Order process is completed

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.