Run Some Javascript Code After Step 2 Of Checkout

can some one tell me what is the hook which i can use to run some javascript code after the user enters the address on checkout step 2 and presses continue.

i need the tpl file name / hook name.

design/themes/[your theme]/templates/addons/my_changes/hooks/checkout/

with content something like:


Much easier to do these type of actions in the backend if whatever API you're using has an API.

This would be specific to step_two of checkout.

Hi tbirn,

thanks for the answer.

I have a query in this. What i need to achieve is that once the user presses the continue button after filling the address i run some javascript code and call an api.

What the code above mentions is the blur function for address field. I need to run the code post the user has submitted the correct address and before showing the third step.

I would do it in the backend on the POSTed data then.

However, if the only api you have available to you is Javascript, you'd have to set a 'click' event on the button to do your work. Unfortuntaely, the buttons aren't generally tied to a step so you'd have to be a bit more creative. You'l have to get the 'step' parameter from the querystring and assign it to something like 'step'.

Then you'd have your click event setup like (UNTESTED)

$('button[name="dispatch[checkout.update_steps]"]').click(function() {
  var step = whatever_you_use_to_get_the_step_from_url();
  if( step == "step_two" ) {
    // Do whatever you want here
  return true;

But again, if you have a non-JS API you can use, I'd certainly do this on the backend. It will be quicker, simpler and probably offer greater flexibility in getting other data about the user.

You can also use form callbacks which are described on the following page (see the Form processing section)