/** * Returns all products in a cart * @return array|null */ public function getAllCartProducts() { $cartID = $this->session->get('cartID'); $query = "\n SELECT\n cp.id, cp.unit_price, cp.quantity, p.id AS product_id, p.name, p.image, p.slug\n FROM\n aca_cart_product AS cp\n INNER JOIN aca_product AS p ON cp.product_id = p.id\n WHERE cp.cart_id = :cartID\n "; $result = $this->db->fetchRowMany($query, array('cartID' => $cartID)); return $result; }
public function getOrderProducts() { $orderId = $this->session->get('completed_order_id'); $query = ' select * from aca_order_product op left join aca_product p on (op.product_id = p.product_id) left join aca_cart c on (op.order_id = c.cart_id) WHERE order_id = "' . $orderId . '"'; return $this->db->fetchRowMany($query); }
public function getAllCartProducts() { $userId = $this->session->get('user_id'); $query = 'select cp.id, p.name, p.description, p.image, cp.unit_price as price, cp.qty from aca_cart_product as cp left join aca_product as p on(p.id = cp.product_id) left join aca_cart as c on(c.id = cp.cart_id) where c.user_id = ' . $userId; return $this->db->fetchRowMany($query, array('myCartid' => $this->getCartId())); }
/** * Get array of all products for a given order * @return array|null */ public function getSessionOrderProducts() { $query = ' SELECT ord.product_id, ord.quantity, ord.price, prod.name, prod.image FROM aca_order_product ord LEFT JOIN aca_product prod ON ord.product_id = prod.id WHERE order_id= :orderId'; $data = $this->db->fetchRowMany($query, array('orderId' => $this->session->get('order_id'))); return $data; }
/** * 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)); } } }
/** * Provide array of cart items * @return array|null */ public function getCart() { $query = "\n SELECT\n p.id as p_id,\n p.name as p_name,\n p.image as p_image,\n cp.price as cp_price,\n cp.product_id as cp_product_id,\n cp.id as cp_id,\n cp.cart_id as cp_cart_id,\n cp.quantity as cp_quantity\n FROM\n aca_cart_product as cp\n LEFT JOIN aca_product as p on (p.id = cp.product_id)\n LEFT JOIN aca_cart as ct on (ct.id = cp.cart_id)\n WHERE\n ct.id = :cartId"; return $this->db->fetchRowMany($query, array('cartId' => $this->cartId)); }