We searched high and low for this code and then finally found a few clues. From these clues we pieced together our custom auto-populated order values for a completed order WooCommerce thank you page Shopped Approved code.
This page here was a very handy resource for all the $order values available to us to call on for the thank you page. Shopped Approved can auto-populate some fields to make the initial survey easier and faster to complete and automatically email customers the follow up emails.
Calling on a few of the values found at the link above and adding a few <?php echo … ?>, we were able to successfully auto-populate the Shopped Approved initial survey on WooCommerce.
We used:
- $order->get_order_number();
- $order->get_billing_first_name();
- $order->get_billing_last_name();
- $order->get_billing_email();
- $order->get_billing_country();
- $order->get_billing_state();
So a completed thank you page code would be (where x’s are your site ID and token as provided by Shopper Approved):
<script type=”text/javascript”> var sa_values = { “site”:xxxxx, “token”:”xxxxxxxx”, ‘orderid’:'<?php echo $order->get_order_number(); ?>’, ‘name’:'<?php echo $order->get_billing_first_name(); ?> <?php echo $order->get_billing_last_name(); ?>’, ’email’:'<?php echo $order->get_billing_email(); ?>’, ‘country’:'<?php echo $order->get_billing_country(); ?>’, ‘state’:'<?php echo $order->get_billing_state(); ?>’ }; function saLoadScript(src) { var js = window.document.createElement(“script”); js.src = src; js.type = “text/javascript”; document.getElementsByTagName(“head”)[0].appendChild(js); } var d = new Date(); if (d.getTime() – 172800000 > 1477399567000) saLoadScript(“//www.shopperapproved.com/thankyou/rate/xxxxx.js”); else saLoadScript(“//direct.shopperapproved.com/thankyou/rate/xxxxx.js?d=” + d.getTime()); </script>
This code is inserted on a custom thank you page template in your theme’s folder. There are a lot of resources on how to create a custom thank you page.
This is the method we used to auto-populate order values on Green Water Sports.