我工作的一個電子商務網站,當用戶添加產品到購物籃的第一次,我碰到下面的錯誤,PHP的幫助,會話錯誤可能嗎?
遇到一個PHP錯誤
嚴重性:注意
消息:未定義指數:ORDERDETAILS
文件名:庫/ MY_Cart.php
行號:59一個PHP錯誤是 遇到
嚴重性:警告
消息:不能更改頭 信息 - 頭已經 發送(輸出開始 /無功/網絡/虛擬主機/ akulaliving .COM/httpdocs資料/ CI-1.7.3 /庫/ Exceptions.php:166)
文件名:庫/ session.php文件
行號:662
的增加了產品與下面的代碼籃下,
if ($this->input->post('btnAddToBag'))
{
$derivativeId = $this->input->post('selDerivative-1');
$quantity = $this->input->post('selQuantity');
$derivative = $this->Product_model->GetProducts(array('pdId' => $derivativeId), 'small');
// Add item to shopping bag.
$attributes = $this->Product_model->GetProductDerivatives(array('pdId' => $derivativeId));
$this->Checkout_model->AddProduct($derivative, $attributes, $quantity);
$this->data['message'] = 'Item added to Shopping Bag.';
// Update Delivery Price
$this->Checkout_model->updateDelivery(49);
//get the bag details
$this->data['items'] = $this->Checkout_model->GetProducts();
}
被調用的模型函數是這樣的,
function AddProduct($derivative, $attributes, $quantity)
{
$data = array(
'id' => $derivative->pdId,
'qty' => $quantity,
'price' => ($derivative->productSavingType == 'none' ? $derivative->productPrice : $derivative->productSavingPrice),
'name' => $derivative->productTitle,
'attributes' => $attributes['attributeValues'],
'refNo' => $derivative->pdRefNo,
'productId' => $derivative->productId,
'set' => $derivative->productIsSet,
'hasImage' => $derivative->hasImage,
'imageUrl' => $derivative->imageUrl,
'imageAlt' => $derivative->imageAlt,
'stockLevel' => $derivative->pdStockLevel,
'leadTime' => $derivative->pdLeadTime
);
$data['nonDiscountedPrice'] = $data['price'];
if ($derivative->productSavingType == 'end-of-season')
{
$data['nonDiscountedPrice'] = $derivative->productPrice;
}
$this->cart->insert($data);
}
錯誤是抱怨碼是以下,
function _insert($items=array())
{
if (isset($items['options']) AND count($items['options']) > 0)
{
$rowid = md5($items['id'].implode('', $items['options']));
}
else
{
$rowid = md5($items['id']);
}
if (isset($this->_cart_contents[$rowid]))
{
if (!isset($items['qty']))
{
return FALSE;
}
// Already Exists, we need to update the total for this item
$new_qty = $items['qty'];
$items['qty'] = $items['qty'] + $this->_cart_contents[$rowid]['qty'];
$items['rowid'] = $rowid;
if ($this->_update($items))
{
return TRUE;
}
return FALSE;
}
// Doesn't exist, we need to insert this item.
if (parent::_insert($items))
{
// Update our total.
if (isset($this->_cart_contents[$rowid]))
{
$this->real_total_items += $this->_cart_contents[$rowid]['qty'];
if ($this->_cart_contents['orderDetails']['discount'] > 0)
{
$this->_cart_contents[$rowid]['price'] = $this->_cart_contents[$rowid]['nonDiscountedPrice'];
$this->_save_cart();
}
}
return TRUE;
}
return FALSE;
}