Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda