Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/blue-sky.co.id/public_html/application/modules/wishlist/controllers/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Wishlist extends Public_Controller { private $products_array = array(); function __construct() { parent::__construct(); } public function index() { //get wishlist products $customer_id = (int) $this->session->userdata('customer')['customer_id']; //get products id from wishlist table /*$this->db->select('product_id')->from('wishlist')->where('customer_id', $customer_id); $product_ids = $this->db->get()->result();*/ /*foreach ($product_ids as $product_id) { $this->db->select('id_products, title, alias, image1')->from('products')->where('product_status', '1')->where('products', $product_id->product_id); $this->products_array[] = $this->db->get()->result_array(); }*/ /*$data['products'] = $this->products_array;*/ $data['products'] = $this->db ->select(' wishlist.product_id, products.alias as alias, products.title as title, products.id_products as id_products, product_details.price as price, product_details.discounted_price, product_images.image as product_image, ') ->from('wishlist') ->join('products', 'products.id_products = wishlist.product_id') ->join('product_details', 'product_details.product_id = products.id_products') ->join('product_images', 'product_details.id = product_images.product_details_id') ->where('wishlist.customer_id',$customer_id) ->group_by(array("products.title", "products.id_products")) ->get() ->result(); //LOAD LANGUAGE FILES if($this->session->userdata('site_lang') == 'english') { $this->lang->load('wishlist', 'english'); } else { $this->lang->load('wishlist', 'indonesian'); } //get SEO $this->data_header['browser_title'] = 'My Wishlist'; $this->data_header['meta_description'] = 'My Wishlist'; $this->data_header['meta_keywords'] = 'Wishlist'; $this->load->view("themes/$this->theme_no/header", $this->data_header); $this->load->view('wishlist', $data); $this->load->view("themes/$this->theme_no/footer", $this->data_footer); } //add wishlist public function add_wishlist() { $product_id = $this->security->xss_clean($this->input->post('id_product')); if($product_id == null){ show_404(); } if(!$this->session->userdata('customer')['customer_id']) { redirect(base_url('register')); } $customer_id = (int) $this->session->userdata('customer')['customer_id']; //check if customer_id and product_id combination already exist $this->db->select('id_wishlist')->from('wishlist')->where('customer_id', $customer_id)->where('product_id', $product_id); $count_wishlist = $this->db->get()->num_rows(); if($count_wishlist > 0) { echo "sudah ada"; exit(); $this->index(); } if ($count_wishlist == 0) { //add to wishlist table $data = array( 'customer_id' => $customer_id, 'product_id' => $product_id ); $this->db->insert('wishlist', $data); } } public function delete($product_id) { $customer_id = (int) $this->session->userdata('customer')['customer_id']; $this->db->where('customer_id', $customer_id); $this->db->where('product_id', $product_id); $this->db->delete('wishlist'); redirect('wishlist'); } }