ICTtask works best with JavaScript enabled.

 

Ajax Shopping Cart Customer Order View & account Update by using PHP OOP PDO(E-Commerce website-part 10)

Live Demo
post thumbnail
Source Code
Hi Everyone, In previous part we have made Customer Account Logout option by using PHP OOP PDO. So now fetch cart product data by specific user session ID and update user account information. When our document ready then we fetch all cart product data into payment & order tab so we create a function for fetch product data by using jquery and ajax request after that we fetch single row data of customer account information for update account update information by user session ID and then we show information on update form we have use bootstrap collapse.so now when click update button then will be sent data into mysql database table for update row information by using ajax request. now we will write code for update query into DB class. Then if successfull update account so we show a alert sweet alert. So I hope understand. Please Follow our video tutorial We have also provide source code and live online demo. In next video tutorial we will make discussing on a new topic thanks. So friend please share this post.Thanks Next Tutorilas Link these:
    Files structure Follow:
  • Application root folder
    • // classes/Cart.php
    • // Cart class
    • // classes/Tabs.php
    • // Tabs class
    • // config/config.php
    • // config file
    • // lib/DB.php
    • // database file
    • upload
    • // upload folder
    • action.php
    • // action file
    • index.php
    • // view page

Sourse Code:

  • Customer.php

  • <?php
    
      /**
    *  Cart Class
    */
      require_once "/../lib/DB.php";
      class Customer 
      {
        private $db;
        function __construct()
        {
          $this->db = new DB();
        }
    
        public function sameUserNameCheck($table,$c_user_name){
          $sql = "SELECT * FROM $table WHERE c_user_name =?";
          return $this->db->affectedUserName($sql,$c_user_name);
    
        }
        public function customerAccountCreate($table,$data){
          return $this->db->insert($table,$data);
        }
    
        public function authLoginCheck($table,$c_user_name_l,$c_pass_l){
          $sql = "SELECT * FROM $table WHERE c_user_name=? AND c_pass=?";
          return $this->db->affectedRow($sql,$c_user_name_l,$c_pass_l);
    
        }
    
        public function fetchCustomerInfo($table,$c_user_name_l,$c_pass_l){
          $sql = "SELECT * FROM $table WHERE    c_user_name ='$c_user_name_l' AND   c_pass='$c_pass_l' ";
          return $this->db->select($sql);
        }
    
      }
    
  • Cart.php

  • <?php
    /**
    *  Cart Class
    */
      require_once "/../lib/DB.php";
      class Cart 
      {
        private $db;
        function __construct()
        {
          $this->db = new DB();
        }
    
        public function addToCart($table,$data){
          return $this->db->insert($table,$data);
        }
         
        public function affectCart($table,$s_id,$pd_id){
          $sql = "SELECT * FROM $table WHERE    s_id=? AND pd_id=?";
          return $this->db->affectedRow($sql,$s_id,$pd_id);
        }
    
        public function getCartList($table){
          $S_ID = $_COOKIE['cart_item'];
          $sql = "SELECT * FROM $table WHERE s_id ='$S_ID' ORDER BY cart_id DESC";
          return $this->db->select($sql);
        }
    
        public function getCartListCount($table){
          $S_ID = $_COOKIE['cart_item'];
          $sql = "SELECT * FROM $table WHERE s_id ='$S_ID' ";
          return $this->db->cartListCount($sql);
        }
    
        public function pd_quantity_up($table,$data,$cond){
          return $this->db->update($table,$data,$cond);
    
        } 
        
    
    
    
      }
    
  • Tabs.php

  • <?php
    /**
    *  Tabs class
    */
      require_once "/../lib/DB.php";
      
      class Tabs 
      {
        private $db;
        
        function __construct()
        {
          $this->db = new DB();
        }
        public function fetchDynamicCat(){
          $sql = "SELECT * FROM tbl_product_cat";
          return $this->db->select($sql);
        }
    
        public function fetchProductByCat($getCatID){
          $sql = "SELECT * FROM tbl_product WHERE pd_cat_id = $getCatID ORDER BY    pd_id DESC";
          return $this->db->select($sql);
        }
    
    
      }
    
  • config.php

  • <?php
    define("HOSTName", "localhost");
    define("USERName", "root");
    define("USERpass", "");
    define("DBname", "ecommerce");
    
    
  • DB.php

  • <?php
    /**
    *  DB Class
    */      
          require_once "/../config/config.php";
    
        class DB 
        {
          public $DBConnect;
          private $HOSTName = HOSTName;
          private $USERName = USERName;
          private $USERpass = USERpass;
          private $DBname = DBname;
          function __construct()
          {
            $this->DBConnect();
          }
    
          public function DBConnect(){
            try{
            $this->DBConnect = new PDO('mysql:host='.$this->HOSTName.';dbname='.$this->DBname,$this->USERName,$this->USERpass);
    
            }catch(PDOException $e){
              echo "Connection Fail..".$e->getMessage();
            }
          }
    
          public function select($sql){
            $stmt = $this->DBConnect->prepare($sql);
            $stmt->execute();
            return $stmt->fetchAll(PDO::FETCH_ASSOC);
          }
    
          public function insert($table,$data){
            $keys = implode(',', array_keys($data));
            $values = ":".implode(',:', array_keys($data));
            
            $sql = "INSERT INTO $table($keys) VALUES($values)";
            $stmt = $this->DBConnect->prepare($sql);
            foreach ($data as $key => $value) {
              $stmt->bindValue(":$key",$value);
            }
            return $stmt->execute();
    
            }
    
            public function affectedRow($sql,$s_id,$pd_id){
              $stmt = $this->DBConnect->prepare($sql);
              $stmt->execute(array($s_id,$pd_id));
              return $stmt->rowCount();
            }
    
            public function cartListCount($sql){
            $stmt = $this->DBConnect->prepare($sql);
            $stmt->execute();
            return $stmt->rowCount();
            }
    
            public function update($table,$data,$cond){
              
              $getKeys ='';
              foreach ($data as $keys => $values) {
                $getKeys .="$keys=:pd_quantity,";
              }
              $getKeys = rtrim($getKeys,",");
    
            $sql = "UPDATE $table SET   $getKeys  WHERE  $cond";
              $stmt = $this->DBConnect->prepare($sql);
              foreach ($data as $key => $value) {
                $stmt->bindValue(":$key",$value);
              }
              $stmt->execute();
              return $stmt->rowCount();
    
            } 
    
            
    
          
    
        }
    
  • customer_action.php

  • action.php

  • index.php

  • Browse by Category

    php Ajax jQuery Codeigniter html css javascript

    Hi there! I am Rayhan Mondol, a PHP & JAVA Developer and ICT task is my programming blog. I'm fond of developing modern web applications. Contact me, I accept the paid task

    Latest Article

    post thumbnail

    Ajax Shopping Cart Customer Order View & account Update by using PHP OOP PDO(E-Commerce website-part 10)

    post thumbnail

    customer accout logout by using PHP OOP, PDO,COOKIE,AJAX(E-Commerce website-part 9)

    post thumbnail

    Customer Account Login by using PHP OOP PDO,AJAX (E-Commerce website-part 8)

    post thumbnail

    Customer Account Create by using PHP OOP PDO (E-Commerce website-part 7)

    post thumbnail

    Remove product from cart by using PHP OOP PDO(E-Commerce website-part 6)

    post thumbnail

    Ajax Shopping Cart update or Edit by using PHP OOP PDO (E-Commerce website-part 5)

    post thumbnail

    Ajax Shopping Cart View and calculate by using PHP OOP PDO (E-Commerce website-part 4)

    post thumbnail

    Drag and Drop Product Add to Cart by using PHP OOP PDO Ajax Jquery - E-Commerce project- (part-3)

    post thumbnail

    Product Add to Cart using PHP OOP PDO Ajax JQuery - E-Commerce project- (part-2)

    post thumbnail

    Create Dynamic Tabs using PHP OOP PDO - E-Commerce project- (part-1)

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal - Delete

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal Edit or Update

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal Read or view

    post thumbnail

    CodeIgniter AJAX CRUD using Bootstrap Modal-Create

    post thumbnail

    CodeIgniter AJAX CRUD(setup removing index.php from url)