Friday, June 17, 2016

Kategori:

Tutorial Toko Online : Source Code Shopping Cart BinerShop Codeigniter

ecommerce


Tobi Web ID Tempatnya Cari Source Code Toko Online, Source Code Aplikasi PHP, Berbasis PHP dan MySQl, Source code CodeIgniter, Pengelolaan Data dengan Codeigniter, Contoh Program dengan PHP, Source Code eCommerce, Source Code dengan Laravel, cek source code website, source code toko online, source code toko online dengan php mysql
ilustrasi gambar dari www.binercenter.com

Pada postingan kali ini ane akan share souce code shopping cart yang ane dapet dari github, yah iseng2 eh ternyata dapet tuh source code nongol di laptop ane, source code ini bisa sobat download di github wh04mi, namun setelah ane coba, ada beberapa bug yang harus diperbaiki. Oh iya source code ini gratis dan dengan lisensi general public umum atau GNU

Berikut beberapa saran ane sih diantaranya source code ini bagi pemula aja ya, yang udah mahir jangan pake ini lah dan jika sobat mememai os linux, ganti nama controller dan model dengan huruf Besar, misalnya controller login.php ganti dengan Login.php.
Sebelumnya pastikan sobat sudah import databasenya ke phpmyadmin lalu buat configurasi database pada direktori application/config/database.php. sebagai berikut konfigurasinya :


$db['default'] = array(
 'dsn' => '',
 'hostname' => 'localhost',
 'username' => 'root',
 'password' => '',
 'database' => 'biner-shop',
 'dbdriver' => 'mysqli',
 'dbprefix' => '',
 'pconnect' => FALSE,
 'db_debug' => TRUE,
 'cache_on' => FALSE,
 'cachedir' => '',
 'char_set' => 'utf8',
 'dbcollat' => 'utf8_general_ci',
 'swap_pre' => '',
 'encrypt' => FALSE,
 'compress' => FALSE,
 'stricton' => FALSE,
 'failover' => array(),
 'save_queries' => TRUE
);

Sobat juga harus memastikan bahwa config routenya sudah benar.
silahkan cek di direktori application/config/routes.php

$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['logout']='login/logout';

Berikut beberapa script contollernya  
Berikut Contoller Customer.php : letak nya pada direktori application/contollers/Costumer.php


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Customer extends CI_Controller {
  
 public function __construct ()
 {
  parent::__construct();
  $this->load->model('model_customer');
  $this->load->model('model_settings');
  $this->load->model('model_users');
 }

 public function index()
 { 
   
 }
 public function payment_confirmation($invoice_id = 0 )
 {
  
  $data['get_sitename'] = $this->model_settings->sitename_settings();
  $data['get_footer'] = $this->model_settings->footer_settings();
   
  $this->form_validation->set_rules('invoice_id_input','Invoice id','required|integer');
  $this->form_validation->set_rules('amount_input','Amount Transfered','required|integer');
  if($this->form_validation->run() == FALSE)
  {
   if($this->input->post('invoice_id_input'))
   {
    $data['invoice_id'] =set_value('invoice_id_input');
   }else{ 
     $data['invoice_id'] = $invoice_id;
    }
   $this->load->view('customer/form_payment_confirmation',$data);
  }else{
    $is_valid = $this->model_customer->mark_invoice_paid_confirmed(set_value('invoice_id_input'),set_value('amount_input'));
    if ($is_valid)
    {
      $this->session->set_flashdata('message','Thank you ..... we will check on your payment confirmation');
      redirect('customer/shopping_history');
    }else{
      $this->session->set_flashdata('error','Worng amount or invoice id.... ! please try again ');
      redirect('customer/payment_confirmation/'.set_value('invoice_id_input'));
     }
     
    }
 }
 public function shopping_history()
 {
  $data['get_sitename'] = $this->model_settings->sitename_settings();
  $data['get_footer'] = $this->model_settings->footer_settings(); 
  
  $user=$this->session->userdata('username');
  $data['history'] = $this->model_customer->get_shopping_history($user);
  $this->load->view('customer/shopping_history_list',$data);
 }
 
 
 
}//end class

