User Guide & Reference Manual

Subscriptions

Retrieve and utilize the user's purchased subscriptions in your templates.

Important URL's

Subscription Template Variables

Each subscription has the following available data accessible.

Variables
Variable Description
{$id} The subscription ID.
{$date_created} The date the subscription was purchased.
{$amount} The recurring charge, without a currency symbol.
{$interval} The number of days between successive charges for this subscription.
{$start_date} The date of the first charge.
{$end_date} The date the subscription will/has expired.
{$last_charge_date} The date of the last charge.
{$next_charge_date} The date of the next charge.
{$number_occurrences} The number of charges that have/will occur for this subscription.
{$card_last_four} If the user entered a credit card, the last 4 digits of this credit card.
{$cancel_date} The date the subscription was cancelled, if applicable.
{$plan.name} The name of the subscription plan (notice it's an array)
{$renew_link} An absolute URL for the renewal link.
{$cancel_link} An absolute URL to cancel this subscription.
{$update_cc_link} An absolute URL to update the billing information for this subscription.
{$is_recurring} Set to TRUE if this subscription is actively recurring, else FALSE.
{$is_active} Set to TRUE if this subscription has not expired, else FALSE.
{$is_renewed} Set to TRUE if this subscription has been subsequently renewed by the user, else FALSE.

Subscription Plan Template Variables

Variables
Variable Description
{$id} The subscription plan ID.
{$name} The name of the plan.
{$type} Either "paid" or "free".
{$initial_charge} The initial charge for the subscription. Does not co-exist with a free trial.
{$amount} The recurring charge for the subscription.
{$interval} The number of days between recurring charges.
{$free_trial} The number of days prior to the first charge.
{$occurrences} The number of occurrences for the subscription (if not unlimited).
{$number_occurrences} The number of charges that have/will occur for this subscription.
{$is_taxable} Set to TRUE/FALSE depending on if the subscription plan is charged exempt.
{$active_subscribers} The number of members currently subscribing to the plan.
{$require_billing_for_trial} Set to TRUE/FALSE depending of if billing information is required for the free trial.
{$description} The plan description.
{$promotion} If set, this is the member group that subscribers are added to.
{$demotion} If set, this is the member group that expired subscribers are added to.
{$add_to_cart} If this URL is accessed, the subscription is added to the member's cart and they are redirected to the cart. Use it in a [b]subscribe now[/b] link.

Template Plugins

{has_subscriptions}

Only display the content between the two tags if the user has at least one active subscription on their account.

Usage:


{has_subscriptions}
You are a subscriber (of some kind)!
{/has_subscriptions}

{subscriptions}

Retrieve the user's subscriptions (active or expired) based on a set of parameters.

Parameters
Variable Required? Description
var Required Specify the name for the returned variable array (e.g., "sub" returns an array with keys like {$sub.date_created}.
active No Set to TRUE to return only subscriptions that have not expired.
recurring No Set to TRUE to return only subscriptions that are still actively recurring.
id No Specify a particular subscription to return.
plan_id No Only return subscriptions to this particular subscription plan.

Example usage (from the account manager):


{has_subscriptions}
<table class="table" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<td colspan="2">Your Subscriptions</td>
		</tr>
	</thead>
	<tbody>
	{subscriptions var="sub" active=TRUE}
	{assign var="sub_id" value=$sub.id}
		<tr>
			<td style="width:50%"><b>{$sub.plan.name}</b></td>
			<td>
				{if $sub.is_recurring == TRUE}Next Charge: {$sub.next_charge_date|date_format:"%B %e, %Y"}
				{else}Expires: {$sub.end_date|date_format:"%B %e, %Y"}{/if}
				{if $sub.is_renewed == TRUE} (Renewed){/if}
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<ul class="sub_options">
					{if $sub.card_last_four and $sub.is_recurring}
						<li>
							<a href="{$sub.update_cc_link}">Update Credit Card Information</a>
						</li>
					{/if}
					{if $sub.last_charge_date}
						<li>
							<a href="{url path="users/invoices/$sub_id"}">View Related Invoices</a>
						</li>
					{/if}
					{if $sub.is_recurring}
						<li>
							<a href="{$sub.cancel_link}">Cancel Subscription</a>
						</li>
					{/if}
					{if $sub.is_renewed == FALSE and $sub.last_charge_date}
						<li>
							<a href="{$sub.renew_link}">Renew Subscription</a>
						</li>
					{/if}
					
					{if !$sub.is_recurring and !$sub.last_charge_date}
						<li>No options available.</li>
					{/if}
				</ul>
			</td>
		</tr>
	{/subscriptions}
	</tbody>
</table>
{/has_subscriptions}

{subscription_plans}

Retrieve and display your site's subscription plan products.

Parameters
Variable Required? Description
var Required Specify the name for the returned variable array (e.g., "sub" returns an array with keys like {$sub.name}.
id No Specify a particular subscription plan to return.

Example usage:


<h2>Check out our available subscription products!</h2>

<table class="table" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<td colspan="2">Your Subscriptions</td>
		</tr>
	</thead>
	<tbody>
	{subscription_plans var="plan"}
		<tr>
			<td style="width:50%"><b>{$plan.name}</b></td>
			<td>
				{setting name="currency_symbol"}{money_format value=$plan.amount} {if $plan.free_trial}{$plan.free_trial} day free trial{/if}
			</td>
			<td>
				<a href="{$plan.add_to_cart}">subscribe now!</a>
			</td>
		</tr>
	{/subscription_plans}
	</tbody>
</table>