function emptyCart()
 {
     $this->Cart->emptyCart($this->passedArgs['ct']);
     $this->redirect(array('action' => 'view/c:' . $this->c));
 }
 public function submit()
 {
     require_once '../app/models/Purchase.php';
     $purchase = new Purchase();
     $purchase->assignProperties($_SESSION['checkout']['properties']);
     $purchaseId = $purchase->savePreparedStatementToDb('purchase', $purchase->properties);
     $products = [];
     foreach ($_SESSION['checkout']['cart'] as $key => $value) {
         if (is_array($value)) {
             array_push($products, ['fkPurchaseProductVersionProductVersion' => $key, 'quantityInPurchase' => $value['cart_quantity'], 'priceAtPurchase' => $value['product_price']]);
         }
     }
     $purchase->addToJoinTable($products, 'purchase_product_version');
     require_once '../app/models/Cart.php';
     $cart = new Cart($_SESSION['checkout']['properties']['fk_purchase_user']);
     $cart->emptyCart();
     $view = new View('checkout/submit');
     $view->set_title('Order Complete');
     $view->pass_data('deliveryDue', $_SESSION['checkout']['properties']['deliveryDue']);
     $view->load_page();
     unset($_SESSION['checkout']);
 }
Exemple #3
0
 public function testAddProduct()
 {
     $cart = new Cart(774);
     $pRepo = new ProductRepository();
     $product1 = $pRepo->getProduct(130);
     $product2 = $pRepo->getProduct(133);
     $cart->emptyCart();
     $this->assertEquals(0, $cart->count(), "Delete didn't work");
     $cart->addProduct($product1);
     $this->assertEquals(1, $cart->count(), "Adding product 1 failed");
     $this->assertEquals($cart->count(), count($cart->getProducts()), "?");
     $cart->addProduct($product2, 1405);
     $this->assertEquals(2, $cart->count(), "Adding product 2 failed");
     //getProducts should ignore its internal cache, so we tell it to.
     $this->assertEquals($cart->count(), count($cart->getProducts(NULL, NULL, TRUE)), "?");
 }
Exemple #4
0
 public function emptyCart()
 {
     $oCart = new Cart();
     $allIds = $oCart->getAllIds();
     $oCart->emptyCart();
 }