TABLE OF CONTENTS
- Finding the order confirmation email template
- Editing the code
- Finding the right place to add new code
- How to add a new entry in the code
- Adding a tag to the product
- Insert the new product's tag into the code
- Link the Moodle Course
- Setup the Enrolment Key method for the course
- Replace the enrolment key into the Shopify order confirmation email code
- Save and Test
We have modified the email to include a lengthly bit of conditional logic to look for specific products that exist within a customer's order. If the order contains a product which has a course link and enrollment key you're wanting to give immediate access to, then it will display near the top of the confirmation email.
Finding the order confirmation email template
Editing the code
Click on the "Edit Code" button at the top right, then you'll see the liquid code. "Liquid" is Shopify's theme templating language. Syntax is very similar to HTML, but uses a lot of curly braces {} and allows for objects and variables, similar to Javascript and other object-oriented languages.
Finding the right place to add new code
From there, you'll see an area that has been sectioned off between two comments. At the time of writing this article, the comment within the Shopify code editor begins on line 9, and the end comment is on line 113.
{% comment %} ZV - BEGIN section to include enrollment keys and links to courses if purchased {% endcomment %} - content here - {% comment %} ZV - END section to include enrollment keys and links to courses if purchased {% endcomment %}
How to add a new entry in the code
{% elsif tag contains "Universal Sources Bundle" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access.</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p>
Take care to notice the general structure for each section.
Course Access (h3 title)
Below you'll find the link to the courses and enrollment keys to gain access. (h4 description)
Hyperlinked text to the course which corresponds to the product they just purchased. (<p><a></a></p>)
Include the enrollment key so they can get access (<p><b></b></p>)
The link and enrollment keys can be repeated as many times as needed to include links to all courses the user needs access to. For example, a bundle product with 3 courses in it should have 3 sets of the link and enrollment key lines of code. Each set should refer to a course and the enrollment key needed to access the course.
{% elsif tag == "Universal Sources Bundle" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href="https://learn.capablelife.com/course/view.php?id=17">Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19">Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p> {% elsif tag == "Universal Sources Bundle" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p>
Adding a tag to the product
Insert the new product's tag into the code
{% elsif tag == "Universal Sources Bundle" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p> {% elsif tag == "New Product Tag Here" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p>
Link the Moodle Course
In another browser tab, navigate to Moodle. Once logged in, go to the desired course which corresponds to the Shopify product.
While you are on the course page, copy the URL in the browser URL bar.
With the URL still in your clipboard, go back to the other browsing tab with the Shopify code editor for the order confirmation email.
Find the anchor tag which wraps to the "Link to 'course name here'". Replace the contents between the quotation marks within the anchor tag with the URL that was recently copied from Moodle. While you are there, replace the text within the >< to say the new course.
Note: Shopify's code editor is very picky at times. Make sure the "" you use are the straight-down type, not slanted. Links contained by slanted quotes will not work properly in Liquid.
<p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p>
Setup the Enrolment Key method for the course
Back in the Moodle tab, on the desired course page, click on the "Participants" link at the top of the course page.
Then, click on the dropdown that says "Enrolled Users". While options are expanded, click on "Enrolment Methods".
While on the Enrolment Methods page, try to find a "Self Enrolment (Student)" entry. If there is an entry there, click on the edit button at the right side of the line item. If there isn't one, create a new one. To do this, click on the dropdown at the bottom of the page which says "Add Method", then click "Self Enrolment".
Find where it says "Enrolment Key", then reveal the key which was established for this course. Copy the key. Our typical convention with these has been a 4-digit pin, so as to not be obnoxious for users to attempt filling in.
Replace the enrolment key into the Shopify order confirmation email code
With the enrolment key for the course still on the clipboard, go back to the other tab with the Shopify order confirmation email code editor open.
Paste the key to replace the contents of the previous enrolment key. This new key should directly correspond to the link which it's granting access to. The link which was replaced just two steps before this.
{% elsif tag == "Universal Sources Bundle" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p> {% elsif tag == "New Product Tag Here" %} <h3>Course Access</h3> <h4>Below you'll find the link to the courses and enrollment keys to gain access</h4> <p><a href=”https://learn.capablelife.com/course/view.php?id=17”>Link to Universal Sources of Anxiety Part 1</a></p> <p>Use the enrollment key to gain access: <b>1778</b></p> <p><a href="https://learn.capablelife.com/course/view.php?id=19”>Link to Universal Sources of Anxiety Part 2</a></p> <p>Use the enrollment key to gain access: <b>1505</b></p>
If this product is a bundle, and you wish to link multiple courses, then repeat the steps until each course has a link presented and enrollment key in the order confirmation email.
Save and Test
Once you are finished duplicating a section of code for a new condition, replacing the tag with the relevant product tag, and replacing the links and enrolment keys to reflect the new course, scroll up and click the save button. Exit the settings and go to discounts.
Setup a discount so you can easily purchase a product for free. Make this discount for the new product which you have just included in the conditional logic within the order confirmation email. Place an order as any customer would on your website and use the code, so that your order total is free.
Check the inbox for the email which you included in the checkout process.
You should receive an order confirmation email from Shopify on behalf of your store shortly. Open it and check to see that it shows a section of text near the top that looks like this, but with the link, text, and key specific to the new product/course:
Course Access
Below you'll find the link to the courses and enrollment keys to gain access.
Link to course name here
Use the enrollment key to gain access: 1234