title: Using update_meta_data on WooCommerce thank you page
body: <p>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.)</p>
  
  <p>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.</p>
  
  <p>Is this the right way to do it? This is what i have done so far but it doesnt work!</p>
  
  <pre><code>//functions.php
  add_action( 'wp_footer', 'hasLoadedPlayPage', 20 );
  function hasLoadedPlayPage( $order ){
  if( !is_wc_endpoint_url( 'order-received' ) ) return;
  $order-&gt;update_meta_data('hasLoadedPlayPage', 'Yes');
  $order-&gt;save();
  }
  
  //thankyou.php
  $hasAnswered = get_post_meta($order-&gt;ID, 'hasLoadedPlayPage', true);
  if(! $hasAnswered){
  echo "NOT SEEN";
  } else {
  echo "SEEN";
  }
  </code></pre>
  
  <p>Any guidance anyone could give me would be greatly appreciated!</p>
  
  <p>Thanks</p>
  
  <p>James</p>