Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Requires: phpFox version >= 4.5.2

...

 

 

In this doc, we will use the app To Do List for example.

...

in Settings

 

First, we will configure price for featuring a to do list:

Open file Install.php, modify function setSettings with the following code

Code Block
php
php

$this->settings = [
    'td_can_user_privacy' => [
        'var_name'      => 'td_can_user_privacy',
        'info'          => 'Allow user add privacy',
        'description'   => 'Enable this setting in case you want your user can use privacy during adding new todo list',
        'type'          => \Core\App\Install\Setting\Site::TYPE_RADIO,
        'value'         => '1',
    ],
    'td_feature_price' => [
        'var_name'    => 'td_feature_price',
        'info'        => 'How much does it cost to feature a todo list?',
        'type'        => \Core\App\Install\Setting\Site::TYPE_CURRENCY,
        'value'       => serialize(['USD' => 2])
    ]
];

...

When you want to get the values of the price, you can use below code:

Code Block
php
php

$aFeaturePrice = unserialize(setting('td_feature_price'));
/**
*   $aFeaturePrice will have array type, below is an example
*   ['USD' => 2]
*/

...

Open file Install.php, modify function setUserGroupSettings with the following code

Code Block
php
php

$this->user_group_settings = [
    'td_can_add_new_todo_list'          => [
        'var_name' => 'td_can_add_new_todo_list',
        'info'     => 'Can add new todo list?',
        'type'     => \Core\App\Install\Setting\Groups::TYPE_RADIO,
        'value'    => [
            "1" => "1",
            "2" => "1",
            "3" => "1",
            "4" => "1",
            "5" => "0"
        ],
        'options'  => \Core\App\Install\Setting\Groups::$OPTION_YES_NO
    ],
    'td_user_sponsor_price' => [
        'var_name' => 'td_user_sponsor_price',
        'info' => 'How much does it cost to sponsor a todo list?',
        'type' => \Core\App\Install\Setting\Groups::TYPE_CURRENCY,
        'value' => [
            "1" => serialize(['USD' => 2]),
            "2" => serialize(['USD' => 4]),
            "3" => serialize(['USD' => 7]),
            "4" => serialize(['USD' => 9]),
            "5" => ''
        ],
    ]
];

...

To get the price value, we can use:

Code Block
php
php

$aUserSponsorPrice = unserialize(user('td_user_sponsor_price'));
/**
*   $aUserSponsorPrice will have array type, below is an example
*   ['USD' => 2]
*/