/** * Delete the entire shopping cart * @throws Exception */ public function nixCart() { $cartId = $this->getCartId(); $this->db->delete('aca_cart_product', array('cart_id' => $cartId)); $this->db->delete('aca_cart', array('cart_id' => $cartId)); //create a new black cart // $this->getCartId(); }
/** * Determine if a given address is used elsewhere and remove it if it isn't * @param int $addressId */ public function checkIfAddressUsed($addressId) { // If original address ID existed, check for it being used elsewhere if ($addressId != 0) { $query = ' SELECT id FROM aca_user WHERE shipping_address_id= :addressId OR billing_address_id= :addressId'; $data = $this->db->fetchRowMany($query, array('addressId' => $addressId)); // If the address isn't used elsewhere, remove it if (empty($data)) { $this->db->delete('aca_address', array('id' => $addressId)); } } }
/** * Delete a shopping cart. Because SRP * @see https://en.wikipedia.org/wiki/Single_responsibility_principle * @throws \Exception */ public function nixCart() { $cartId = $this->getCartId(); $this->db->delete('aca_cart_product', array('cart_id' => $cartId)); $this->db->delete('aca_cart', array('id' => $cartId)); }
/** * Deletes an item from the cart. * @param int $cartProductID * @return bool * @throws \Simplon\Mysql\MysqlException */ public function removeProductFromCart($cartProductID) { return $this->db->delete('aca_cart_product', array('id' => $cartProductID)); }
/** * Delete a shopping cart * @throws \Exception */ public function removeCart() { // Delete order from cart $this->db->delete('aca_cart_product', array('cart_id' => $this->cartId)); $this->db->delete('aca_cart', array('id' => $this->cartId)); }