Tutor LMS is one of the most advanced LMS plugins for WordPress.

It comes with loads of important hooks, filters and supported functions.

Although the code support is a bit low, it’s evident that no LMS plugin would beat Tutor LMS

in Today’s articles, I’m going to illustrate how to detect if a course is free or if a course is paid.

Detect if a course is free on Tutor LMS

As a WordPress freelancer an advanced WordPress developer, I usually come across clients who would want some custom customizations. Customizations based on code and not just UI.

In the last project, I got a client who wanted me to detect if a course is free or paid. If it’s is free, I would show Enroll now button, else Add to Cart Text.

The following code will detect if a course is free or paid on Tutor LMS programmatically

$is_purchasable = tutor_utils()->is_course_purchasable( $course_id );
if( $is_purchasable ){
  // thse course is not free
} else {
  // course is free

Where to Add this code?

This code can be added in custom plugins or in the functions.php of a child theme.

Think of a course id as a post id, courses are normal posts, they are custom post types, known as courses

Similar Posts