new pisilinux web sites
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php namespace ZN\Shopping;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
class Update extends CartExtends
|
||||
{
|
||||
/**
|
||||
* Update item
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function item($code, array $data) : bool
|
||||
{
|
||||
if( empty(Properties::$items) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( Properties::$items as $row )
|
||||
{
|
||||
if( is_array($code) )
|
||||
{
|
||||
if(isset($row[key($code)]) && $row[key($code)] == current($code))
|
||||
{
|
||||
$code = $row[key($code)];
|
||||
}
|
||||
}
|
||||
|
||||
$key = array_search($code,$row);
|
||||
|
||||
if( ! empty($key) )
|
||||
{
|
||||
array_splice(Properties::$items, $i, 1);
|
||||
|
||||
if( count($data) !== count($row) )
|
||||
{
|
||||
foreach( $data as $k => $v )
|
||||
{
|
||||
$row[$k] = $v;
|
||||
}
|
||||
|
||||
array_push(Properties::$items, $row);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push(Properties::$items, $data); // @codeCoverageIgnore
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $this->driver->insert($this->key, Properties::$items);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user