Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
How to get order number after submitting form via ajax?

The order is created after the form is submitted.

 add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
     <script>
                         
document.addEventListener( 'wpcf7submit', function( event ) {
    var inputs = event.detail.inputs;
    console.log(inputs);
}, false );
           </script>   

       <?php  }

I need to get the order number immediately after it is created from the form

add_action('wp_ajax_hello', 'say_hello1');
add_action('wp_ajax_nopriv_hello', 'say_hello1');

function say_hello1() {
    if (empty ( $_POST['order_id'])) {
    $order_id = absint( get_query_var('view-order') );
    $testart = $order_id;
    } else {
        $testart = ( $_POST['order_id']);
    }

    
    echo "Проверка, $testart!";
    wp_die();
}

I'm trying to get the order number when clicking on the submit form so that I can tell it to the customer. I can't do anything.

add_action( 'wp_footer', 'my_action_javascript25', 99 );

function my_action_javascript25() {
    ?>
    <script>
    document.addEventListener( 'wpcf7submit', function( event ) {
        var datax = {
            action: 'hello',
            order_id: 'testpage'
        };
        jQuery.post( ajaxurl, datax, function( response ){
            alert( 'Получено с сервера: ' + response );
        } );
    } );
    </script>
    <?php
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!