1

I'm trying to develop a new module but just can't get the correct solution, I hope you can help me.

On the checkout complete page i need the order object with all information of the just created order to print out an javascript code which will be created with the order data and execute when the user completes the checkout process. With the hook "myModule_footer" I am getting into the footer to print my code and with "arg(2)" I can check if the URL is "complete". But now I need to get the order object but I just can't find the right way to do it.

I also tried other hooks like "myModule_checkout_complete" but they won't work:

function myModule_checkout_complete($order, $account) {
drupal_set_message('It works');
}

Is there an better solution to hook into the checkout complete page, get the order object and return some code to the frontend?

Thanks

0

The hook hook_uc_checkout_complete() is the function you're looking for. However, you're going to have problems here since the function runs after the page display.

One way to get around this is override the theme function on the complete sale page:

function THEME_uc_cart_complete_sale($variables) {
  $order_json = json_encode($variables['order']);
  drupal_add_js('jQuery(document).ready(function () { var order = '.$order_json.'; console.log(order); });','inline');

  return $variables['message'];
}

This will execute JS code with the order object upon sale completion.

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.