本文整理汇总了PHP中Basket类的典型用法代码示例。如果您正苦于以下问题:PHP Basket类的具体用法?PHP Basket怎么用?PHP Basket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Basket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: basket
function basket()
{
if ($_POST) {
$basket = new Basket();
$basket->toOrder();
$this->redirect('/cabinet/basket/thanks/');
} else {
if (Funcs::$uri[2] == 'delivery') {
$seo['seo_title'] = 'Условия доставки';
Funcs::setMeta($seo);
$basket = new Basket();
$data['order'] = $basket->getOrder();
$data['delivery'] = $basket->getDelivery($data['order']);
View::render('cabinet/delivery', $data);
} elseif (Funcs::$uri[2] == 'thanks') {
$seo['seo_title'] = 'Благодарим вас за заказ!';
Funcs::setMeta($seo);
View::render('basket/thanks');
} else {
$data['seo_title'] = 'Корзина';
Funcs::setMeta($data);
$basket = new Basket();
$data['order'] = $basket->getOrder();
//$data['delivery']=$basket->getDelivery($data['order']);
//$data['payment']=$basket->getOrder($data['order']);
View::render('cabinet/basket', $data);
}
}
}
示例2: products
/**
* Process the Products
*
* @param Basket $basket
* @return array
*/
public function products(Basket $basket)
{
$products = [];
foreach ($basket->products() as $product) {
$products[] = ['sku' => $product->sku, 'name' => $product->name, 'price' => $product->price, 'rate' => $product->rate, 'quantity' => $product->quantity, 'freebie' => $product->freebie, 'taxable' => $product->taxable, 'delivery' => $product->delivery, 'coupons' => $product->coupons, 'tags' => $product->tags, 'discount' => $product->discount, 'category' => $product->category, 'total_value' => $this->reconciler->value($product), 'total_discount' => $this->reconciler->discount($product), 'total_delivery' => $this->reconciler->delivery($product), 'total_tax' => $this->reconciler->tax($product), 'subtotal' => $this->reconciler->subtotal($product), 'total' => $this->reconciler->total($product)];
}
return $products;
}
示例3: add
public function add()
{
$this->template->title = 'Cart :: Add';
$this->template->metaDescription = '';
$this->template->content = View::factory('cart')->bind('cart', $cart);
$p_id = $_POST['p_id'];
$this->cart = $this->session->get('Basket');
$cart = new Basket();
$item = new Item();
$item->id = $p_id;
$cart->add($item);
url::redirect('/cart');
}
示例4: getPrice
/**
*
* @return float
*/
public function getPrice(Basket $basket)
{
$items = $basket->getItems();
$sumPrice = 0;
/* @var $item Item */
foreach ($items as $item) {
$discount = $item->getProductDiscount();
$discountPrice = $discount->getDiscountPrice($item);
$discountAmount = $discount->getDiscountAmount($item);
$sumPrice += $discountPrice * $discountAmount;
}
return $sumPrice;
}
示例5: __construct
public function __construct(Service $service)
{
$this->db = $db;
//Выборка всех категорий для меню т.к. используются на всех страницах публичной части
$this->category = $service->get('category_mapper')->getAll();
$this->basket_info = Basket::getBasketInfo();
}
示例6: buildContent
function buildContent()
{
$harmoni = Harmoni::Instance();
$basket = Basket::instance();
$basket->removeAllItems();
RequestContext::locationHeader($harmoni->request->quickURL("basket", "view"));
}
示例7: indexAction
public function indexAction()
{
$basket = Basket::getBasket();
//При удалении товара
if ($_GET['del_item']) {
Basket::deleteProductFromBasket($_GET['del_item']);
}
//Подтверждеение заказа
if ($_POST['confirm_order']) {
//Для получеения общей суммы заказа
$basket_info = Basket::getBasketInfo();
//Создаем и заполняем доменный объект заказа
$order = new Order();
$order->id = uniqid();
//ID (Primary Key) для заказов генерируем сами
$order->user_id = intval($_SESSION['user_id']);
$order->delivery = $_POST['delivery'];
$order->pay = $_POST['pay'];
$order->total_sum = $basket_info['total_sum'];
$order->status = 'processing';
//Статус по-умолчанию, "В обработке"
$order->date = date('Y-m-d H:i:s', time());
$order->products = $basket;
//Сохраняем заказ
$this->service->get('order_mapper')->save($order);
//Очищаем корзину и редиректим
Basket::cleanBasket();
$_SESSION['message'] = 'Спасибо за покупку. Ваш заказ принят в обработку. Данные отправлены на почту';
header('Location: /basket');
exit;
}
$view_data['basket'] = $basket;
$view_data['title'] = 'Корзина покупателя';
$this->service->get('view')->render('basket.tpl.php', $view_data);
}
示例8: execute
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 5/5/06
*/
function execute()
{
$harmoni = Harmoni::Instance();
$basket = Basket::instance();
$basket->removeAllItems();
print $basket->getSmallBasketHtml();
exit;
}
示例9: loadBasket
public function loadBasket($id)
{
$model = Basket::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'Запись не найдена.');
}
if ($model->user_id !== Yii::app()->user->id) {
$this->error403();
}
return $model;
}
示例10: process
public function process()
{
$sql = 'INSERT INTO finance_transactions (amount, description, timestamp, account) VALUES (:amount, :title, now(), :account) ';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
foreach (Basket::getContents() as $basketItem) {
$stmt->bindValue(':amount', $basketItem['cost']);
$stmt->bindValue(':title', '(given cash) ' . $basketItem['title'] . ' ticket for ' . $basketItem['username']);
$stmt->bindValue(':account', $this->getElementValue('username'));
$stmt->execute();
Events::setSignupStatus($basketItem['userId'], $basketItem['eventId'], 'CASH_IN_POST');
}
}
示例11: actionView
public function actionView($id)
{
self::validateAdmin();
$order = Order::getOrderById($id);
$productQuantity = json_decode($order['products'], true);
$productId = array_keys($productQuantity);
$products = Products::getProductlistById($productId);
$totalPrice = Basket::getTotalPrice($products, $productQuantity);
$total = array_sum($totalPrice);
require_once ROOT . '/views/admin_order/view.php';
return true;
}
示例12: getAssets
/**
* Answer the assets to display in the slideshow
*
* @return object AssetIterator
* @access public
* @since 5/4/06
*/
function getAssets()
{
$assets = array();
$repositoryManager = Services::getService("Repository");
$basket = Basket::instance();
$basket->clean();
$basket->reset();
while ($basket->hasNext()) {
$assets[] = $repositoryManager->getAsset($basket->next());
}
$iterator = new HarmoniIterator($assets);
return $iterator;
}
示例13: buildContent
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
$harmoni->request->startNamespace("basket");
$idManager = Services::getService("Id");
$authZ = Services::getService("AuthZ");
$basket = Basket::instance();
$assetId = $idManager->getId(RequestContext::value("asset_id"));
$basket->moveUp($assetId);
$harmoni->request->endNamespace();
RequestContext::locationHeader($harmoni->request->quickURL("basket", "view"));
}
示例14: isAuthorizedToExecute
/**
* Check Authorizations
*
* @return boolean
* @access public
* @since 9/27/05
*/
function isAuthorizedToExecute()
{
$harmoni = Harmoni::instance();
$authZ = Services::getService("AuthZ");
$idManager = Services::getService("Id");
$basket = Basket::instance();
$basket->reset();
$view = $idManager->getId("edu.middlebury.authorization.view");
$this->_exportList = array();
while ($basket->hasNext()) {
$id = $basket->next();
if ($authZ->isUserAuthorized($view, $id)) {
$this->_exportList[] = $id;
}
}
if (count($this->_exportList) > 0) {
return true;
} else {
return false;
}
}
示例15: update
/**
* Tells the wizard component to update itself - this may include getting
* form post data or validation - whatever this particular component wants to
* do every pageload.
* @param string $fieldName The field name to use when outputting form data or
* similar parameters/information.
* @access public
* @return boolean - TRUE if everything is OK
*/
function update($fieldName)
{
$idManager = Services::getService("Id");
$ok = parent::update($fieldName);
// then, check if any "buttons" or anything were pressed to add/remove elements
$this->_addFromBasketButton->update($fieldName . "_addfrombasket");
if ($this->_addFromBasketButton->getAllValues()) {
$basket = Basket::instance();
$basket->reset();
while ($basket->hasNext()) {
$assetId = $basket->next();
$element =& $this->_addElement();
$element['_assetId'] = new AssetComponent();
$element['_assetId']->setParent($this);
$element['_assetId']->setValue($assetId);
}
$basket->removeAllItems();
$this->rebuildPositionSelects();
}
return $ok;
}