How to setup a Freemium access model using shopping cart

Discussion in 'Setting-up protection' started by engineerwsu, Oct 1, 2015.

  1. engineerwsu

    engineerwsu Member

    Joined:
    Sep 18, 2014
    Messages:
    31
    I would like to set up a freemium access application. All users who create an account have access to free content. Users unlock additional features by purchasing a higher level license. The application is coded to unlock the features based on the logged in users's level of access. In addition, there are add-on products or upgrades that could be either individually purchased or purchased along with a paid access level.

    I will give an example below:
    Everyone has free access simply by creating an account.

    Paid Access Levels
    1.) Bronze ($1/mo) - users can create one page
    2.) Silver ($2/mo)- users can create 3 pages
    3.) Gold ($5/mo) - users can create unlimited pages

    Add-On Features (can be added to the free page or the paid access pages)
    • Stock Ticker widget
    • Thermometer widget
    I'm looking for some advice on how to set this up in aMember for both access and shopping cart/payment. I've noticed that if I use the shopping cart add-on and setup the paid access levels, access levels are all listed as individual items (add to cart) rather than a radio box. I shouldn't be able to buy a Bronze, Silver, and Gold package all at the same time. But, if I don't use the shopping cart add-on, I get a radio box list. However, how do I then allow users to purchase the add-on features?
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I suggest you to add two Product bricks to your signup form (aMember CP -> Configurration -> Forms Editor).

    In configuration of first brick set to display only your access levels eg. Bronze, Silver and Gold
    input type set to radio and make this brick required.

    In configuration of second Product brick set to display your addons eg. Stock Ticker widget and Thermometer widget.
    Input type set to checkbox and make this brick optional. In event you have many addons you can set to display it in popup. Please see how it done on our signup form http://www.amember.com/amember/signup (Optional Plugins)

    Then check your signup form. I hope such configuration will solve your use case.

    Best Regards.
  3. engineerwsu

    engineerwsu Member

    Joined:
    Sep 18, 2014
    Messages:
    31
    Thanks ceasar. I think that answers the question about the shopping cart. and how that can be made to work for the freemium model.

    My other question is about how users might be granted the necessary permissions to access additional features. My thought is to use the $_SESSION variable to set the access level and check it on each page, but maybe there is a better way.

    Firstly
    1.) where do I put my application (e.g. /amember/myapplication) and then add that folder as free access?
    2.) my login pages, signups, etc will need to share files (js/css/php) with the freemium application. Currently, the mod_rewrites are making absolute paths to the include files a little challenging.

    Basically, if I have a freemium application to run inside of aMember, what is the best way to run that in aMember?

    Cheers
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    First of all please put all your content outside of amember folder. You can use same folder for assets for both applications. There is not any issue with it.

    You can populate $_SESSION with necessary data in file site.php (http://www.amember.com/docs/Site.php_file)
    Please take into account by default aMember uses non standard session handler so you may want to change it to default one if you want to access aMember session from your 3ty part script. You can do it at aMember CP -> Configuration -> Setup/Configuration -> Advanced (Session Storage).

    Here is example of code how to populate session with ids of user active subscriptions:
    PHP:
    if (Am_Di::getInstance()->auth->getUserId()) {
        
    $_SESSION['active_product_ids'] = Am_Di::getInstance()->auth->getUser()->getActiveProductIds();
    }
    Then based on this array you can grant different access to different users in your application.

Share This Page