Apps, plugins and design themes can be available in the Webasyst Store under two licenses — basic and premium. By default, products are published under the basic license. The premium license is an extra one, which offers more functionality to a user and is usually more expensive.
A user can purchase either any of these two licenses or an upgrade from the basic to the premium license (provided that they already have a basic license). The price of each license is defined by the product developer.
Premium license upgrade purchase
A user can purchase the upgrade on the product-viewing page in the Installer app. We recommend that you tell users about the upgrade option directly in your product’s interface and thus promote the upgrade to a more feature-rich product version. To do so, you may use a link pointing to an address generated with a code snippet like {$wa_backend_url}installer/store/...
.
You will find a ready-to-use Smarty code for each of your products in your developer profile in the Webasyst Customer Center. Just copy it and use it in your source code. You may design such upgrade promotion links completely to your liking!
Product license verification in source code
Both licenses are represented in the Webasyst Store by a single instance of the product source code. To determine which product features must be available to a certain user, you need to check the available license using the waLicensing
class methods, both in PHP code and in Smarty templates.
-
check
Returns an instance of the
waLicensing
class corresponding to the specified software product. -
isPremium
Verifies the availability of information whether a user has the premium license.
-
isStandard
Verifies the availability of information whether a user has the basic license and has no premium license.
-
isAnyPremiumFeatureEnabled
Verifies the availability of enabled product settings which must be available only to premium license owners.
-
getSetting
Returns the value of a license verification setting.
-
hasLicense
Verifies whether a user has an active product license.
-
hasPremiumLicense
Verifies whether a user has an active premium license.
-
hasStandardLicense
Verifies whether a user has an active basic license and has no premium license.
-
isCached
Returns information about the next call of any other class method to be fast, i. e. without a network request.
public static function check ($slug = '')
Returns an instance of the waLicensing
class corresponding to a certain software product. It makes it convenient to call other public methods of this class.
Parameters
-
$slug
Product identifier made up according to the following rules:
- for apps: product’s app_id; e.g., 'shop',
- for apps’ plugins: app_id/plugins/plugin_id; e.g., 'shop/plugins/referrals',
- for system plugins: wa-plugins/shipping/plugin_id; e.g., 'wa-plugins/shipping/courier', 'wa-plugins/payment/cash', 'wa-plugins/sms/mysms',
- for design themes: parent_theme_app_id/themes/parent_theme_id; e.g., 'site/themes/default' (specify the parent theme’s ID and its app ID because a license is issued for the parent theme within a theme family).
Example
// PHP if (waLicensing::check('myapp')->isPremium()) { echo 'Thank you for purchasing the premium license!'; } // Smarty {if waLicensing::check('someapp/plugins/myplugin')->isPremium()} Thank you for purchasing the premium license! {/if}
To avoid specifying a product identifier for each method call, you can create a custom class in your product, extending the waLicensing
class, with a fixed value of the $static_slug
field.
class myappLicensing extends waLicensing { protected static $static_slug = 'myapp'; }
Static method check()
of such a class can be called without an argument:
$is_premium = myappLicensing::check()->isPremium();
public function isPremium()
Returns true
if the information is available that a user has the premium license or used to have it in the past.
Example
// PHP if (waLicensing::check('myapp')->isPremium()) { echo 'You have the premium license or used to have it in the past.'; }
public function isStandard()
Returns true
if no information is available whether a user has the premium license or used to have it in the past.
Example
// PHP if (waLicensing::check('myapp')->isStandard()) { echo 'You have the basic license.'; }
public function isAnyPremiumFeatureEnabled()
Returns true
if some product settings are enabled which must be available only to premium license owners. This method can be used only for apps and their plugins; for other products it always returns false
.
To make this method correctly work for your product, add public method isAnyPremiumFeatureEnabled()
to your app’s configuration class in the wa-apps/[app_id]/lib/config/[app_id]Config.class.php
file, or to your plugin’s main class, which must return different Boolean values depending on the current product settings.
This method may come in handy in the situations when you cannot reliably verify whether a user does have the premium license. E.g., if a website has been restored from a backup archive or there is no connection to the Webasyst updates server, or during the development.
Example
// PHP if (waLicensing::check('myapp')->isAnyPremiumFeatureEnabled()) { echo 'You have settings for premium license owners enabled.'; }
public function getSetting ($name, $default = null)
Returns the value of a license verification setting; e.g., 'license_premium'
(denotes the availability of the information whether a user has the premium license or used to have it in the past).
Example
// PHP if (waLicensing::check('myapp')->getSetting('license_premium')) { echo 'You have the premium license or used to have it in the past.'; }
public function hasLicense ($err_if_unable_to_connect = false)
Returns true
if a user has any active license, either basic or premium.
Params
-
$err_if_unable_to_connect
Flag denoting the necessity to throw an exception should the Webasyst licenses server not return a correct response for a request for user licenses information. If the parameter is set to
false
then the method returns the information about user’s licenses which has been received during the latest successful checkup.
Example
// PHP if (waLicensing::check('myapp')->hasLicense()) { echo 'You have an active product license.'; }
public function hasPremiumLicense ($err_if_unable_to_connect = false)
Returns true
if a user has an active premium license.
Params
-
$err_if_unable_to_connect
Flag denoting the necessity to throw an exception should the Webasyst licenses server not return a correct response for a request for user licenses information. If the parameter is set to
false
then the method returns the information about user’s licenses which has been received during the latest successful checkup.
Example
// PHP if (waLicensing::check('myapp')->hasPremiumLicense()) { echo 'You have an active premium license.'; }
public function hasStandardLicense ($err_if_unable_to_connect = false)
Returns true
if a user has an active basic license and has no active premium license of the specified product.
Params
-
$err_if_unable_to_connect
Flag denoting the necessity to throw an exception should the Webasyst licenses server not return a correct response for a request for user licenses information. If the parameter is set to
false
then the method returns the information about user’s licenses which has been received during the latest successful checkup.
Example
// PHP if (waLicensing::check('myapp')->hasStandardLicense()) { echo 'You have an active basic license and have no premium license.'; }
public function isCached()
Returns information about the next call of any other class method to be fast, i. e. without a network request.
Example
// PHP if (waLicensing::check('myapp')->isCached()) { //next class method call will be fast }
System requirements
waLicensing
class methods and the ability to use a premium license are available only to users with the Webasyst framework version 2.7.0 or higher installed. When publishing a product with a premium license support do specify this limitation as a system requirement:
'app.installer' => [ 'version' => '>=2.7.0', 'strict' => true, ],
How to publish a premium license
- Add conditions to your product’s source code using the
waLicensing
class methods to determine which product features must be available to the owners of different licenses. - Enable the premium license in the product properties in your developer profile in the Webasyst Customer Center.
- Specify a price for the premium license.
- Submit the product to the publication in the Webasyst Store.