facing this error undefined variable framework/App/ErrorHandler
[2018-10-06 12:45:23] main.CRITICAL: Notice: Undefined variable: vls in /home/dukaania/public_html/testing2/app/code/Sugarcode/Test/Model/Total/Fee.php on line 46 {"exception":"[object] (Exception(code: 0): Notice: Undefined variable: vls in /home/dukaania/public_html/testing2/app/code/Sugarcode/Test/Model/Total/Fee.php on line 46 at /home/dukaania/public_html/testing2/vendor/magento/framework/App/ErrorHandler.php:61)"} []
Please someone review my code:
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Sugarcode\Test\Model\Total;
class Fee extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
/**
* Collect grand total address amount
*
* @param \Magento\Quote\Model\Quote $quote
* @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
* @param \Magento\Quote\Model\Quote\Address\Total $total
* @return $this
*/
protected $_coreSession;
protected $quoteValidator = null;
protected $vls = null;
public function __construct(\Magento\Quote\Model\QuoteValidator $quoteValidator, \Magento\Framework\Session\SessionManagerInterface $coreSession)
{
$this->quoteValidator = $quoteValidator;
$this->_coreSession = $coreSession;
}
public function getValue()
{
$this->_coreSession->start();
return $this->_coreSession->getMyValue(); //Get value from customer session
}
public function collect(
\Magento\Quote\Model\Quote $quote,
\Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
\Magento\Quote\Model\Quote\Address\Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
global $total_cost;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$customerSession->setValue($total_cost); //set value in customer session
$vluas= $customerSession->getValue();
$this->vls = $vluas[0].$vluas[1];
$exist_amount = 0; //$quote->getFee();
$fee = $this->vls; //Excellence_Fee_Model_Fee::getFee();
$balance = $fee - $exist_amount;
$total->setTotalAmount('fee', $balance);
$total->setBaseTotalAmount('fee', $balance);
$total->setFee($balance);
$total->setBaseFee($balance);
$total->setGrandTotal($total->getGrandTotal() + $balance);
$total->setBaseGrandTotal($total->getBaseGrandTotal() + $balance);
return $this;
}
protected function clearValues(Address\Total $total)
{
$total->setTotalAmount('subtotal', 0);
$total->setBaseTotalAmount('subtotal', 0);
$total->setTotalAmount('tax', 0);
$total->setBaseTotalAmount('tax', 0);
$total->setTotalAmount('discount_tax_compensation', 0);
$total->setBaseTotalAmount('discount_tax_compensation', 0);
$total->setTotalAmount('shipping_discount_tax_compensation', 0);
$total->setBaseTotalAmount('shipping_discount_tax_compensation', 0);
$total->setSubtotalInclTax(0);
$total->setBaseSubtotalInclTax(0);
}
/**
* @param \Magento\Quote\Model\Quote $quote
* @param Address\Total $total
* @return array|null
*/
/**
* Assign subtotal amount and label to address object
*
* @param \Magento\Quote\Model\Quote $quote
* @param Address\Total $total
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
{
global $total_cost;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$customerSession->setValue($total_cost); //set value in customer session
$vluas= $customerSession->getValue();
$this->vls = $vluas[0].$vluas[1];
//print_r($vls);
return [
'code' => 'fee',
'title' => 'Shipping Price',
'value' => $this->vls
];
}
/**
* Get Subtotal label
*
* @return \Magento\Framework\Phrase
*/
public function getLabel()
{
return __('Fee');
}
}