Advertisement
craygo

pnp.php

Jul 18th, 2011
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Pnp extends CI_Controller
  4. {
  5.  
  6.   function Pnp()
  7.   {
  8.     parent::__construct();
  9.     $this->load->model('cart_model');
  10.   }
  11.  
  12.   function page_data()
  13.   {
  14.     $data['title'] = 'Prep N\' Pop';
  15.     $data['header'] = '
  16.      <div id="header" /></div>';
  17.     $data['css'] = "
  18.      <link href=\"".$this->config->item('base_url').$this->config->item('css')."\" rel=\"stylesheet\" type=\"text/css\" />
  19.      <script type=\"text/javascript\" src=\"".$this->config->item('base_url')."assets/js/jquery-1.6.2.min.js\"></script>
  20.      <script type=\"text/javascript\" src=\"".$this->config->item('base_url')."assets/js/core.js\"></script>
  21.           <script type=\"text/javascript\">
  22.         function swap(image) {
  23.             document.getElementById(\"pnp\").src = image.href;
  24.         }
  25.     </script>
  26.     <script src=\"".$this->config->item('base_url')."assets/js/flowplayer-3.2.6.min.js\"></script>";
  27.     $data['heading'] = '
  28.      <div id="heading" />Prep N\' Pop</div>';
  29.  
  30.     return $data;
  31.  
  32.   }
  33.  
  34.     function index()
  35.     {
  36.       $data = $this->page_data();
  37.       $data['products'] = $this->cart_model->retrieve_products(); // Retrieve an array with all products
  38.         $this->load->view('home', $data);
  39.     }
  40.  
  41.   function add_cart_item(){
  42.  
  43.     if($this->cart_model->validate_add_cart_item() == TRUE){
  44.  
  45.         // Check if user has javascript enabled
  46.         if($this->input->post('ajax') != '1'){
  47.             redirect('pnp'); // If javascript is not enabled, reload the page with new data
  48.         }else{
  49.             echo 'true'; // If javascript is enabled, return true, so the cart gets updated
  50.         }
  51.     }
  52.   }
  53.  
  54.     function update_cart(){
  55.         $this->cart_model->validate_update_cart();
  56.         redirect('pnp');
  57.     }
  58.  
  59.     function show_cart(){
  60.         $this->load->view('cart');
  61.     }
  62.  
  63.     function empty_cart(){
  64.         $this->cart->destroy();
  65.         redirect('pnp');
  66.     }
  67.  
  68.   function checkout()
  69.   {
  70.     $this->load->view('checkout', $this->page_data());
  71.   }
  72. }
  73.  
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement