1

I've been seeing an issue in the Magento system.log relating to the following but I'm a little bit of a novice and not certain how to resolve.

ERR (3): Strict Notice: Declaration of As_FreeShippingMsg_Block_Notice::helper() should be compatible with Mage_Core_Block_Abstract::helper($name)  in /app/code/community/As/FreeShippingMsg/Block/Notice.php on line 75

The below is the notice.php file which relates to the above error...

class As_FreeShippingMsg_Block_Notice extends Mage_Core_Block_Template
{
    public function __construct()
    {
        return parent::__construct();
    }

    private function getQuote()
    {
        return Mage::getSingleton('checkout/cart')->getQuote();
    }

    public function isFreeshippingMsgEnabled()
    {
        return $this->helper()->isEnabled();
    }

    public function getFreeshippingMsgAmount()
    {
        return $this->helper()->getAmount();
    }

    public function hasFreeShipping()
    {
        $total = $this->getTotal();

        if ($this->isFreeshippingMsgEnabled() && $this->getFreeshippingMsgAmount()) {
            return (float)$total >= $this->getFreeshippingMsgAmount();
        }
        return false;
    }

    public function getAdditionForFreeShipping()
    {
        $total = $this->getTotal();

        $freeShippingConfig = $this->getFreeshippingMsgAmount();

        if ($freeShippingConfig >= $total) {
            return $freeShippingConfig - $total;
        } else {
            return false;
        }
    }

    protected function getTotal()
    {
        $calculate_on = $this->helper()->getCalculateOn();

        switch($calculate_on) {
            case 'grandtotal' :
                $total = $this->getQuote()->getGrandTotal();
                break;
            case "subtotal" :
                $total = $this->getQuote()->getSubtotal();
                break;
            default :
                $total = $this->getQuote()->getGrandTotal();
        }

        return $total;
    }

    public function helper()
    {
        return Mage::helper('as_freeshippingmsg');
    }
}

And the following is the data.php helper file...

class As_FreeShippingMsg_Helper_Data extends Mage_Core_Helper_Abstract
{
    const PREFIX = 'freeshippingmsg/general/';

    public function getAmount()
    {
        return (float)$this->getConfig('amount', $this->getStoreId());
    }

    public function isEnabled()
    {
        return (bool)$this->getConfig('enabled', $this->getStoreId());
    }

    public function getEligibleText()
    {
        return $this->getConfig('eligible_text', $this->getStoreId());
    }

    public function getSpendMoreText()
    {
        return $this->getConfig('spend_more_text', $this->getStoreId());
    }

    public function getCalculateOn()
    {
        return $this->getConfig('calculate_on', $this->getStoreId());
    }

    protected function getStoreId()
    {
        return Mage::app()->getStore()->getStoreId();
    }

    protected function getConfig($field, $storeId)
    {
        return Mage::getStoreConfig(self::PREFIX . $field, $storeId);
    }
}

If anybody is able to confirm why I would be seeing this message and how to resolve that would be great.

0

2 Answers 2

1

There is no need to rewrite this method .... instead of $this->helper() use

$this->helper('as_freeshippingmsg')

... or add a "wrapper" that does not exist in parent class ...

protected function _getHelper()
{
    return Mage::helper('as_freeshippingmsg');
}
1

Your extension of ::helper() isn't compatible with the class you are extending. Even though you are manually setting the helper name in your custom file, you should still pass in the $name property if you are in strict mode, even if you don't use it.

You could probably even do this:

public function helper($name = 'as_freeshippingmsg')
{
    return parent::helper($name);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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