本文整理汇总了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;