Example #1
0
 /**
  * Move Items to another cart instance
  *
  * @param Cart $cart
  */
 public function moveItemsTo(Cart $cart)
 {
     $this->items()->update(['cart_id' => $cart->id]);
     $cart->item_count += $this->item_count;
     $cart->total_price += $this->total_price;
     $cart->save();
     $this->item_count = 0;
     $this->total_price = 0;
     return $this->save();
 }
Example #2
0
 public function moveTo(Cart $cart)
 {
     $this->delete();
     // delete from own cart
     return $cart->items()->create($this->attributes);
 }
Example #3
0
 public function testCreateItem()
 {
     $cart = Cart::create();
     $cart->addItem(['product_id' => 1, 'unit_price' => 10.5, 'quantity' => 1]);
     $this->assertCount(1, $cart->items);
 }