Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda