In case you want to support admin can control the prices of your app (price for feature item, sponsor item, etc...), this document can help you how to add a setting/user group setting for price with multiple currenciesRequires: 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
$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:
$aFeaturePrice = unserialize(setting('td_feature_price')); /** * $aFeaturePrice will have array type, below is an example * ['USD' => 2] */
in User Group Settings
Phpfox also support price with multiple currencies in User Group Settings.
For example: we will configure sponsor price for each user groups.
Open file Install.php, modify function setUserGroupSettings with the following code
$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:
$aUserSponsorPrice = unserialize(user('td_user_sponsor_price')); /** * $aUserSponsorPrice will have array type, below is an example * ['USD' => 2] */