本文整理汇总了PHP中Properties::items方法的典型用法代码示例。如果您正苦于以下问题:PHP Properties::items方法的具体用法?PHP Properties::items怎么用?PHP Properties::items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties::items方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: item
public function item($code, array $data) : bool
{
Properties::$items = $this->driver->select(md5('SystemCartData')) ?? NULL;
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);
}
}
$i++;
}
return $this->driver->insert(md5('SystemCartData'), Properties::$items);
}
示例2: prices
public function prices() : int
{
Properties::$items = $this->driver->select(md5('SystemCartData')) ?? NULL;
if (empty(Properties::$items)) {
return 0;
}
$total = 0;
foreach (Properties::$items as $values) {
$quantity = isset($values['quantity']) ? $values['quantity'] : 1;
$price = isset($values['price']) ? $values['price'] : 0;
$total += $price * $quantity;
}
return $total;
}
示例3: item
public function item(array $product) : bool
{
// Ürünün adet parametresinin belirtilmemesi durumunda 1 olarak kabul edilmesi istenmiştir.
if (!isset($product['quantity'])) {
$product['quantity'] = 1;
}
// Sepettin daha önce oluşturulup oluşturulmadığına göre işlemler gerçekleştiriliyor.
if ($sessionCart = $this->driver->select(md5('SystemCartData'))) {
Properties::$items = $sessionCart;
}
array_push(Properties::$items, $product);
$this->driver->insert(md5('SystemCartData'), Properties::$items);
Properties::$items = $this->driver->select(md5('SystemCartData'));
return true;
}
示例4: item
public function item($code) : \stdClass
{
Properties::$items = ($sessionCart = $this->driver->select(md5('SystemCartData'))) ? $sessionCart : '';
if (empty(Properties::$items)) {
return (object) [];
}
foreach (Properties::$items as $row) {
if (!is_array($code)) {
$key = array_search($code, $row);
} else {
if (isset($row[key($code)]) && $row[key($code)] == current($code)) {
$key = $row;
}
}
if (!empty($key)) {
return (object) $row;
}
}
}