0

I'm using Magento 1.9.0.1.

I have very strange error reports in my system.log file.

Here is what the log says and repeat it many times:

2015-01-15T02:28:51+00:00 ERR (3): Notice: Undefined index: grand_total  in /home/sportsdi/public_html/beta/app/code/local/VivasIndustries/PercentPayment/Model/Quote/Address/Total/Discount.php on line 134
2015-01-15T02:28:51+00:00 ERR (3): Notice: Undefined index: grand_total  in /home/sportsdi/public_html/beta/app/code/local/VivasIndustries/PercentPayment/Model/Quote/Address/Total/Discount.php on line 66
2015-01-15T02:28:51+00:00 ERR (3): Notice: Undefined index: grand_total  in /home/sportsdi/public_html/beta/app/code/local/VivasIndustries/PercentShipping/Model/Quote/Address/Total/Discount.php on line 188
2015-01-15T02:28:51+00:00 ERR (3): Notice: Undefined variable: adress  in /home/sportsdi/public_html/beta/app/code/local/VivasIndustries/PercentShipping/Model/Quote/Address/Total/Discount.php on line 202

Here are the both files so you can check the code:

File: /app/code/local/VivasIndustries/PercentPayment/Model/Quote/Address/Total/Discount.php :

<?php
class VivasIndustries_PercentPayment_Model_Quote_Address_Total_Discount extends Mage_Sales_Model_Quote_Address_Total_Abstract
{

     public function __construct()
    {
         $this -> setCode('discount_total');
         }
    /**
     * Collect totals information about discount
     * 
     * @param Mage_Sales_Model_Quote_Address $address 
     * @return Mage_Sales_Model_Quote_Address_Total_Shipping 
     */

     public function getPercSmall()
    {

        $EnableDiscount = Mage::getStoreConfig('checkout/percentpayment/active');
         $MinPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_min_amt');
         $MaxPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_max_amt');
         $quote1 = Mage::getModel('checkout/session')->getQuote();
         $quoteData= $quote1->getData();
         $SessionGrandTotal = $quoteData['grand_total'];



        return ($EnableDiscount==1 && Mage::getStoreConfig('checkout/percentpayment/discountusergroup') == Mage::getSingleton('customer/session')->getCustomerGroupId() && $MinPrice <= $SessionGrandTotal && $MaxPrice >= $SessionGrandTotal);
    }


    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 getPerc()
    {

        $EnableDiscount = Mage::getStoreConfig('checkout/percentpayment/active');
         $MinPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_min_amt');
         $MaxPrice = Mage::getStoreConfig('checkout/percentpayment/percentpayment_max_amt');
         $quote1 = Mage::getModel('checkout/session')->getQuote();
         $quoteData= $quote1->getData();
         $SessionGrandTotal = $quoteData['grand_total'];


        $PcPayment = Mage::getSingleton('core/session')->getPcPayment();

        return ($MinPrice <= $SessionGrandTotal && $MaxPrice >= $SessionGrandTotal && $PcPayment == 'pc_payment');
    }

     public function collect(Mage_Sales_Model_Quote_Address $address)
    {
         parent :: collect($address);
         $items = $this->_getAddressItems($address);
         if (!count($items)) {
            return $this;
         }
         $quote= $address->getQuote();



         //amount definition


         if($this->getPerc())
            {




         $discount = Mage::getStoreConfig('checkout/percentpayment/percentpayment_percent');
         $setFee = Mage::getStoreConfig('checkout/fee/active');
        if($setFee==0)
        {
         $totals = array_sum($address->getAllTotalAmounts()) + VivasIndustries_PercentShipping_Model_Quote_Address_Total_Discount::getShippingPercent();
         } else {
         $totals = array_sum($address->getAllTotalAmounts()) + AG_Fee_Model_Fee::getFee();
         }
         $discountAmount = (-$totals * $discount / 100);


            $address->setDiscountAmount($discountAmount);
            $address->setBaseDiscountAmount($discountAmount);

            $quote->setDiscountAmount($discountAmount);      

         //amount definition

         $discountAmount = $quote -> getStore() -> roundPrice($discountAmount);
         $this -> _setAmount($discountAmount) -> _setBaseAmount($discountAmount);
         $address->setData('discount_total',$discountAmount);

         return $this;
         }
     }

    /**
     * Add discount totals information to address object
     * 
     * @param Mage_Sales_Model_Quote_Address $address 
     * @return Mage_Sales_Model_Quote_Address_Total_Shipping 
     */
     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');
         $quote1 = Mage::getModel('checkout/session')->getQuote();
         $quoteData= $quote1->getData();
         $SessionGrandTotal = $quoteData['grand_total'];

         if($this->getPerc())
            {
         parent :: fetch($address);
         $amount = $address -> getTotalAmount($this -> getCode());
         if ($amount != 0){
             $address -> addTotal(array(
                     'code' => $this -> getCode(),
                     'title' => $this -> getLabel(),
                     'value' => $amount
                    ));
         }

         return $adress;
         }
     }

     public function getLabel()
    {
         return Mage::helper('percentpayment')->__('50% Предплата');
    }

    /**
     * Get label
     * 
     * @return string 
     */

}

Here is the another file: /beta/app/code/local/VivasIndustries/PercentShipping/Model/Quote/Address/Total/Discount.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');
         $quote1 = Mage::getModel('checkout/session')->getQuote();
         $quoteData= $quote1->getData();
         $SessionGrandTotal = $quoteData['grand_total'];


        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 $adress;
         }

     }

     public function getLabel()
    {
         $TaxLabel = Mage::getStoreConfig('checkout/percentshipping/percentshipping_text');
         return Mage::helper('percentshipping')->__($TaxLabel);
    }

    /**
     * Get label
     * 
     * @return string 
     */

}

Can please please point me where is the problem and how i can fix it ? Thanks in advance!

0

you need to check the keys of the table of which you want to extract grand_total. this key probably does not exist (context issue ?).

for the address error, it misses a "d" in the variable you want to return. you wrote adress instead of address.

2
  • how about providing the snippet?
    – SR_Magento
    Jan 16 '15 at 0:15
  • because I have no idea of the context. if you explain me where things are called and how, I maybe can help. Jan 16 '15 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.