Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Run Some Javascript Code After Step 2 Of Checkout Rate Topic   - - - - -

 
  • technoob
  • Senior Member
  • Trial users
  • Join Date: 08-Jun 15
  • 286 posts

Posted 11 August 2017 - 03:02 PM #1

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,894 posts

Posted 11 August 2017 - 06:12 PM #2

design/themes/[your theme]/templates/addons/my_changes/hooks/checkout/step_two_edit_link_title.post.tpl

 

with content something like:

<script type="text/javascript" class="cm-ajax-force">
$('input[name="user_data[b_address]"]').blur(function() {
  // your code here
});
</script>

NOT TESTED

 

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • technoob
  • Senior Member
  • Trial users
  • Join Date: 08-Jun 15
  • 286 posts

Posted 12 August 2017 - 12:26 PM #3

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 9,894 posts

Posted 13 August 2017 - 08:07 PM #4

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 14,955 posts

Posted 14 August 2017 - 07:50 AM #5

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

 

http://docs.cs-cart....croformats.html


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия