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
}