Skip to content

Commit 2a0cd42

Browse files
authored
Create allow-purchase-when-enrolled.php
1 parent f2c9727 commit 2a0cd42

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* Still allow purchase when enrolled in a product
4+
*
5+
* Information on using custom code: https://lifterlms.com/docs/how-do-i-add-custom-code-to-lifterlms/
6+
*/
7+
8+
/**
9+
OPTION 1
10+
*/
11+
// Allow purchase of all WooCommerce products regardless of enrollments.
12+
add_filter( 'llms_wc_user_not_already_enrolled_into_related_llms_products', '__return_true' );
13+
14+
15+
/**
16+
OPTION 2
17+
*/
18+
// If you want to be more specific, you can do checks based on the current user or the WC product.
19+
add_filter( 'llms_wc_user_not_already_enrolled_into_related_llms_products', function ( $return, $user_id, $wc_product ) {
20+
$llms_products = llms_get_llms_products_by_wc_product_id( $wc_product->get_id() );
21+
22+
// Do checks based on user ID, the WC product, and/or the LifterLMS products associated with the WC product.
23+
// Return true if allowed, a WP_Error otherwise.
24+
25+
return $return;
26+
}, 10, 3 );

0 commit comments

Comments
 (0)