0
我正在使用Magento 1.9.0.1,並且我創建了一個擴展。Magento - 奇怪的問題 - 注意:未定義變量
下面是我從SYSTEM.LOG文件時出現錯誤:
2015-01-17T16:56:16+00:00 ERR (3): Notice: Undefined variable: customer_id in /home/sportsdi/public_html/beta/app/code/local/VivasIndustries/PercentShipping/Model/Quote/Address/Total/Discount.php on line 187
下面是完整的文件:應用程序/代碼/本地/ VivasIndustries/PercentShipping /型號/報價/地址/總/折扣.PHP:
<?php
class VivasIndustries_PercentShipping_Model_Quote_Address_Total_Discount extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
public function __construct()
{
$this -> setCode('discountshipping_total');
}
/**
* Collect totals information about discount
*
* @param Mage_Sales_Model_Quote_Address $address
* @return Mage_Sales_Model_Quote_Address_Total_Shipping
*/
public function getShippingPerc()
{
$EnableDiscountShipping = Mage::getStoreConfig('checkout/percentshipping/active');
return ($EnableDiscountShipping==1);
}
/* public function SetPercSession(){
Mage::getSingleton('core/session')->setPcPayment('pc_payment');
$PcPay = Mage::getSingleton('core/session')->getPcSession();
if($PcPay == ""){
Mage::getSingleton('core/session')->setPcSession('no_redirect');
header("Location: http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
exit;
}
}
public function UnsPercSession(){
Mage::getSingleton('core/session')->unsPcPayment();
$PcPay = Mage::getSingleton('core/session')->getPcSession();
if($PcPay != ""){
Mage::getSingleton('core/session')->unsPcSession();
header("Location: http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
exit;
}
}
*/
public function collect(Mage_Sales_Model_Quote_Address $address)
{
parent :: collect($address);
$items = $this->_getAddressItems($address);
if (!count($items)) {
return $this;
}
$quote= $address->getQuote();
Mage::getSingleton('core/session', array('name' => 'frontend'));
//amount definition
if($this->getShippingPerc()) {
$PcPayment = Mage::getSingleton('core/session')->getPcPayment();
$PayOnDel = Mage::getSingleton('core/session')->getPayOnDel();
$Tax100 = Mage::getStoreConfig('checkout/percentshipping/percentshipping100tax_percent');
$Tax50 = Mage::getStoreConfig('checkout/percentshipping/percentshipping50tax_percent');
$Tax100ondel = Mage::getStoreConfig('checkout/percentshipping/percentshipping100ondeltax_percent');
if($PcPayment==""){
$discount = Mage::getStoreConfig('checkout/percentshipping/percentshipping100_percent');
}
if($PcPayment!=""){
$discount = Mage::getStoreConfig('checkout/percentshipping/percentshipping50_percent');
}
if($PayOnDel!=""){
$discount = Mage::getStoreConfig('checkout/percentshipping/percentshipping100ondel_percent');
}
$totals = array_sum($address->getAllTotalAmounts());
if($PcPayment!=""){
$discountAmount = ($totals * $discount/100);
$discountAmount = $discountAmount*2;
} else {
$discountAmount = ($totals * $discount/100);
}
//amount definition
//Tax definitions
if($PcPayment=="" && $PayOnDel==""){
if($Tax100 >= $discountAmount){
$discountAmount = $Tax100;
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
} else {
$discountAmount = $quote -> getStore() -> roundPrice($discountAmount);
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
}
}
if($PcPayment!="" && $PayOnDel==""){
if($Tax50 >= $discountAmount){
$discountAmount = $Tax50;
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
} else {
$discountAmount = $quote -> getStore() -> roundPrice($discountAmount);
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
}
}
if($PayOnDel!=""){
if($Tax100ondel >= $discountAmount){
$discountAmount = $Tax100ondel;
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
} else {
$discountAmount = $quote -> getStore() -> roundPrice($discountAmount);
$this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
$address->setData('discountshipping_total',$discountAmount);
Mage::getSingleton('core/session')->setPercentShipping($discountAmount);
return $this;
}
}
}
}
public static function getShippingPercent() {
$ret = Mage::getSingleton('core/session')->getPercentShipping();
return $ret;
}
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$EnableDiscount = Mage::getStoreConfig('checkout/percentpayment/active');
$MinPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_min_amt');
$MaxPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_max_amt');
$SessionGrandTotal = Mage::getModel('sales/quote')->loadByCustomer($customer_id)->getGrandTotal();
if($this->getShippingPerc()) {
parent :: fetch($address);
$amount = $address -> getTotalAmount($this -> getCode());
if ($amount != 0){
$address -> addTotal(array(
'code' => $this -> getCode(),
'title' => $this -> getLabel(),
'value' => $amount
));
}
return $address;
}
}
public function getLabel()
{
$TaxLabel = Mage::getStoreConfig('checkout/percentshipping/percentshipping_text');
return Mage::helper('percentshipping')->__($TaxLabel);
}
/**
* Get label
*
* @return string
*/
}
能否請你告訴我怎樣能得到有關該錯誤的更多信息,爲什麼談到和我如何能解決這個問題?這個錯誤對於擴展的正常工作有多重要,以及它可能會遇到什麼樣的問題。
在此先感謝!