Important: This is applicable to users that sell coupon codes from Thinkific with WooCommerce. If you use WooCommerce to create enrollments directly, this is not required.
By default, the WooCommerce email for Thinkific coupon codes requires you to outline how a user should use it to access their content on Thinkific. However, if you want to insert a link in the email such that when a user clicks it, they are directed to Thinkific and the coupon is automatically applied, simple add this code to your functions.php file
Important: WooNinja does not offer support for custom code. Please consult with your developer and always back up your site before making code changes.
<?php
/**
* Adds an additional line to the coupon email to insert the direct to checkout coupon link
* @see https://support.thinkific.com/hc/en-us/articles/360035675974-Share-Links-with-Coupons-Automatically-Applied
*/
add_action( 'thinkific/woocommerce/coupon/email/post', 'custom_wc_thinkific_coupon_email_group_link', 10, 4 );
function custom_wc_thinkific_coupon_email_group_link( $order, $product, $email, $license_keys ) {
$course_id = carbon_get_post_meta( $product->get_id(), 'thinkific_woocommerce_product' );
$link = "https://www.YourThinkificSite.com/enroll/$course_id?th__c=" . reset( $license_keys );
echo "<p>Click here to access: $link </p>";
}
Additional Reading: https://support.thinkific.com/hc/en-us/articles/360035675974-Share-Links-with-Coupons-Automatically-Applied