1

Curious if there is a way to fire order confirmation emails immediately? Basically how this was handled in Commerce 2.

There are cases, and I'm dealing with one currently, where there is no command line access to the hosting or the possibility of setting up cron jobs and the likes to trigger the queue on an interval...

Is there a workaround?

1

There are a couple of options here.

Number 1

If you have the config setting runQueueAutomatically set to false you could call the controller action queue/run via ajax from your success page. This would trigger the queue to run.

Number 2

You can use the EVENT_AFTER_COMPLETE_ORDER event to run some custom code, in a module or plugin. In that code you can include Craft::$app->getQueue()->run() this will also trigger the queue to run. e.g.

Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e) {
    Craft::$app->getQueue()->run();
});
|improve this answer|||||
  • I'm not extremely adept with the yii/php side of things in Craft, I'm assuming this would need to be wrapped into a module's functionality. – Anders Apr 1 at 2:13
  • ... Meaning inside an init() function or something like that. – Anders Apr 1 at 4:46
  • Yea @Anders that is right 👍 – nfourtythree Apr 2 at 7:32
  • Figured it out, thanks! – Anders Apr 2 at 21:33
  • Can you share your solution? – Wonko Apr 3 at 15:49

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.