Thread: USPS Check Code

Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    95
    Plugin Contributions
    1

    Default USPS Check Code

    I had a little look at the beta and checked if my module worked under the new version.

    I'm wondering whether the USPS check code built into /admin/modules.php line 30-32 should be moved to the usps::check() method.

    It's not really a problem, but since USPS is no longer pre-installed I thought it would make more sense.

    I was using modules.php to add some checking related to the modified version. Now I just realised the modules check() method could be used instead to display warning/error html before rendering the table of shipping modules.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    64,672
    Plugin Contributions
    6

    Default Re: USPS Check Code

    I would agree that you should move the check into the USPS module itself ... the less you touch the core the better ...

    Something like:
    Code:
        if (IS_ADMIN_FLAG) {
          if (defined('MODULE_SHIPPING_USPS_STATUS')) {
            //Check USPS Package Dimensions config
            $dimensions=zen_get_configuration_key_value('MODULE_SHIPPING_USPS_DIMENSIONS');
            $dimensions=preg_replace(array('/^[\s,:]*/','/[\s,:]*$/'),'',$dimensions); //Strip leading and trailing whitespace + separators
            $dim_array=preg_split('/[\s,:]+/',$dimensions);
            foreach ($dim_array as $k=>$dparam) {
              if (!preg_match('/^(?P<dimensions>(?:\d{1,3}(?:\.\d{1,5})?x\d{1,3}(?:\.\d{1,5})?x\d{1,3}(?:\.\d{1,5})?)|regular);(?P<weight>\d{1,2}(?:\.\d{1,5})?|\+)(?:;(?P<container>[NRV]))?$/', $dparam)) {
                $dimerr.='<br /><br />The parameters set in Package Dimensions Config #'.($k+1).' are invalid'.($dimerr?'.':(', please enter valid shipping parameters. Current setting will be overridden with default: \'regular;+\''));
              }
            }
            if (preg_match('/^\s*$/',$dimensions)) {
              $shipping_errors.='<br />You must enter valid dimension values. Current setting will be overridden with default: \'regular;+\'';
            }
            $shipping_errors.=$dimerr;
            $this->title .= ($shipping_errors ? '<span class="alert">' . ' Dimension Values Errors ' . '</span>' : '');
            $this->description .= '<span class="alert">' . $shipping_errors . '</span>';
          }
        }
    
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
    I would also suggest moving the sent/recieved files to the /cache so that it is not using the root of the shop ...
    Code:
            file_put_contents(DIR_FS_SQL_CACHE . '/uspsRecieve.xml', $body);
            file_put_contents(DIR_FS_SQL_CACHE . '/uspsSend.xml', $output);
    Last edited by Ajeh; 3 Sep 2011 at 05:36 PM.
    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: v1.5.1]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  3. #3
    Join Date
    Dec 2006
    Location
    Australia
    Posts
    95
    Plugin Contributions
    1

    Default Re: USPS Check Code

    Thanks for the suggestions

    I will have it updated in my next version.

 

 

Similar Threads

  1. Check new users for zip code
    By jmacdoug in forum General Questions
    Replies: 2
    Last Post: 29 Jul 2011, 07:02 AM
  2. USPS First Class International - Adding a comment on check out
    By Sharni in forum Built-in Shipping and Payment Modules
    Replies: 13
    Last Post: 17 Jul 2011, 07:21 PM
  3. Zip Code Error Check?
    By powrwrap in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 1 Apr 2011, 12:33 AM
  4. Check this code please..error somewhere
    By strelitzia in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 1 Oct 2008, 03:16 PM
  5. Can someone please check this code!
    By Vood in forum General Questions
    Replies: 4
    Last Post: 3 Nov 2007, 02:04 AM

Bookmarks

Posting Permissions

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