Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Shortcode_Checkout::checkout( array $atts )

Renders the checkout template.


Parameters Parameters

$atts

(array) (Required) Shortcode attributes array.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/shortcodes/class.llms.shortcode.checkout.php

	private static function checkout( $atts ) {

		// if there are membership restrictions, check the user is in at least one membership.
		// this is to combat CHEATERS.
		if ( $atts['plan']->has_availability_restrictions() ) {
			$access = false;
			foreach ( $atts['plan']->get_array( 'availability_restrictions' ) as $mid ) {

				// once we find a membership, exit.
				if ( llms_is_user_enrolled( self::$uid, $mid ) ) {
					$access = true;
					break;
				}
			}
			if ( ! $access ) {
				llms_print_notice( __( 'You must be a member in order to purchase this access plan.', 'lifterlms' ), 'error' );
				return;
			}
		}

		if ( self::$uid ) {
			// ensure the user isn't enrolled in the product being purchased.
			if ( isset( $atts['product'] ) && llms_is_user_enrolled( self::$uid, $atts['product']->get( 'id' ) ) ) {

				/**
				 * Filter the displaying of the checkout form notice for already enrolled in the product being purchased.
				 *
				 * @since 4.2.0
				 *
				 * @param bool $display_notice Whether or not displaying the checkout form notice for already enrolled students in the product being purchased.
				 */
				if ( apply_filters( 'llms_display_checkout_form_enrolled_students_notice', true ) ) {
					llms_print_notice(
						sprintf(
							// Translators: %2$s = The product type (course/membership); %1$s = product permalink.
							__( 'You already have access to this %2$s! Visit your dashboard <a href="%1$s">here.</a>', 'lifterlms' ),
							llms_get_page_url( 'myaccount' ),
							$atts['product']->get_post_type_label()
						),
						'notice'
					);
				}

				return;
			}

			$user = get_userdata( self::$uid );
			llms_print_notice( sprintf( __( 'You are currently logged in as <em>%1$s</em>. <a href="%2$s">Click here to logout</a>', 'lifterlms' ), $user->user_email, wp_logout_url( $atts['plan']->get_checkout_url() ) ), 'notice' );
		} else {
			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() );
		}

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

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Added filter to control the displaying of the notice informing the students they're already enrolled in the product being purchased.
3.36.3 Added l10n function to membership restriction error message.
3.33.0 Do not display the checkout form but a notice to a logged in user enrolled in the product being purchased.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.