put() 공개 메소드

Add item to the shopping cart If the position was previously added to the cart, then information about it is updated, and count increases by $quantity
public put ( IECartPosition $position, $quantity = 1 )
$position IECartPosition
예제 #1
0
 function testEmpty()
 {
     $this->setUp();
     $cart = new EShoppingCart();
     $this->assertTrue($cart->isEmpty());
     $book = Book::model()->findByPk(1);
     $cart->put($book);
     $this->assertFalse($cart->isEmpty());
 }
예제 #2
0
 public function actionSwitchDostavka()
 {
     $cart = new EShoppingCart();
     $cart->init();
     if ($_POST['dostavka'] == "on") {
         $productInCart = new ProductInCart();
         $productInCart->name = $_POST['Доставка'];
         $productInCart->id = 100;
         $productInCart->count = 1;
         $productInCart->priceForThisCount = 200;
         //Цена доставки!!!
         $cart->put($productInCart);
     } else {
         $cart->remove(100);
     }
     $totalPrice = 0;
     $positions = $cart->getPositions();
     foreach ($positions as $position) {
         $totalPrice += $position->priceForThisCount;
     }
     echo $totalPrice;
 }