本文整理汇总了PHP中Basket::addEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Basket::addEvent方法的具体用法?PHP Basket::addEvent怎么用?PHP Basket::addEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basket
的用法示例。
在下文中一共展示了Basket::addEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_ajax
public function action_ajax()
{
$r = Yii::app()->request;
$c = $this->config;
switch ($r->getParam('action')) {
case 'addProduct':
$model = new Basket('addProduct');
$model->product_id = $r->getParam('product_id');
$model->count = $r->getParam('count');
echo json_encode((int) $model->addProduct());
break;
case 'addEvent':
$model = new Basket('addEvent');
$model->event_id = $r->getParam('event_id');
$model->count = $r->getParam('count');
echo json_encode((int) $model->addEvent());
break;
case 'changeCount':
$basket = $this->loadBasket($r->getParam('id'));
if ((int) $r->getParam('count') == 1 && $basket->count < 1000 || (int) $r->getParam('count') == -1 && $basket->count > 1) {
$basket->saveCounters(array('count' => (int) $r->getParam('count')));
echo json_encode(1);
} else {
echo json_encode(0);
}
break;
case 'removeFromBasket':
$basket = $this->loadBasket($r->getParam('id'));
echo json_encode((int) $basket->delete());
break;
default:
echo json_encode(null);
break;
}
}
示例2: process
public function process()
{
$event = Events::getById($this->getElementvalue('event'));
Basket::addEvent($event, $this->ticketCosts[$event['id']]);
}
示例3: testAdd
public function testAdd()
{
$event = array('id' => 1);
Basket::addEvent($event, 1.99);
}
示例4: redirect
require_once 'includes/classes/FormAddToBasket.php';
require_once 'includes/classes/Basket.php';
use libAllure\Session;
use libAllure\Sanitizer;
use libAllure\DatabaseFactory;
if (!Session::isLoggedIn()) {
redirect('login.php', 'You need to <a href = "login.php">login</a> or <a href = "register.php">register</a> to pay for events.');
}
$sanitizer = new Sanitizer();
$action = $sanitizer->filterString('action');
if (isset($_REQUEST['event'])) {
$eventId = intval($_REQUEST['event']);
$event = Events::getById($eventId);
switch ($action) {
case 'addPersonal':
Basket::addEvent($event);
redirect('basket.php', 'Ticked added', false, 1);
case 'delete':
Basket::removeEvent($event, $_REQUEST['user']);
redirect('basket.php', 'Ticket removed', false, -1);
}
}
$signupableEvents = Events::getSignupableEvents();
$tpl->assign('signupableEvents', $signupableEvents);
$formAddToBasket = new FormAddToBasket($signupableEvents);
if ($formAddToBasket->validate()) {
$formAddToBasket->process();
redirect('basket.php', 'Ticket added to basket');
}
$tpl->assign('addToBasketHasEvents', $formAddToBasket->hasEvents);
$tpl->assignForm($formAddToBasket, 'addToBasket');