1

I have checkout function which uses drupal_goto to redirect to the confirmation page after validating all info. I want to redirect to the confirmation page before all validation. Then in the background I need it to complete all validation and email me any errors.

Problem is, drupal_goto calls drupal_exit so all further code stops running. I can implement my own goto function without the exit but then it won't redirect until all validation is completed. I need validation to run in the background after the redirect.

0

During checkout, you'll need to create a transaction because the order needs to be paid before it is actually completed. If you're needing to do other processing, you might consider looking at the architecture of Commerce License, where a license can have a post-checkout set of processes.

The short version of it looks like this:

  1. You create the license or the "queue item" that needs to process.
  2. Redirect to the completion page.
  3. Have an AJAX watcher that looks for the completion of whatever needs to be done (could be handled by queues or some external system that updates state on the site).
  4. Use JavaScript to take action.
  • Thanks. Could be I wasn't clear enough but what I wanted was "redirect to the confirmation page before all validation" meaning I want to redirect regardless of all validation and processing, and only after the redirect should it do all processing. – Efraim Apr 26 '16 at 14:27
  • I will probably need to either trigger a rule to run after checkout or I will run the checkout process on the confirmation page instead of the checkout page. – Efraim Apr 26 '16 at 14:29
  • Ah, I see that now. What do you then consider "validation"? When you've completed... validating that the payment is completed? Or do you have another process in the background that you're wanting to store? – nvahalik Apr 26 '16 at 14:30
  • I have a few processes that run. Including payment, bookings with third party APIs etc. – Efraim Apr 26 '16 at 14:39

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.