Dynamically Get Zip Code on Shipping Form – Magento 1.9

magento-1.9onepage-checkoutzipcode

I would like to get the zip code after the user is done inputting.
I am using a One Page Checkout for this. I am currently using a code that get the zip code on the user information being saved on the system. By the way I would like to add the code on one of the custom module's model. is this possible?

Best Answer

Add this code on the OnePageCheckout Controller(IndexController.php):

$billing_data = $this->getRequest()->getPost('billing', array());

and get the Zip Code:

$billing_data['postcode']

as you wish to use it on other module, just set it on the core session:

Mage::getSingleton('core/session')->unsZipCode();
Mage::getSingleton('core/session')->setZipCode($ZipCode);

and Get value from session in your module like:

$zipCode = Mage::getSingleton('core/session')->getZipCode();

this will allow you to get the Zip Code whenever the user is done inputting.

Related Topic