I am creating an LMS using LearnDash + WooCommerce. So far so good. Now, I’d like to hide a Product when the logged-in user has already purchased it to a) prevent the user from purchasing it twice, and b) so that I can display a product grid for them without the already purchased item(s).
Another example: if a user who purchased ITEM A goes to the shop, ITEM A should not even be displayed for them.
Thanks so much!
3
Answers
So, I ended up with a nice workaround:
On the product page, I created a CUSTOM FIELD where I can input the COURSE ID.
Then, with PHP, I check the Product and retrieve the custom field for the COURSE ID.
LearnDash has a shortcode for students... so after retrieving the course ID, I can display a message/button for users who have registered already for this course.
This is the code:
Hope it helps!
Gist snippet got from here – please check
There is a simpler solution.
Use this LearnDash shortcode…
[visitor]
Hello visitor.
Put your "Buy now" button here.
[/visitor]