Jump to content
xaviour

Checking postcode and city name

Recommended Posts

HI,

 

I need to check the postcode where I am going to deliver before accepting payment. if the post code matched then proceed to payment else display an error message.

 

I know its a very easy thing and am sure one of you can help me figure this out.

 

Thank you.

Share this post


Link to post
Share on other sites

It's not such a quick fix, especially if you do it right and not use a simple Javascript for it.

 

One approach would be to modify the function that validates a zipcode, and return an invalid response if the post code does not match the ones you wish to use.

 

Keep in mind that it requires some coding language, and may have other effects that I am not thinking about at the moment.

 

A simpler option would be the following shipping module http://www.prestashop.com/forums/index.php?/topic/148747-module-localized-shipping-set-shipping-rates-by-country-state-or-zipcode-range-or-wildcard/

It lets you specify shipping by country state or post code (including ranges and wildcard), which would allow you to limit shipping only to certain post codes, without having to modify any code.

Share this post


Link to post
Share on other sites

Hmm.. ya but that would just complicate things for me as of today.

 

However, is it possible As currently I am only delivering in one pin-code area and city. I wanted to know if its possible to set the city and pincode to a default value and prevent the customer from editing it (disable in form).

Share this post


Link to post
Share on other sites

Everything is possible, you would have to edit some core files or create overrides.

You may be able to only modify the address class to always return the same zip & city.

Share this post


Link to post
Share on other sites

Ya that's what i am trying to do now but getting errors like a blank screen.

 

Think you can give me a pointer or two on how to do it.

 

Thanks in advance. :)

Share this post


Link to post
Share on other sites

I already gave a pointer, I cannot write the code for you.

 

If you get a black screen, try to turn on error reporting in /config/config.inc.php line #28.

 

If you have any specific questions, we'll try to answer them.

Share this post


Link to post
Share on other sites

Hmm... thanks for your help but I had figured that class based on my limited programming lang but don't know how to set the values, that's why I posted here. Hoping someone might have a better solution.

 

As I am not a programmer but an entrepreneur.

Share this post


Link to post
Share on other sites

I gave you the most simple and easy solution, which uses a module for postcode based shipping, that requires no programming skills.

Share this post


Link to post
Share on other sites

OK! Solved!

 

All I needed to do was edit the isPostCode($postcode) & isCityName($city) in Validate.php to check the city name and post code entered. Preferably override it.

 

well tomreg this was easier wasn't it ;):)

Share this post


Link to post
Share on other sites

Sure was, and I'm sure you get more satisfaction from figuring it out (which is always the way I chose to go).

 

However, it didn't sound like you were interested in doing any changes before, but rather have someone else do them for you (which is the easiest way)

Share this post


Link to post
Share on other sites

LOL!

I only post here only after trying out everything I know about programming and searching the forum about similar topics.

 

As far as I know the whole point of having a forum is to help users out (programmers & "merchants") but currently the whole point of this forum is to sell modules irrespective of the users needs.I am not criticizing this approach as its a very effective way of selling but trying to highlight that a certain level of discretion is necessary.

 

PS: you had just told me to look into Validate.php ,I would have done the rest as I did not know where the code gets validated.

Share this post


Link to post
Share on other sites

The forum is indeed for helping people, which is often done with a module, especially when the question is not really a specific code related question, but rather a "how do I do X and Y", rather than "I tried X and Y and got the following error"

 

While those also get answered, as I did trying to point you in the right direction, and told you how to troubleshoot the white screen you got, you never mentioned an error you got, or any of the things you tried to do.

 

Instead you took the "I'm not a developer approach" which is not likely going to get you many answers.

 

I can't speak for others, but I try to help people that seem to want help resolving issues and not have others solve their problems...

  • Like 1

Share this post


Link to post
Share on other sites

OK! Solved!

 

All I needed to do was edit the isPostCode($postcode) & isCityName($city) in Validate.php to check the city name and post code entered. Preferably override it.

 

well tomreg this was easier wasn't it ;):)

 

Hi there, I would like accept order from City ABC only What changes I should do in validate.php or in isCityName($city) to make this work. Looking forward for your help. Thanks in advance

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More