News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Not to Ship on P.O Boxes

Started by navdeep, February 14, 2010, 16:58:02 PM

Previous topic - Next topic

navdeep

Hello Virtuemart Developers,

I need your help... i dont want to accept orders for P.O Boxes.. in simple i need a prompt error message when some one
- Add New Shipping Address
- Default (Use same as Billing Address)
- Update Existing Shipping Address

i found a function in ps_checkout.php
        function validate_shipto(&$d) {
//TODO to be implemented
        }


Something is missing...i want to validate shipping address against PO Box

i have already function to do this..function func_is_postal_box($address) {
  $postalBoxRegex = '/^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])(\s+)([0-9]+)/iD';

  @preg_match($postalBoxRegex, trim($address), $isPostalBox);

  if (is_array($isPostalBox) && (count($isPostalBox) > 0)) {
    return true;
  }
  else {
    return false;
  }
}

lowmips

Catch the Billing address in ps_user.php (look at the validation methods, add your code there).
Catch the Shipping addresses in ps_user_address.php (again, add your code to the validation methods).

use the global $vmLogger to throw an error, warning, whatever like this:
$vmLogger->err('Sorry, we do not ship to P.O. addresses');

-Reggie
Visit my website at www.lowmips.com
View my newsletters Here (sign up for newsletters on the front page of my website)

navdeep

 :) Thanks lowmips for you kind help...But Problem still presists  :'(
Some users have already Addresses of PO Boxes... So i need validation during Step 1 Checkout Process. Please Help

nicodesigns

#3
For the files:
administrator/components/com_virtuemart/classes/ps_user.php (line 128)
administrator/components/com_virtuemart/classes/ps_user_address.php (line 104)

I inserted the following code:

function func_is_postal_box($address) {
  $postalBoxRegex = '/^([pP]{1}(.*?)[oO]{1}(.*?))?([bB][oO]?[xX])(\s+)([0-9]+)/iD';

  @preg_match($postalBoxRegex, trim($address), $isPostalBox);

  if (is_array($isPostalBox) && (count($isPostalBox) > 0)) {
  $vmLogger->err('Sorry, we do not ship to P.O. Boxes');
    return true;
  }
  else {
    return false;
  }
}

I went to add a new shipping address using a PO Box and it still accepted it.
What did I do incorrectly?  ???

Thanks!

orchid1

does any one know where to insert the code above?
I inserted the function into the code but I am not sure where to call the function or what variable I pass it. I recognize that I have to pass the address but I am not sure what VM calls that variable or on what line to make the call to the function
for instance where would I write "func_is_postal_box($vm_address);"
thus triggering the validation function to check for PO BOX?

I have the code for the regular expression per the previous post I'm just not sure where to make the call to it.

Anybody have 5 minutes to post back I would be happy to make a small contribution to your paypal account.
Thanks


nicodesigns

Hi Orchid,

I hired Lowmips to fix this with FedEx.  Perhaps he can help you too.

cchrisgates

Short of hiring someone to add this function, has anyone figured out a solution.  Seems this should be implemented in the shipping modules/store configuration