Print Page | Close Window

Prohibiting Post Office boxes from validating

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=5405
Printed Date: 02-December-2024 at 6:29pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Prohibiting Post Office boxes from validating
Posted By: hotshotsecret
Subject: Prohibiting Post Office boxes from validating
Date 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!



Replies:
Posted By: Guests
Date 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


Posted By: hotshotsecret
Date 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!


Posted By: Guests
Date 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.


Posted By: Greg Dinger
Date 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.


-------------
GreyBeard Design Group

Certified ProductCart Developer

Web Design/Development/Hosting

http://tinyurl.com/5c8t4t" rel="nofollow - Add-Ons & Custom Code |



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net