Replies: 0
Hi all,
I am trying to limit access to the WooCommerce thank you page so the user can only view it once (At the moment you can paste the URL in another browser and see it still.)
I was thinking of creating/attaching a custom order meta to the order once the thank you page has loaded and then wrapping the whole page template in an if statement that checks if this meta exists. Thus when they paste it into another browser/window the template sees that this metas exists and shows them a different message.
Is this the right way to do it? This is what i have done so far but it doesnt work!
//functions.php
add_action( 'wp_footer', 'hasLoadedPlayPage', 20 );
function hasLoadedPlayPage( $order ){
if( !is_wc_endpoint_url( 'order-received' ) ) return;
$order->update_meta_data('hasLoadedPlayPage', 'Yes');
$order->save();
}
//thankyou.php
$hasAnswered = get_post_meta($order->ID, 'hasLoadedPlayPage', true);
if(! $hasAnswered){
echo "NOT SEEN";
} else {
echo "SEEN";
}
Any guidance anyone could give me would be greatly appreciated!
Thanks
James