• Hello,

    I am trying to customize the Learnpress single course template and need to add button for buying the course.

    I have inserted the button but not able to find the hook or code to check if the user has already enrolled to the course or not so that the button should only gets displayed when the user has not enrolled to the course.

    Can you please help me with this problem?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi hungpatel1412,

    Thank you for reaching out!

    To assist you better, could you please let us know which theme you are currently using? Some themes, especially premium ones developed by ThimPress like Eduma or Coaching, have custom templates and hooks for LearnPress that might differ from the default ones.

    Once we have this information, we’ll be able to provide you with a more accurate solution for displaying the button conditionally based on the user’s enrollment status.

    Looking forward to your response!

    Best regards,
    Brianvu-tp

    Thread Starter harshpatel1412

    (@harshpatel1412)

    Hello @briantp ,

    Thank you for the response.

    I am using Hello Elementor Theme.

    Plugin Support brianvu-tp

    (@briantp)

    Hi hungpatel1412,

    Thank you for your response!

    Since you’re using the Hello Elementor Theme, you can customize the display of the “Buy Course” button by referring to the LearnPress core function that handles this feature. Specifically, you can check the following file and function:

    • File Path:
      wp-content/plugins/learnpress/inc/TemplateHooks/Course/SingleCourseTemplate.php
    • Function:
      html_btn_purchase_course

    Within this function, you’ll find the condition can_purchase(), which determines whether the “Buy Now” button should be displayed based on the user’s enrollment status.

    This should help you conditionally display the button only when the user is not enrolled in the course.

    Let us know if you need further assistance!

    Best regards,
    Brianvu-tp

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.