遇到PHP错误未定义索引:on libraries / Cart.php行号:447

时间:2017-12-03 15:45:43

标签: php mysql codeigniter cart shopping-cart

我正在使用Codeigniter和购物车库购物车。我修改了购物车库,它适用于其他项目。知道它的含义吗?提前谢谢。

错误

A PHP Error was encountered 
Severity: Notice 
Message: Undefined index: 1679091c5a880faf6fb5e6087eb1b2dc
Filename: libraries/Cart.php
Line Number: 447

我的购物车库:

function _save_cart()
{
    unset($this->_cart_contents['total_items']);
    unset($this->_cart_contents['cart_total']);

    $total = 0;
    $items = 0;

    foreach ($this->_cart_contents as $key => $val)
    {
        if ( ! is_array($val) OR ! isset($val['price']) OR ! isset($val['qty']))
        {
            continue;
        }

        $total += ($val['price'] * $val[$key]['qty']-$val['price']*$val['qty']*$val['disc']/100);
        $items += $val['qty'];

        $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']-$this->_cart_contents[$key]['price']*$this->_cart_contents[$key]['qty']*$this->_cart_contents[$key]['disc']/100);
    }

    $this->_cart_contents['total_items'] = $items;
    $this->_cart_contents['cart_total'] = $total;

    if (count($this->_cart_contents) <= 2)
    {
        $this->CI->session->unset_userdata('cart_contents');

        return FALSE;
    }

    $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));

    return TRUE;
} 

第447行是:

$total += ($val['price'] * $val[$key]['qty']-$val['price']*$val['qty']*$val['disc']/100);

0 个答案:

没有答案