Berikut Contoller Home.php : letak nya pada direktori application/contollers/


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {
  
 public function __construct ()
 {
  parent::__construct();
  //load model -> model_products 
  $this->load->model('model_products');
  $this->load->model('model_settings');
 }

 public function index()
 { 
  $data['get_sitename'] = $this->model_settings->sitename_settings();
  $data['get_footer'] = $this->model_settings->footer_settings(); 
  $data['products'] = $this->model_products->all_products(); //this all_products from model 
  $data['starts'] = $this->model_products->dis_products();
  $this->load->view('home',$data); //this $data from model inside class model_products
  
  
  
 }
 
 public function showme($pro_name)
 {  
   $data['get_sitename'] = $this->model_settings->sitename_settings();
   $data['get_footer'] = $this->model_settings->footer_settings(); 
   $data['starts'] = $this->model_products->dis_products();
   $data['comes'] = $this->model_products->showme($pro_name); //for showme function in home/showme
   $this->load->view('this_products',$data);
 }
 
 public function add_to_cart($pro_id,$send)
 {
  $product = $this->model_products->find($pro_id);
  $data = array(
      'id'      => $product->pro_id,
      'qty'     => 1,
      'price'   => $product->pro_price,
      'name'    => $product->pro_name,
      'title'   => $product->pro_title
      );
  
  $this->cart->insert($data); 
  if ($send == 'add')
  {
    redirect('home/showme/'.$product->pro_name);
  }else{
    redirect(base_url());
    }
  
 }
 
 public function cart()
 {
  $data['get_sitename'] = $this->model_settings->sitename_settings();
  $data['get_footer'] = $this->model_settings->footer_settings(); 
  $this->load->view('show_cart',$data); 
  
 }//view inside cart
 
 public function clear_cart()
 {
  $this->cart->destroy();
  redirect(base_url());
 }
 
 public function report($pro_id)
 {
  $product = $this->model_products->find($pro_id);
  
  if($this->session->userdata('group') != ('2' ||'3'))
  {
   $group_usr = Gost;
   $name_usr = Gost; 
  }else{
    $group_usr = $this->session->userdata('group');
    $name_usr = $this->session->userdata('username');
   }
  
  
  
  $report_products = array
  (
   'rep_id_product'   => $product->pro_id,
   'rep_name'     => $product->pro_name,
   'rep_title_product'   => $product->pro_title,
   'rep_usr_name'    => $name_usr,
   'rep_usr_group'    => $group_usr
  );
  $this->model_products->report($report_products);
  redirect(base_url());
  
 }
 
}

Berikut Contoller Login.php : letak nya pada direktori application/contollers/


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller {
  
 public function index()
 {
  $this->load->model('model_settings');
  $this->form_validation->set_rules('username','Username','required|alpha_numeric');
  $this->form_validation->set_rules('password','Password','required|alpha_numeric|md5');
  
  if($this->form_validation->run() == FALSE)
  {
   $data['get_sitename'] = $this->model_settings->sitename_settings();
   $data['get_footer'] = $this->model_settings->footer_settings(); 
   $this->load->view('login/form_login',$data);  
  }else{
   $this->load->model('model_users'); 
   $valid_user = $this->model_users->check_usr();
   $check_user_is_active = $this->model_users->check_user_is_active();
   if($valid_user == FALSE)
   {
    if ($check_user_is_active == FALSE)
    {
      $this->session->set_flashdata('error','Username / Password Not Correct !' );
    }else{
      $this->session->set_flashdata('error','Sorry this account is not active !' );
      }
    
    redirect('login');
   }else{
    $this->session->set_userdata('username',$valid_user->usr_name);
    $this->session->set_userdata('group',$valid_user->usr_group);
    
    switch($valid_user->usr_group)
    {
     case 1 ://for admin
       redirect('admin/products');
     break;
     
     case 2 ://for c-admin
       redirect('admin/products');
     break;
     
     case 3 ://for member
       redirect(base_url());
     break;
     
     default: break;
    }
   }//end if valid_user 
   
  }//end if validation
  
  
  
  
 }
 
 public function logout()
 {
  $this->session->sess_destroy();
  redirect('login');
 }
 
  
 
 
}


