shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

wishlist.php (1150B)


      1 <?php
      2 class ModelAccountWishlist extends Model {
      3 	public function addWishlist($product_id) {
      4 		$this->db->query("DELETE FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "' AND product_id = '" . (int)$product_id . "'");
      5 
      6 		$this->db->query("INSERT INTO " . DB_PREFIX . "customer_wishlist SET customer_id = '" . (int)$this->customer->getId() . "', product_id = '" . (int)$product_id . "', date_added = NOW()");
      7 	}
      8 
      9 	public function deleteWishlist($product_id) {
     10 		$this->db->query("DELETE FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "' AND product_id = '" . (int)$product_id . "'");
     11 	}
     12 
     13 	public function getWishlist() {
     14         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "'");
     15 
     16 		return $query->rows;
     17 	}
     18 
     19 	public function getTotalWishlist() {
     20 		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_wishlist WHERE customer_id = '" . (int)$this->customer->getId() . "'");
     21 
     22 		return $query->row['total'];
     23 	}
     24 }