The Subscriptions is an interface API class containing useful subscriptions functions.
- is_active($product, $customer = null, $reset_cache = false) - allows you to check whether a currently logged in customer owns a subscription, specified with the subscription product SKU, and whether this subscription is active (paid) at the moment. The function returns Boolean value (TRUE or FALSE). Please note that if there a trial period or a grace period is active at the moment, the function will return TRUE even in case if the order/invoice is not paid yet.
The method have 3 parameters. Only the first parameter is required:
- $product - specifies the subscription product object (Shop_Product) or the product SKU string.
- $customer - specifies the customer to check the subscription for. This method accepts the (Shop_Customer) object, or the customer identifier (a number). If this parameter is omitted, a currently logged in customer will be used.
- $reset_cache - cache control. By default the method caches subscription information between calls, so if you call the method multiple times for a same customer, no extra SQL queries will be issued. If you for some reason want to clear the method cache, pass the TRUE value to this parameter.
<? if (Subscriptions::is_active('membership')): ?> <p>This content is visible only for customers which purchased a subscription product with the "membership" SKU.</p> <? endif ?>
Want to Learn More?
This knowledge base is dedicated to helping you build successful eCommerce projects. To get the most value for your time, you'll want to download the free trial of LemonStand's eCommerce platform. If you're not ready, you can also browse our features and live demo.