- Issue created by @antiden
The module is designed to use transitions as part of the core workflows module, so you'd need to transition the state from one to the other, rather than simply change the workflow state. So, you'd have a transition from "unpaid" to "paid", say "mark as paid", and you'd run that on the submission at the point of payment.
Then, there is a function on the workflows manager service to help do that:
$workflowsManager = Drupal::service('webform_workflows_element.manager'); $element_id = 'workflow'; $transition_id = 'mark_as_paid'; $log_message = 'Paid in order ' . $order->getOrderNumber(); $success = $workflowsManager->runTransition($webform_submission, $element_id, $transition_id, $log_message); if ($success) { $webform_submission->save(); }
- 🇷🇺Russia antiden
Thanks for your answer, but I get an error. Transition name: paid (from Pay to Paid). My code:
$workflowsManager = Drupal::service('webform_workflows_element.manager'); $element_id = 'workflow'; $transition_id = 'paid'; $log_message = 'Paid in order ' . $order->getOrderNumber(); $success = $workflowsManager->runTransition($webform_submission, $element_id, $transition_id, $log_message); if ($success) { $webform_submission->save(); }
Error: Call to undefined method Drupal\webform_workflows_element\Service\WebformWorkflowsManager::runTransition()...
Ah, it only exists in the dev version. If you're using the current alpha, you may need to use runTransitionOnElementValue and then look at the logic in the dev version for runTransition to do the transition on the element: https://git.drupalcode.org/project/webform_workflows_element/-/blob/1.0....
- 🇷🇺Russia antiden
Yay, installed dev version, and
runTransition()
it worked. Big thx!