We already saw how to get product id from course id in our earlier article.

Today I’m going to illustrate the simplest way to get a course id associated with woo-commerce product Id in Tutor LMS.

How to get course Id from Product Id in Tutor LMS.

I’m a freelance WordPress Developer, and many are the times IĀ  come across clients who need code customization on various WordPress products.

Most of the time I usually navigate to a given plugin and I study the code then I’m able to see how they have come up with stuff.

Anyways, today I will demonstrate how to get a course id from the linked product Id in Tutor LMS

Get Course ID from Product ID in Tutor LMS

This is simply as saying, get the course ID associated with productId

The following code will illustrate how to get a course ID from product ID in tutorĀ  LMS

$product_id = 4234;
$if_has_course = tutor_utils()->product_belongs_with_course( $product_id );

if ($if_has_course) {
  $course_id = $if_has_course->post_id;
}

Is that simple, now you have your course id from associated product Id

 

 

Similar Posts