예제 #1
0
 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);
 }
예제 #2
0
 /**
  * Create a cart record, and return the id if it doesn't exist
  * If it does exist, just return the ID
  * @return int
  * @throws Exception
  */
 public function getCartId()
 {
     //        $db = $this->get('acadb');
     $user_id = $this->session->get('user_id');
     $query = '
     select
         *
     from
         aca_cart
     WHERE
         user_id = :userId';
     $data = $this->db->fetchRow($query, array('userId' => $user_id));
     if (empty($user_id)) {
         throw new Exception('Please login first');
     } else {
         if (empty($data)) {
             $cartId = $this->db->insert('aca_cart', array('user_id' => $user_id));
         } else {
             $cartId = $data['cart_id'];
         }
         $this->session->set('cart_id', $cartId);
         $this->session->save();
         return $cartId;
         //        return $this->getCartId();
     }
 }