Berikut Contoller Order.php : letak nya pada direktori application/contollers/



<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Order extends CI_Controller {
 
 public function __construct()
 {
  parent::__construct();
  
  if(!$this->session->userdata('username'))
  {
   redirect('login');
  }
  $this->load->model('model_settings');
  $this->load->model('model_orders');
  $this->load->model('model_users');
 }
 
 public function index()
 {
  
  $is_processed = $this->model_orders->process();
  if($is_processed)
  {
   $this->cart->destroy();
   redirect('order/success');
  }else{
    $this->session->set_flashdata('error','Failed To Processed Your Order ! , please try again');
    redirect('home/cart');
   
    }
 }
 
 public function success()
 {
  $data['get_sitename'] = $this->model_settings->sitename_settings();
  $data['get_footer'] = $this->model_settings->footer_settings(); 
 
  $this->load->view('order_success',$data);
   
 }
 
}//end  class
Berikut Contoller Register.php : letak nya pada direktori application/contollers/



<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Register extends CI_Controller {
 
 public function __construct ()
 {
  parent::__construct();
  $this->load->model('model_users');
  $this->load->model('model_settings');
 }
  
 public function index()
 {
  
  $this->form_validation->set_rules('rusername','Username','required|alpha_numeric|min_length[4]|max_length[20]');
  $this->form_validation->set_rules('rpassword','Password','required|alpha_numeric|matches[repassword]|min_length[6]|max_length[24]|md5');
  $this->form_validation->set_rules('repassword','Password','required|alpha_numeric');
  
  if($this->form_validation->run() == FALSE)
  {
   $data['get_sitename'] = $this->model_settings->sitename_settings();
   $data['get_footer'] = $this->model_settings->footer_settings(); 
   $this->load->view('register/form_register',$data); 
   
  }else{
    $data_register_new = array
     (
     'usr_name'   => set_value('rusername'),
     'usr_password'  => set_value('rpassword'),
     'stuts'    => '1',
     'usr_group'    =>'3'
     );
     if($this->model_users->is_usr() == FALSE)
     {
      $this->model_users->register_new($data_register_new);
       $this->form_validation->set_rules('rusername');
       $this->form_validation->set_rules('rpassword');
       if($this->form_validation->run() == FALSE)
       {
        $this->load->view('login/form_login');  
       }else{
        $valid_user = $this->model_users->check();
         if($valid_user == FALSE)
         {
          $this->session->set_flashdata('error','Username / Password Not Correct !' );
          redirect('login');
         }else{
           $this->session->set_userdata('username',$valid_user->usr_name);
           $this->session->set_userdata('group',$valid_user->usr_group);
           switch($valid_user->usr_group)
           {
            case 3 ://for member
            redirect(base_url());
            break;
            
            default: break;
           }
         }
       }
      
      redirect(base_url());
     }else{
      $this->session->set_flashdata('error','Please Write Other User Name !' );
      redirect('register');
     }
  }
 }
 
}

Berikut link download source code nya : DOWNLOAD, sebelum download silahkan share dulu ya, terima kasih.

Sekian source code kali ini, source code ini bersumber dari Github
Sekian share source code gratis kali ini, semoga bermanfaat bagi sobat semua.

Tobi Muhammad

Author & Editor

Tobi (Muhammad Tobi) adalah seorang Tukang Masak di perusahaan startup, suka sekali menulis dan mempelajari source code open source lisensi GNU di Github dll. Bisa pemrogramman web karena sering belajar dari contoh program yang ada di Github dll. Anak desa yang hanya lulusan Paket C.

0 comments:

Post a Comment

 

News Letters

Subscribe here to get our newsletter in your inbox, it is safe and EASY!

Copyright © Tobi Web™