本文整理匯總了PHP中Model_Order::set_featured_plan方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Order::set_featured_plan方法的具體用法?PHP Model_Order::set_featured_plan怎麽用?PHP Model_Order::set_featured_plan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Order
的用法示例。
在下文中一共展示了Model_Order::set_featured_plan方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_240
/**
* This function will upgrade DB that didn't existed in versions prior to 2.4.0
*/
public function action_240()
{
//new configs
$configs = array(array('config_key' => 'subscribe', 'group_name' => 'general', 'config_value' => 0), array('config_key' => 'cookie_consent', 'group_name' => 'general', 'config_value' => 0), array('config_key' => 'sharing', 'group_name' => 'advertisement', 'config_value' => 0), array('config_key' => 'logbee', 'group_name' => 'advertisement', 'config_value' => 0), array('config_key' => 'thanks_page', 'group_name' => 'advertisement', 'config_value' => ''), array('config_key' => 'auto_locate', 'group_name' => 'general', 'config_value' => 0), array('config_key' => 'search_multi_catloc', 'group_name' => 'general', 'config_value' => 0), array('config_key' => 'featured_plans', 'group_name' => 'payment', 'config_value' => '{"5":"10"}'), array('config_key' => 'user_fields', 'group_name' => 'user', 'config_value' => '{}'));
Model_Config::config_array($configs);
//locations latitude/longitude
try {
DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "locations` ADD `latitude` DOUBLE NULL , ADD `longitude` DOUBLE NULL ;")->execute();
} catch (exception $e) {
}
//ads latitude/longitude
try {
DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "ads` ADD `latitude` DOUBLE NULL , ADD `longitude` DOUBLE NULL ;")->execute();
} catch (exception $e) {
}
//featured days on orders
try {
DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "orders` ADD `featured_days` int(10) unsigned DEFAULT 0")->execute();
} catch (exception $e) {
}
//update pay as feature, create one in the array
$price = core::config('payment.pay_to_go_on_feature');
$days = core::config('payment.featured_days');
Model_Order::set_featured_plan($days, $price);
Model_Config::set_value('payment', 'pay_to_go_on_feature', 1);
}
示例2: action_payment
/**
* Payment deatails and paypal configuration can be configured here
* @return [view] Renders view with form inputs
*/
public function action_payment()
{
//delete featured plan
if (is_numeric(Core::get('delete_plan'))) {
Model_Order::delete_featured_plan(Core::get('delete_plan'));
$this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
}
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Payments')));
$this->template->title = __('Payments');
// all form config values
$paymentconf = new Model_Config();
$config = $paymentconf->where('group_name', '=', 'payment')->find_all();
// save only changed values
if ($this->request->post()) {
if (is_numeric(Core::request('featured_days')) and is_numeric(Core::request('featured_price'))) {
Model_Order::set_featured_plan(Core::request('featured_days'), Core::request('featured_price'), Core::request('featured_days_key'));
Alert::set(Alert::SUCCESS, __('Featured plan updated'));
$this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
}
$validation = Validation::factory($this->request->post())->rule('pay_to_go_on_top', 'not_empty')->rule('pay_to_go_on_top', 'numeric')->rule('stripe_appfee', 'numeric')->rule('stripe_appfee', 'range', array(':value', 0, 100))->rule('to_featured', 'range', array(':value', 0, 1))->rule('to_top', 'range', array(':value', 0, 1))->rule('sandbox', 'range', array(':value', 0, 1))->rule('paypal_seller', 'range', array(':value', 0, 1))->rule('stock', 'range', array(':value', 0, 1))->rule('authorize_sandbox', 'range', array(':value', 0, 1))->rule('stripe_address', 'range', array(':value', 0, 1));
//not updatable fields
$do_nothing = array('featured_days', 'pay_to_go_on_feature', 'featured_plans');
if ($validation->check()) {
foreach ($config as $c) {
$config_res = $this->request->post($c->config_key);
if (!in_array($c->config_key, $do_nothing) and $config_res != $c->config_value) {
if ($c->config_key == 'pay_to_go_on_top') {
$config_res = str_replace(',', '.', $config_res);
}
$c->config_value = $config_res;
try {
$c->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
} else {
$errors = $validation->errors('config');
foreach ($errors as $error) {
Alert::set(Alert::ALERT, $error);
}
$this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
}
Alert::set(Alert::SUCCESS, __('Payments Configuration updated'));
$this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'payment')));
}
$pages = array('' => __('Deactivated'));
foreach (Model_Content::get_pages() as $key => $value) {
$pages[$value->seotitle] = $value->title;
}
$this->template->content = View::factory('oc-panel/pages/settings/payment', array('config' => $config, 'pages' => $pages, 'featured_plans' => Model_Order::get_featured_plans()));
}