本文整理匯總了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');
}
}