Yogesh Raghav Posted January 17, 2017 Share Posted January 17, 2017 I want to disallow or hide some payment modules like cod,paytm,debit-card/credit card for certain zipcodes area. its like while client is checking out he.she should see only any of these module (or two of them) depending upon his/her zip code area.as example if zip code is 110002,122001,122101 than COD,paytm should be visible or debit/credit card whoule be visible or vice versa.there are more than 10,000 Zip codes available in our store and we need to allow payment some modules depending on any of the zip codes available in between them.our store site is: https://www.shelltag.comyou can check while checking out any item.Thanks Yogesh Raghav Link to comment Share on other sites More sharing options...
Yogesh Raghav Posted January 17, 2017 Author Share Posted January 17, 2017 (edited) my mistake topic is Hiding Some Payment Modules Depending Upon Zipcodes (Pardon) Edited January 17, 2017 by Yogesh Raghav (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted January 17, 2017 Share Posted January 17, 2017 you could do this in one of 2 ways 1) You could edit each of those payment modules hookpayment function, and add your logic which would look at the carts shipping address zip code, and react appropriately. 2) You could edit/override either the ParentOrderController or OrderOpcController (5 page or 1 page checkout). These controllers handle calling each payment method during checkout. So you could add all of your logic to one of these controllers depending on what checkout method you use. 1 Link to comment Share on other sites More sharing options...
Yogesh Raghav Posted January 18, 2017 Author Share Posted January 18, 2017 can you please show me by giving an example like where i have to make the changes and use logic..i know that i have to enable check out option based on zip-codes so which particular files i need to make changes.can u please give a coding hint..iam a begginer in prestashop so i need help in this regards.thanks Link to comment Share on other sites More sharing options...
bellini13 Posted January 18, 2017 Share Posted January 18, 2017 this should give you an idea for option 1 //create an array of zipcodes that will cause this payment method to hide $zipcodes_to_ignore = array('110002', '122001', '122101'); //get the delivery address from the cart $delivery_address = new Address($this->context->cart->id_address_delivery); //the delivery address is not defined, so we return false to hide the payment method. //this could be optional, in the event you are using some custom OPC module which may not have collected the address yet if (!Validate::isLoadedObject($delivery_address)) return false; //get the zip code from the address $zipcode = $shipping_address->postcode; //check that the zipcode has a value. Some countries do not use them if ( isset($zipcode) && !empty($zipcode) ) //lastly, check if the zipcode is in the list of zipcodes to ignore for this payment module if (in_array($zipcode, $zipcodes_to_ignore)) return false; Link to comment Share on other sites More sharing options...
Yogesh Raghav Posted January 21, 2017 Author Share Posted January 21, 2017 (edited) great thanks..well and i just wanna know in which files shall i implement it as i have set of more than 10000 zip codes so in which specific files like order-opc etc i suppose to implement this logic. any idea would be appreciable. Edited January 21, 2017 by Yogesh Raghav (see edit history) Link to comment Share on other sites More sharing options...
Yogesh Raghav Posted February 6, 2017 Author Share Posted February 6, 2017 kindly reply please. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now