Jump to content

Hiding come payment modules depending upon Zipcodes


Yogesh Raghav

Recommended Posts

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.com

you can check while checking out any item.

Thanks

Yogesh Raghav

Link to comment
Share on other sites

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. 

  • Like 1
Link to comment
Share on other sites

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

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...