Show Referral link and social icons on the Orders Thank You page

READ FIRST: This code needs to be added at the end of the functions.php file. If you are familiar with editing functions.php, feel free to continue reading. If you haven't done this before, adding this code in wrong place might bring the site down and the only way to access it is by editing functions.php file again via FTP. Feel free to contact us if you need help!

If you want to show customers referral link with social sharing option on the Thank you page after they make an order, add below code to functions.php.

// Show shortcode in the thank you page
function show_referral_link(){
	echo "<h2>Refer a friend</h2><p>Refer a friend and earn rewards.</p>";
	echo do_shortcode('[WOO_GENS_RAF_ADVANCE guest_text="Text to show when user is not logged in"]');

Of course, don't forget to change guest_text shortcode parameters, which is text that will appear to users that are not logged in. 

If you are using guest feature, add below code to functions.php as well. This will allow them to get links without adding email again.

add_action('woocommerce_checkout_update_order_meta', 'saveOrderEmail');
function saveOrderEmail($order_id){
	$order = new WC_Order( $order_id );
	$user_email	= ( version_compare( WC_VERSION, '2.7', '<' ) ) ? $order->billing_email : $order->get_billing_email();	
	setcookie('gens_raf_guest', $user_email, time()+60*60*24*30, '/');
Thank you page is just an example, you can use the same function but change the action to place advance shortcode anywhere else on the site. 

Still need help? Contact Us Contact Us