$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>woocommerce offtopic - Run function on "Place Order"|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

woocommerce offtopic - Run function on "Place Order"

matteradmin9PV0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

I'm building a custom checkout, that uses steps, like those used on Apple.

.jpg

When an input field is marked as invalid, I would like the affected sections to expand again. I can't seem to get the function running on click though.

The test code is very basic. Any why this would not be working? It does work if I change the .click to use the body element, for example.

jQuery('#place_order').click(function(){

  if(jQuery('p#billing_last_name_field').hasClass('woocommerce-invalid')) {
    alert('INVALID');
  } else {
    alert('VALID');
  }

});
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 3 years ago.

Improve this question

I'm building a custom checkout, that uses steps, like those used on Apple.

http://www.formisimo/blog/wp-content/uploads/2013/09/Apple-stage-one.jpg

When an input field is marked as invalid, I would like the affected sections to expand again. I can't seem to get the function running on click though.

The test code is very basic. Any why this would not be working? It does work if I change the .click to use the body element, for example.

jQuery('#place_order').click(function(){

  if(jQuery('p#billing_last_name_field').hasClass('woocommerce-invalid')) {
    alert('INVALID');
  } else {
    alert('VALID');
  }

});
Share Improve this question asked Sep 5, 2015 at 10:39 user1235285user1235285 1531 gold badge3 silver badges10 bronze badges 2
  • the trigger ('#place_order').click is too soon, the validation is made later. try the trigger $(document.body).on("update_checkout", ... – mmm Commented Sep 5, 2015 at 18:42
  • generic JS, WooCommerce and other 3rd party plugin/theme dev support is off topic and not in this stacks scope. You should ask via their official support routes or in their groups and communities. – Tom J Nowell Commented Oct 18, 2021 at 22:44
Add a comment  | 

1 Answer 1

Reset to default 3

As it was already noted by @mmm, your click event is placed too soon. Try with a submit trigger, as suggested in a similar StackOverflow answer:

jQuery(document).ready(function($) {
    jQuery("form.woocommerce-checkout").on('submit', function() {
        ... your code here ...
    });
});
Post a comment

comment list (0)

  1. No comments so far