Prevent shipping to PO Box (how to)

Figured I’d start sharing how I’m doing the custom modifications I’m making to CS-Cart…



I’m working with CS-Cart version 2.0.15



Edit the /js/core.js file and add this at line 1483:


// Billing address first line<br />
			if(elm.attr("name") == "user_data[b_address]") {<br />
				if (lbl.hasClass('cm-required') || jQuery.is.blank(elm.val()) == false) {<br />
					if($('#sa').css('display') !== "block") {<br />
						if(elm.val().indexOf( 'po box' ) !== -1 || elm.val().indexOf( 'PO Box' ) !== -1 || elm.val().indexOf( 'P.O. Box' ) !== -1 || elm.val().indexOf( 'p.o. box' ) !== -1 || elm.val().indexOf( 'po Box' ) !== -1 || elm.val().indexOf( 'p.o. Box' ) !== -1 || elm.val().indexOf( 'p.o Box' ) !== -1 || elm.val().indexOf( 'p.o box' ) !== -1 || elm.val().indexOf( 'P.O Box' ) !== -1|| elm.val().indexOf( 'P.O box' ) !== -1) {<br />
								this.form_message("Cannot ship to a PO Box", lbl);<br />
								is_ok = false;<br />
								set_mark = true;<br />
						}<br />
					}<br />
				}<br />
			}<br />
			<br />
		<br />
		// Shipping address first line<br />
				if(elm.attr("name") == "user_data[s_address]") {<br />
					if (lbl.hasClass('cm-required') || jQuery.is.blank(elm.val()) == false) {<br />
						if(elm.val().indexOf( 'po box' ) !== -1 || elm.val().indexOf( 'PO Box' ) !== -1 || elm.val().indexOf( 'P.O. Box' ) !== -1 || elm.val().indexOf( 'p.o. box' ) !== -1 || elm.val().indexOf( 'po Box' ) !== -1 || elm.val().indexOf( 'p.o. Box' ) !== -1 || elm.val().indexOf( 'p.o Box' ) !== -1 || elm.val().indexOf( 'p.o box' ) !== -1 || elm.val().indexOf( 'P.O Box' ) !== -1 || elm.val().indexOf( 'P.O box' ) !== -1) {<br />
								this.form_message("Cannot ship to a PO Box", lbl);<br />
								is_ok = false;<br />
								set_mark = true;<br />
						}<br />
					}	<br />
				}
```<br />
<br />
This is for one page checkout. What this does is prevent the user from inserting anything containing "po box" or several variations into the shipping address fields. If they elect to ship to billing address, they cannot put a po box as their billing address either.

Never thought about this - will try it out. Thanks!

[COLOR=“DarkOrchid”]Does this appear to be working for everyone ? This is something we could really use for those persons who don’t quite understand English[/COLOR] :rolleyes:

i need this feature long long time ago. will check it out. thanks for sharing.

I implemented this one a store I recently designed, so you can see it in action here: [url]http://www.theactigraph.com/store/[/url]

[quote name=‘trevorgehman’]I implemented this one a store I recently designed, so you can see it in action here: [URL]http://www.theactigraph.com/store/[/URL][/quote]



Just FYI “News & Events” goes to a blank page. Otherwise a really nice Web site!

Anyone know how to do this for version 3.0.1?

Anyone know how to do this with recent version?