當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ShoppingCart::getItems方法代碼示例

本文整理匯總了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">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="6">&nbsp;</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";
開發者ID:nebulade,項目名稱:faursprung_website,代碼行數:31,代碼來源:shoppingcart.php

示例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;
開發者ID:aaronleslie,項目名稱:aaronunix,代碼行數:31,代碼來源:index.php


注:本文中的ShoppingCart::getItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。