Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changelogs/additional-checks-course-enrollment-cap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
significance: patch
type: changed
links:
- "#3086"
entry: Add additional check for course capacity on the checkout page.
29 changes: 29 additions & 0 deletions includes/shortcodes/class.llms.shortcode.checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,35 @@ private static function checkout( $atts ) {
llms_get_login_form( sprintf( __( 'Already have an account? <a href="%s">Click here to login</a>', 'lifterlms' ), '#llms-show-login' ), $atts['plan']->get_checkout_url() );
}

if ( isset( $atts['product'] ) && 'course' === $atts['product']->get( 'type' ) && ( $course = new LLMS_Course( $atts['product']->post ) ) && ! $course->has_capacity() ) {
/**
* Filter the displaying of the checkout form notice for already enrolled in the product being purchased.
*
* @param bool $display_notice Whether or not displaying the checkout form notice for already enrolled students in the product being purchased.
* @param LLMS_Access_Plan $plan The access plan.
*
* @since 4.2.0
*/
if ( apply_filters( 'llms_display_checkout_form_course_capacity_notice', true, $atts['plan'] ) ) {
llms_print_notice(
$course->get( 'capacity_message' ),
'error'
);
}

/**
* Filter to block checkout when the course capacity has been reached. Defaults to true.
*
* @param bool $block_checkout Whether or not blocking the checkout form when a course is at capacity.
* @param LLMS_Access_Plan $plan The access plan.
*
* @since [version]
*/
if ( apply_filters( 'llms_checkout_block_course_capacity_checkout', true, $atts['plan'] ) ) {
return;
}
}

llms_get_template( 'checkout/form-checkout.php', $atts );
}

Expand Down
Loading