LLMS_Access_Plan::get_checkout_url( bool $check_availability = true )
Retrieve the full URL to the checkout screen for the plan.
Parameters Parameters
- $check_availability
-
(bool) (Optional) Determine if availability checks should be made (allows retrieving plans on admin panel).
Default value: true
Return Return
(string)
Source Source
File: includes/models/model.llms.access.plan.php
$ret = '#llms-plan-locked'; $available = $this->is_available_to_user( get_current_user_id() ); // if bypassing availability checks OR plan is available to user. if ( ! $check_availability || $available ) { $ret_params = array( 'plan' => $this->get( 'id' ), ); $redirection = $this->get_redirection_url( true, true ); if ( $redirection ) { $ret_params['redirect'] = $redirection; } $ret = llms_get_page_url( 'checkout', $ret_params ); // not available to user -- this is a member's only plan. } elseif ( ! $available ) { $memberships = $this->get_array( 'availability_restrictions' ); // if there's only 1 plan associated with the membership return that url. if ( 1 === count( $memberships ) ) { $ret = get_permalink( $memberships[0] ); $redirection = $this->get_redirection_url(); if ( $redirection ) { $ret = add_query_arg( array( 'redirect' => $redirection, ), $ret ); } } } /** * Filter the checkout URL for an access plan. * * @since Unknown * @since 3.31.0 The `$check_availability` parameter was added. * * @param string $ret The checkout URL. * @param LLMS_Access_Plan $this Access plan object. * @param bool $check_availability Determine if availability checks should be made. * (allows retrieving plans on admin panel) */ return apply_filters( 'llms_plan_get_checkout_url', $ret, $this, $check_availability ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
7.0.0 | No need to add the redirect querystring parameter if not already set, except for unavailable members only plans. |
3.31.0 | The $check_availability parameter was added to the filter llms_plan_get_checkout_url |
3.30.0 | Added access plan redirection settings. |
3.0.0 | Introduced. |