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
if(elm.attr("name") == "user_data[b_address]") {
if (lbl.hasClass('cm-required') || jQuery.is.blank(elm.val()) == false) {
if($('#sa').css('display') !== "block") {
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) {
this.form_message("Cannot ship to a PO Box", lbl);
is_ok = false;
set_mark = true;
}
}
}
}
// Shipping address first line
if(elm.attr("name") == "user_data[s_address]") {
if (lbl.hasClass('cm-required') || jQuery.is.blank(elm.val()) == false) {
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) {
this.form_message("Cannot ship to a PO Box", lbl);
is_ok = false;
set_mark = true;
}
}
}
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.