Background
We have changed the checkout process slightly in WooCommerce
Usually, a user goes: Order Checkout --> Thank you Page (where Order ID
appears) --> Upsell page
Now it goes like this: Order Checkout --> Upsell Page
This redirect is achieved using this script:
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'https://website.com/upsell/' );
exit;
}
}
Question
The issue here is that I can't extract Order ID
from the DOM in the Thank You page because after checkout we immediately redirect users to the Upsell page.
So is there a way to push the Order ID
into a Javascript variable on the Upsell Page?
Thank you.