Magento Forum

Increasing Credit Card expiration years list
 
quanza
Sr. Member
 
Avatar
Total Posts:  97
Joined:  2008-12-02
Tokyo, Japan
 

Hi,

I’m trying to find where the Credit Card expiration years are being set, so I can increase the upper bound.  The place it’s being called is here:

app/code/core/Mage/Payment/Block/Form/Cc.php:  $years = $this->_getConfig()->getYears();

but I can’t find where the value is initially being set.  _getConfig()->getYears() isn’t defined anywhere (!!)

I need to increase the expiration years, as I’ve come across some credit cards that expire in 2019, and my system is only going to 2018 (!!).  How ... typical Magento :)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Manos Dilaverakis
Member
 
Total Posts:  49
Joined:  2009-02-25
 

The list is defined by the getYears() method in Mage_Payment_Model_Config (app/code/core/Mage/Payment/Model/Config.php).

Here’s how you get from $years = $this->_getConfig()->getYears() to that:

$this is the current class (Mage_Payment_Block_Form_Cc) which has a method _getConfig(). All _getConfig() does is return Mage::getSingleton(’payment/config’)

Mage::getSingleton(’payment/config’) gets you an object of type Mage_Payment_Model_Config (/app/code/core/Mage/Payment/Model/Config.php). So all you need to do is open that class and look for the method getYears(), which as it turns out, returns the next 10 years including the current one.

From here you can follow the easy, wrong path and just change that method in the core file, or the harder, but right path and override the method in a module of your own.

 
Magento Community Magento Community
Magento Community
Magento Community
 
quanza
Sr. Member
 
Avatar
Total Posts:  97
Joined:  2008-12-02
Tokyo, Japan
 

Thank you Manos!  Strange, I grepped the entire code tree looking for that one function and it slipped through my fingers.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top