ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Customizing ProductCart
  New Posts New Posts RSS Feed - Prohibiting Post Office boxes from validating
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Prohibiting Post Office boxes from validating

 Post Reply Post Reply
Author
Message
hotshotsecret View Drop Down
Newbie
Newbie


Joined: 10-January-2013
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote hotshotsecret Quote  Post ReplyReply Direct Link To This Post Topic: Prohibiting Post Office boxes from validating
    Posted: 10-January-2013 at 4:03pm
Due to restrictions with our FedEx shipping manager in Quickbooks, we would like to force an actual street address in the 'ship to' section of the cart.

Here is what I have so far with the code (found in opc_updshipaddr.asp):
if pcShippingAddress="PO Box" then
pcErrMsg=pcErrMsg & "<li>Street Address is not valid</li>"
end if

Hopefully I'm on the right track & not over-thinking it...
Thanks!
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 10-January-2013 at 4:17pm
Hi @hotshotsecret,

I think you'd want this argument instead:
if InStr(LCase(pcShippingAddress),"po box") > 0 OR InStr(LCase(pcShippingAddress),"pobox") > 0 then
Back to Top
hotshotsecret View Drop Down
Newbie
Newbie


Joined: 10-January-2013
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote hotshotsecret Quote  Post ReplyReply Direct Link To This Post Posted: 10-January-2013 at 4:30pm
So I'm adding the following to line 75 or thereabouts, and it's not working yet. Continues to load shipping rates: 

if InStr(LCase(pcShippingAddress),"po box") > 0 OR InStr(LCase(pcShippingAddress),"pobox") > 0 then pcErrMsg=pcErrMsg & "<li>Street Address is not valid</li>" end if

Thanks for the quick response!
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 10-January-2013 at 5:58pm
Ok, I had a quick look under the hood here, and this is what I see:

First of all, you have the name of the variable slightly incorrect here. But handling it here is not the best place as this catches the "error" after the silent post back and then I find that all of the fields the user filled out on shipping info get lost and have to be re-entered. Not particularly elegant.

However, if handling it here, this is what you'd want. Find:
if pcStrShippingAddress="" then
pcErrMsg=pcErrMsg & "<li>"&dictLanguage.Item(Session("language")&"_opc_72")&"</li>"
end if
Right below that, add:
if InStr(LCase(pcStrShippingAddress),"po box") > 0 OR InStr(LCase(pcStrShippingAddress),"pobox") > 0 OR InStr(LCase(pcStrShippingAddress),"p.o.") > 0 then
pcErrMsg=pcErrMsg & "<li>"&"You may not ship to a Post Office Box"&"</li>"
end if

It would be better to handle it on onepagecheckoutJS.asp, though. However, that's more complicated and would take me some head-scratching time to sort out.
Back to Top
Greg Dinger View Drop Down
Certified ProductCart Developers
Certified ProductCart Developers
Avatar

Joined: 23-September-2006
Location: United States
Status: Offline
Points: 238
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greg Dinger Quote  Post ReplyReply Direct Link To This Post Posted: 11-January-2013 at 7:38am
We actually implemented something to address this, but in the end, and with all respect to Sean's helpful post, it was a bit more complex than he proposes.  I'm not in a position to go grab the code and paste it here, as it actually involved 2 hours of coding. 
 
What I recall we discovered was that even though something like the above approach seemed desirable, there is logic in OPC that defeated us in that regard.  I beleive that what happened was that we'd get the desired error message, but then the checkout process would blast past our error and head off to the shipping options portion of OPC. 
 
We ended up establishing a block of code in opc_chooseShpmnt.asp that tests pcCustSession_ShippingAddress from the pcCustomerSessions table, and thus addresses the issue.
 
If you find that the above approach is not successful, tap on me (via my site) next week and we can help sort this out for you.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.