M
M
matros972019-08-22 10:13:16
WordPress
matros97, 2019-08-22 10:13:16

How to store the value as a variable for another page?

Hello, upon successful payment in Woocommerce, I should be redirected to another page, I did it like this in the thankyou.php template

<?php


if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

if($_GET['key'])
{
  
  //echo $order->get_order_number();

  set_query_var('numberorder', $order->get_order_number());
  //exit;

  wp_redirect(home_url('thankyou'));
  exit;
}
?>

I will call the page on which the redirect is going like this
<span class="order-number"><?php echo $numberorder; ?></span>

But nothing is saved, yesterday I tried both global and the session does not save for some reason the value how can I fix it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matros97, 2019-08-22
@matros97

This is how I tried

`if($_GET['key'])
{
  
  //echo $order->get_order_number();

  //set_query_var('numberorder', $order->get_order_number());
  //exit;

  $_SESSION['numberorder'] = $order->get_order_number();

  wp_redirect(home_url('thankyou'));
  exit;
}
?>`
`

<?php echo $_SESSION['numberorder']; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question