Download the PHP package remp/crm-upgrades-module without Composer
On this page you can find all versions of the php package remp/crm-upgrades-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download remp/crm-upgrades-module
More information about remp/crm-upgrades-module
Files in remp/crm-upgrades-module
Package crm-upgrades-module
Short Description CRM Upgrades Module
License MIT
Homepage https://remp2030.com
Informations about the package crm-upgrades-module
CRM Upgrades Module
Module provides a way to upgrade user's subscriptions. It utilizes current subscription price, target subscription price, and number of remaining days of user's subscription to calculate "credit" which is used to provide different ways of upgrade.
Installation
We recommend using Composer for installation and update management. To add CRM Upgrades extension to your REMP CRM application use following command:
Enable installed extension in your app/config/config.neon
file:
Configuration
Prerequisites
Upgrades expect you to configure default subscription type for each combination of content access and subscription length. This way the module knows, that if you want to upgrade to subscription type with content access content_access_AA
, it's the default one.
The setting is not available in the UI, so you need to seed it manually. You can use following snippet to make sure, there's only one default subscription type for each content access / length combination.
Validation snippet
Alternatively you could set the target subscription type explicitly at the upgrade_options.subscription_type
column, however this would cause a lot of duplication and is not generally recommended.
Upgraders
Module currently provides 4 default upgraders to use:
paid_recurrent
. Calculates the amount of money that user needs to pay to upgrade to better subscription without changing the billing cycle. Charge is made directly.free_recurrent
. Changes the subscription type configured on the recurring payment. Upgrade is made free of charge at the moment of upgrade, higher amount will be charged at the next billing cycle.paid_extend
. Calculates the discount for fully new subscription. End time of original subscription is ignored, original subscription is stopped and remaining days are used as a credit to discount the upgraded subscription price.short
. Calculates the credit user has available and uses it to calculate number of days of higher-tier subscription user could have. Upgrade "shortens" the original subscription and upgrades it.
You can implement your own upgrader by following Crm\UpgradesModule\Upgrade\UpgraderInterface
and then registering it in applicatino configuration:
Subsequent upgrades
CRM provides support to upgrade subscriptions following currently upgraded subscription. Subsequent upgrades allow upgrade of subscriptions:
- Having the same subscription type as the original subscription before upgrade.
- Having the same subscription type as the subscription after the upgrade.
Subsequent upgrades currently don't support cross-subscription-type upgrade. That means, that if user has monthly subscription followed by yearly subscription, the yearly still wouldn't be upgraded.
This feature is still experimental and disabled by default. To enable it, add this to your configuration:
This config says, that to execute subsequent upgrades, CRM should use short
upgrader. Even if user used paid_recurrent
upgrade to do the actual upgrade, all of the following subscriptions will be shortened. This is to simplify the process and provide universal way of subsequent upgrades.
Upgrade scenarios
At this moment there's no UI to configure the upgrades within CRM admin. You need to seed your configuration from within your internal modules.
Upgrade options
Options define which upgrader can be used for which kind of content-access-based upgrade. The two important columns are:
type
. This is referencingUpgraderInterface::getType()
return value.config
. Object defining the conditions of upgrade (described below).
Upgrade schemas
Schemas have only one purpose: to bundle multiple upgrade options logically together.
Module needs to link each subscription type with upgrade options that it can use. To prevent linking each subscription type with N upgrade options, options are grouped within a schema and subscription type is linked to this single schema.
The link is made in subscription_type_upgrade_schemas
table and it needs to be defined explicitly for each subscription type you want to be upgradeable.
Example
If you want to allow upgrade to content access foo
by shortening the subscription, you would:
- Insert new
upgrade_option
record with values:type
:short
config
:{"require_content": ["foo"]}
- Link it to some
upgrade_schema
record. - Link all the subscription types you want to allow the upgrade from to this
upgrade_schema
record. - Make sure there's a single subscription type with content access
foo
for each standard length of your subscription types.
Using module
Module has a default presentation layer displaying all the default available upgrade scenarios for currently logged user at :Upgrades:Upgrade:default
route.
It's recommended to make a custom implementation of the presenter for special offer upgrades due to the use of require_tags
configuration option.