Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012
    Posts
    60
    Plugin Contributions
    0

    Default Coding help needed for USPS weight restriction for shipping option

    Sorry this is a similar post, but I've taken from other posts but since they are older versions of the USPS module, I'm afraid I'm missing something. I need to restrict the weight to less than 2 lbs for intl sm flat rate box. Here is the code I have:

    $methods = array();
    $size = sizeof($uspsQuote);
    for ($i=0; $i<$size; $i++) {
    list($type, $cost) = each($uspsQuote[$i]);

    // BOF: UPS USPS
    $title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
    if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];

    // strip the ** from the titles

    $title = str_replace('**', '', $title);
    $cost = preg_replace('/[^0-9.]/', '', $cost);

    // add $this->usps_countries to title to test actual country

    /*
    $methods[] = array('id' => $type,
    'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
    'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    */
    if ($type == 'Priority Mail International Small Flat Rate Box' && $shipping_weight >= 2.00) {
    // skip Priority Mail International Small Flat Rate Box on >= 2.00
    } else {

    $methods[] = array('id' => $type,
    'title' => $title,
    'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? $usps_handling_fee * $shipping_num_boxes : $usps_handling_fee) );



    // bof: sort by contributed by Marco B
    // Sort the options
    if (MODULE_SHIPPING_USPS_QUOTE_SORT != 'Unsorted') {
    usort($methods,'usps_sort_'.MODULE_SHIPPING_USPS_QUOTE_SORT);
    }
    // eof: sort by contributed by Marco B
    }
    }

    $this->quotes['methods'] = $methods;


    when I go over the weight in the cart, the flat rate option for any international country is still showing Anyone know how to fix?

    Thanks in advanced!

    What do the */ and /* mean?

  2. #2
    Join Date
    Jan 2011
    Posts
    65
    Plugin Contributions
    0

    Default Re: Coding help needed for USPS weight restriction for shipping option

    i'm assuming the IF/ELSE condition is failing, which is why the "ELSE" portion of your code is executing despite what your shipping weight is.

    Looking at the defined types of shipping for the USPS version of the module you're using, looks like the exact string passed to the $type variable when selecting small flat rate int box should be... 'Priority Mail International Small Flat Rate Box**'

    If that doesn't work, it might also be... 'Priority Mail Int Flat Rate Small Box'

    The reason is because here is the array of shipment types as defined in the code of the USPS version that you're using...
    Code:
    $this->intl_types = array(
            'Global Express' => 'Global Express Guaranteed (GXG)**', // ID="4"
            'Global Express Non-Doc Rect' => 'Global Express Guaranteed Non-Document Rectangular', // ID="6"
            'Global Express Non-Doc Non-Rect' => 'Global Express Guaranteed Non-Document Non-Rectangular', // ID="7"
            'USPS GXG Envelopes' => 'USPS GXG Envelopes**', // ID="12"
            'Express Mail Int' => 'Express Mail International', // ID="1"
            'Express Mail Int Flat Rate Box' => 'Express Mail International Flat Rate Boxes', // ID="26"
            'Express Mail Int Flat Rate Env' => 'Express Mail International Flat Rate Envelope', // ID="10"
            'Express Mail Int Legal' => 'Express Mail International Legal Flat Rate Envelope', // ID="17"
            'Priority Mail International' => 'Priority Mail International', // ID="2"
            'Priority Mail Int Flat Rate Lrg Box' => 'Priority Mail International Large Flat Rate Box', // ID="11"
            'Priority Mail Int Flat Rate Med Box' => 'Priority Mail International Medium Flat Rate Box', // ID="9"
            'Priority Mail Int Flat Rate Small Box' => 'Priority Mail International Small Flat Rate Box**', // ID="16"
            'Priority Mail Int DVD' => 'Priority Mail International DVD Flat Rate Box**', // ID="24"
            'Priority Mail Int Lrg Video' => 'Priority Mail International Large Video Flat Rate Box**', // ID="25"
            'Priority Mail Int Flat Rate Env' => 'Priority Mail International Flat Rate Envelope**', // ID="8"
            'Priority Mail Int Legal Flat Rate Env' => 'Priority Mail International Legal Flat Rate Envelope**', // ID="22"
            'Priority Mail Int Padded Flat Rate Env' => 'Priority Mail International Padded Flat Rate Envelope**', // ID="23"
            'Priority Mail Int Gift Card Flat Rate Env' => 'Priority Mail International Gift Card Flat Rate Envelope**', // ID=18
            'Priority Mail Int Small Flat Rate Env' => 'Priority Mail International Small Flat Rate Envelope**', // ID="20"
            'Priority Mail Int Window Flat Rate Env' => 'Priority Mail International Window Flat Rate Envelope**', // ID=19
            'First Class Mail Int Parcel' => 'First-Class Mail International Parcel**', // ID="15" Changed Package to Parcel
            'First Class Mail Int Lrg Env' => 'First-Class Mail International Large Envelope**', // ID="14"
            'First Class Mail Int Letter' => 'First-Class Mail International Letter**' // ID="13"
            );
    I think the string you're trying to match in the IF statement ('Priority Mail International Small Flat Rate Box') is from older code and that string value has been changed by USPS since then.

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

    Default Re: Coding help needed for USPS weight restriction for shipping option

    That is correct, the IF should be using:
    Code:
    if ($type == 'Priority Mail International Small Flat Rate Box**' && $shipping_weight >= 2.00) {
    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.5]
    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!

  4. #4
    Join Date
    Jul 2012
    Posts
    60
    Plugin Contributions
    0

    Default Re: Coding help needed for USPS weight restriction for shipping option

    Thanks so much! I thought I tried that but it worked this time :) I'm sure others will love this trick as well! Works great!

    Also, I know I've found before, but I'm having trouble finding where the shipping / checkout text is to modify what is said when customers choose their shipping method. Thanks!

 

 

Similar Threads

  1. v151 Set Specific Shipping option by weight - USPS or UPS
    By headbirdbrain in forum Addon Shipping Modules
    Replies: 2
    Last Post: 12 Sep 2013, 08:07 PM
  2. v139h Max weight restriction code for USPS Priority Mail Int Lrg Video box shipping option
    By heteromorphic in forum Addon Shipping Modules
    Replies: 9
    Last Post: 8 Sep 2012, 01:05 AM
  3. Replies: 1
    Last Post: 31 May 2009, 02:06 AM
  4. USPS Shipping Option for First Class Domestic not showing
    By DVMGuy in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 19 Jul 2008, 07:51 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR