Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Disable UPS for PO Box addresses

    I know there is a mod to ban PO boxes altogether, but is there a way to disable a specific shipping method when the address is a po box?

    TIA!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Disable UPS for PO Box addresses

    You could try customizing the code in:
    /includes/modules/shipping/ups.php

    with the code in RED:
    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);
          }
    
    // bof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb']
    if (!IS_ADMIN_FLAG) {
    global $order;
    $street_address = $order->delivery['street_address'];
    // BEGIN PO Box Ban street address
        if ( preg_match('/PO BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $street_address) ) {
          $error = true;
        }
    
    $suburb = $order->delivery['suburb'];
    // BEGIN PO Box Ban suburb
        if ( preg_match('/PO BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $suburb) ) {
          $error = true;
        }
    
        if ($error) {
          $this->enabled = false;
        }
    }
    // eof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb']
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_ZONE > 0) ) {
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Disable UPS for PO Box addresses

    Thank you, I tried it in flat.php as a test because UPS isn't actually installed yet, and kept getting this log error:

    PHP Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in /***/public_html/includes/modules/shipping/flat.php on line 69
    This is that section of code in flat.php, with line 69 highlighted in red:

    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
          }
    
        // bof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb'] if (!IS_ADMIN_FLAG) { global $order; $street_address = $order->delivery['street_address'];
    // BEGIN PO Box Ban street address
        if ( preg_match('/PO BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $street_address) ) {
          $error = true;
        }
    
    $suburb = $order->delivery['suburb'];
    // BEGIN PO Box Ban suburb
        if ( preg_match('/PO BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $suburb) ) {
          $error = true;
        }
    
        if ($error) {
          $this->enabled = false;
        }
    } 
    // eof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb']   
        
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
    Quote Originally Posted by Ajeh View Post
    You could try customizing the code in:
    /includes/modules/shipping/ups.php

    with the code in RED:
    Code:
          // disable only when entire cart is free shipping
          if (zen_get_shipping_enabled($this->code)) {
            $this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);
          }
    
    // bof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb']
    if (!IS_ADMIN_FLAG) {
    global $order;
    $street_address = $order->delivery['street_address'];
    // BEGIN PO Box Ban street address
        if ( preg_match('/PO BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $street_address) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $street_address) ) {
          $error = true;
        }
    
    $suburb = $order->delivery['suburb'];
    // BEGIN PO Box Ban suburb
        if ( preg_match('/PO BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/BOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/POBOX/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O\./si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/P\.O/si', $suburb) ) {
          $error = true;
        } else if ( preg_match('/PO\./si', $suburb) ) {
          $error = true;
        }
    
        if ($error) {
          $this->enabled = false;
        }
    }
    // eof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb']
    
          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_UPS_ZONE > 0) ) {
    Last edited by Danielle; 6 Aug 2014 at 06:08 PM.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Disable UPS for PO Box addresses

    Check the code that I posted as your code looks like you missed a chunk ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Disable UPS for PO Box addresses

    Hmmm it looks identical to me. What chunk did I miss?

    Quote Originally Posted by Ajeh View Post
    Check the code that I posted as your code looks like you missed a chunk ...

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Disable UPS for PO Box addresses

    I see what looks so odd, you have all the code on 1 line for:
    Code:
        // bof: block PO BOX addresses in $order->delivery['street_address'] or $order->delivery['suburb'] if (!IS_ADMIN_FLAG) { global $order; $street_address = $order->delivery['street_address'];
    Try putting the code like I have it as it looks like you have turned the start of the code into a comment ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v151 Multiple Ship - From addresses for Shipping (UPS module)
    By samueljjs in forum Addon Shipping Modules
    Replies: 1
    Last Post: 22 Apr 2014, 03:03 PM
  2. Disable UPS Ground for some states?
    By brushwoodnursery in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 19 Nov 2011, 05:48 PM
  3. UPS and P.O. Box Addresses
    By mikestaps in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 20 Oct 2010, 02:32 PM
  4. disable side box column for ez-pages
    By subb in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 15 Dec 2006, 09:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg