本文整理汇总了PHP中Basket::items方法的典型用法代码示例。如果您正苦于以下问题:PHP Basket::items方法的具体用法?PHP Basket::items怎么用?PHP Basket::items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basket
的用法示例。
在下文中一共展示了Basket::items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->template->title = 'Cart';
$this->template->metaDescription = '';
$this->template->content = View::factory('cart')->bind('p', $this->cart);
$this->cart = $this->session->get('Basket');
$cart = new Basket();
$this->additionalInfo = array();
if ($cart->size() > 0) {
$products = array();
foreach ($cart->items() as $index => $item) {
$products[] = $item->id;
}
$db = new Database();
$rows = $db->query('SELECT d.description FROM discounts d JOIN discounts_objects AS do ON (do.discount_id=d.id) WHERE d.effective_from <= now() AND d.effective_to >= now() AND d.type_id=1 AND do.object_id IN (' . join(',', $products) . ')');
foreach ($rows as $row) {
$this->additionalInfo[] = $row->description;
}
}
if (isset($_POST['update'])) {
foreach ($cart->items() as $index => $item) {
//update quntities
if ($item->qty != $_POST['quantity'][$index]) {
$item->qty = $_POST['quantity'][$index];
$cart->update($item);
}
//delete products
if (isset($_POST['delete'][$index]) and $_POST['delete'][$index] == 'on') {
$item->qty = 0;
$cart->update($item);
}
}
$this->cart = $this->session->get('Basket');
}
}