remove() 공개 메소드

Removes position from the shopping cart of key
public remove ( mixed $key ) : mixed | void
$key mixed
리턴 mixed | void
예제 #1
0
 function testEventOnRemovePosition()
 {
     $this->setUp();
     $cart = new EShoppingCart();
     $this->testVar = false;
     $cart->attachEventHandler('onRemovePosition', array($this, 'testEventHandler'));
     $book = Book::model()->findByPk(1);
     $cart->put($book);
     $cart->remove($book->getId());
     $this->assertTrue($cart->hasEvent('onRemovePosition'));
     $this->assertTrue($cart->hasEventHandler('onRemovePosition'));
     $this->assertTrue($this->testVar);
 }
예제 #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;
 }