本文整理汇总了PHP中ShoppingCart::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP ShoppingCart::getItems方法的具体用法?PHP ShoppingCart::getItems怎么用?PHP ShoppingCart::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShoppingCart
的用法示例。
在下文中一共展示了ShoppingCart::getItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShoppingCart
<td width="40px" align="center">Preis(EUR)</td>
<td colspan="2" width="200px"> </td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<?php
/* load or initialize the ShoppingCart */
if (!isset($shopping_cart)) {
if (isset($_SESSION["cart_product_id_array"])) {
$shopping_cart = new ShoppingCart($_SESSION["username"], $_SESSION["cart_product_id_array"], $_SESSION["cart_product_amount_array"]);
} else {
$shopping_cart = new ShoppingCart($_SESSION["username"]);
}
}
$list = $shopping_cart->getItems();
/* if there were any actions, set the focus to the next item */
$prev_edit_product_id = "";
$set_focus_next = false;
if (var_get_post("action", "") == "edit_product_amount") {
$prev_edit_product_id = var_get_post("product_id", "");
}
for ($i = 0; $i < count($list); $i++) {
echo "\t<tr class=\"list_normal\" onmouseover=\"javascript: this.className='list_hover';\" onmouseout=\"javascript: this.className='list_normal';\">\n";
echo "\t<form name=\"edit_product_amount_" . $list[$i][0] . "\" action=\"shoppingcart.php\" method=\"POST\">\n";
echo "\t<input type=\"hidden\" name=\"action\" value=\"edit_product_amount\">\n";
echo "\t<input type=\"hidden\" name=\"product_id\" value=\"" . $list[$i][0] . "\">\n";
echo "\t<input type=\"submit\" value=\"\" class=\"invisible_submit\">\n";
echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][0] . "</td>\n";
echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][1] . "</td>\n";
echo "\t\t<td onclick=\"javascript: window.location.href = 'product_details.php?product_id=" . $list[$i][0] . "';\">" . $list[$i][4] . "</td>\n";
示例2: foreach
case 'add':
foreach ($products as $product) {
if ($product['name'] == $name) {
$cart->add($name);
break;
}
}
break;
case 'empty':
$cart->clear();
break;
case 'remove':
$cart->remove($name);
break;
}
$items = $cart->getItems();
if (!empty($items)) {
echo '
<table class="table">
<tr>
<td><b>Product</b></td>
<td><b>Price</b></td>
<td><b>Qty</b></td>
<td><b>Total</b></td>
<td></td>
</tr>';
$total = 0;
foreach ($items as $name => $qty) {
foreach ($products as $product) {
if ($product['name'] == $name) {
break;