PHP Classes

please add a total sum function...

Recommend this page to a friend!

      Shopping Cart  >  Shopping Cart package blog  >  How to Create a Simpl...  >  All threads  >  please add a total sum function...  >  (Un) Subscribe thread alerts  
Subject:please add a total sum function...
Summary:please add a total sum function...
Messages:2
Author:mahdi ghas
Date:2015-09-21 12:49:04
 

  1. please add a total sum function...   Reply   Report abuse  
Picture of mahdi ghas mahdi ghas - 2015-09-21 12:49:04
hi
please add a total sum function...
tnx

  2. Re: please add a total sum function...   Reply   Report abuse  
Picture of Ashraf Gheith Ashraf Gheith - 2015-09-22 07:26:00 - In reply to message 1 from mahdi ghas
public function totalCart(){
$total = 0;
if($_SESSION['cart'] != ""){
$cart = json_decode($_SESSION['cart'], true);
for($i=0;$i<count($cart);$i++){
$lines = $this->getProductData($cart[$i]["product"]);
$total += ($lines->price*$cart[$i]["count"]);
}
}
return $total;
}

Just add this method to the cart.