本文整理匯總了PHP中ShoppingCart::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShoppingCart::add方法的具體用法?PHP ShoppingCart::add怎麽用?PHP ShoppingCart::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ShoppingCart
的用法示例。
在下文中一共展示了ShoppingCart::add方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testComputesReducedVatForTheRightCountry
public function testComputesReducedVatForTheRightCountry()
{
$shoppingCart = new ShoppingCart(new Austria());
$article = new Article(new ArticleName('Test'), new ArticleDescription(''), new Euro(1000), new ArticleTypeReduced());
$shoppingCart->add($article);
$shoppingCart->add($article);
$this->assertEquals(new Money(2200, new Currency('EUR')), $shoppingCart->total());
}
示例2: addToShoppingCart
public function addToShoppingCart(Article $article)
{
$this->shoppingCart->add($article);
}
示例3: ShoppingCart
?>
</table>
</div>
<div class="col-md-12">
<h4>Shop Cart</h4>
<?php
require 'shoppingCart.class.php';
$cart = new ShoppingCart();
$action = isset($_GET['action']) ? $_GET['action'] : '';
$name = isset($_GET['name']) ? $_GET['name'] : 0;
switch ($action) {
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">
示例4: header
}
$link = preg_replace('/\\/\\//', '/', $link);
header("HTTP/1.1 301 Moved Permanently");
header('location: ' . $link);
exit;
}
// Добавление в корзину
if ((int) Text::get_get('add_to_cart') > 0) {
$id = (int) Text::get_get('add_to_cart');
$product_set = (int) Text::get_get('product_set');
$cart = new ShoppingCart($current_lang, $object->getLocalization());
if ($product_set == 1) {
// Получение комплекта товаров
$complect = $object->getRelationList(PREF . 'catalog_set', PREF . 'catalog_items', 'item_id1', 'item_id2', $id);
// Добавление в корзину
$cart->add($id, 1);
if (is_array($complect) && !empty($complect)) {
for ($i = 0; $i < count($complect); $i++) {
$cart->add($complect[$i]['id'], 1);
}
}
} else {
// Добавление в корзину
$cart->add($id, 1);
}
if (Text::get_get('ajaxSetCart') == 1) {
$cart_info = array('count' => $cart->count(), 'cost' => $cart->cost());
$smarty->assign('cart', $cart_info);
$smarty->assign('__lang', $object->getLocalization());
$data = $smarty->fetch(DOC . 'templates/site/matches/header_cart_block.tpl');
echo $data;