i want to display chosen quantity when i view products. For example i have 2 apple in my basket. i want when i view this apple's page see that i've already chosen 2. i hope u'll understand
public function countProductInBasket($iProduct){ $oFFS=FlatFilesSerialize::getInstance(); $iBasket=$_SESSION['iCustomer'.LANGUAGE]; $aBasket=$oFFS->getData(DB_ORDERS_TEMP); // assign file with basket data if(isset($aBasket[$iBasket][$iProduct]['iQuantity'])&&$aBasket[$iBasket][$iProduct]['iQuantity']>0) // if there is something with customer_id and just viewed product return $aBasket[$iBasket][$iProduct]['iQuantity']; // return the basket quantity of this product }
$iInBasket=$oProduct->countProductInBasket($iProduct); if(is_numeric($iInBasket)&&$iInBasket>0){ echo 'there '.(($iInBasket==1)?' is':' are').' already '.$iInBasket.(($iInBasket==1)?' piece':' pieces').' in basket'; // we check here the count of product in basket and depending on it (1 or more) we set singular ("is", "piece") or plural ("are", "pieces") }
The words: "there are/is already ... piece/s in basket" you should fit to languages database. That's all
Can You wait till tuesday? I'm right now on a business trip and don't have local server on my laptop. I have already the solution in my head (driving 1000 km gives enough time to think :-) )
OK, we do it another way, we make it new. 1. Cancel the changes I wrote above; 2. /core/orders.php -> find function generateBasket() 3. In this function under: