Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.
If you need assistance with this, please reach out to our list of consultants for further assistance:
The RCP_Registration class is used on the registration page for setting up the registration, applying discounts, applying fees, and calculating the total price. In most cases, you will want to use the
rcp_get_registration() function to retrieve the current, main instance of the registration object.
$registration = new RCP_Registration( $level_id, $discount_code );
The class has the following public methods:
set_subscription( $subscription_id )
Used for setting the membership level ID for the registration. If the membership level being added has a fee, that is automatically applied as well.
Returns the membership level ID the registration is for.
Returns the type of registration. One of:
- new - Brand new signup; the user did not have a membership previously.
- renewal - Renewing an existing membership.
- upgrade - Upgrading an existing membership to a higher-priced one.
- downgrade - Downgrading an existing membership to a lower-priced one.
Get the existing membership object that is being renewed, upgraded, or downgraded. Returns an RCP_Membership object if there is one, or will return false if this is a new registration.
Returns true if the level being registered for has a free trial and the current user is eligible to sign up for it.
Returns false if the level being registered for does not have a trial, or if there is a trial but the current user is not eligible for it.
add_discount( $code, $recurring = true )
Adds a discount to the registration. The recurring flag specifies whether the discount code should apply to all future payments or only the first payment.
Returns an array of discount codes that have been applied, or false if none.
add_fee( $amount, $description = null, $recurring = false, $proration = false )
Adds a fee to the registration. The parameters are as follows:
$amount(float) - Amount of the fee.
$description(string) - Description of the fee (i.e. "Signup Fee").
$recurring(bool) - Whether or not the fee should be applied to all future payments.
$proration(bool) - Whether or not this is a proration credit being applied.
$registration = rcp_get_registration(); $registration->add_fee( 50, __( 'Extra Signup Fee', 'rcp' ) );
Returns an array of all fees that have been applied to the registration, or false if none.
get_total_fees( $total = null, $only_recurring = false )
Returns the total amount of fees that have been applied to the registration.
Returns the total amount of signup fees that are being applied. This does not include proration credits or recurring fees.
Returns the total amount of proration credits being put towards the registration.
get_total_discounts( $total = null, $only_recurring = false )
Returns the total amount of discounts.
get_total( $discounts = true, $fees = true )
Returns the total initial price (with or without discounts/fees, depending on parameters).
get_recurring_total( $discounts = true, $fees = true )
Returns the recurring total (with or without discounts/fees, depending on parameters).