Search code examples
phpmagentoccavenue

CCAvenue integration with Magento 1.6.2


Had received a module from CCAVENUE and it was working fine with Magento 1.6.2... but just recently it has started giving an error of undefined variable dec..

Has anybody had a similar issue? And any work arounds tried... any help and suggestion would be greatly appreciated.

Error

Notice: Undefined variable: dec in /home/maationl/public_html/app/code/core/Mage/Avenues/controllers/libfuncs.php3

And the relevant code

<?php 
function cdec($num) { 
    for ($n = 0 ; $n < strlen($num) ; $n++) { 
        $temp = $num[$n] ; 
        $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
    } 
    return $dec;
} 
?>

Solution

  • The precise error you mention can be fixed by defining $dec before using it.

    <?php 
    function cdec($num) { 
        $dec = 0;
        for ($n = 0 ; $n < strlen($num) ; $n++) { 
            $temp = $num[$n] ; 
            $dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);
        } 
        return $dec;
    } 
    ?>
    

    What I suspect happened is that you enabled error reporting and you're now getting errors from the plugin which have been in there forever.

    It usually isn't advisable to edit code which is in the core of Magento or plugins you didn't create yourself (for upgradability) but looking at that path it might not actually be a proper Magento module.

    I've had the pleasures of adding payment providers to Magento with plugins provided by the payment gateway which were riddled with bugs, not tested quite well enough, or not even written by the Magento guidelines...

    You're probably better of editing this one file, document it, and remember to keep that documentation on hand once you do an upgrade.