Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

wkdwich

Members
  • Content count

    439
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    wkdwich reacted to badlhby in USPS Rate V4, Intl Rate V2 (official support thread)   
    The comment is correct that XML response is being returned in CHUNKED format. Here is a workaround that I've put in. Hopefully it helps you:
     
    I run USPS Methods 7.1 and am having no issues after making the following changes:
     
    First you will need to define a function for HTTP_CHUNKED_DECODE somewhere within the code:
     

    /** * dechunk an http 'transfer-encoding: chunked' message * * @[member='param'] string $chunk the encoded message * @[member='Return'] string the decoded message. If $chunk wasn't encoded properly it will be returned unmodified. */ function http_chunked_decode($chunk) { $pos = 0; $len = strlen($chunk); $dechunk = null; while(($pos < $len) && ($chunkLenHex = substr($chunk,$pos, ($newlineAt = strpos($chunk,"\n",$pos+1))-$pos))) { if (!$this->is_hex($chunkLenHex)) { trigger_error('Value is not properly chunk encoded', E_USER_WARNING); return $chunk; } $pos = $newlineAt + 1; $chunkLen = hexdec(rtrim($chunkLenHex,"\r\n")); $dechunk .= substr($chunk, $pos, $chunkLen); $pos = strpos($chunk, "\n", $pos + $chunkLen) + 1; } return $dechunk; } /** * determine if a string can represent a number in hexadecimal * * @[member='param'] string $hex * @[member='Return'] boolean true if the string is a hex, otherwise false */ function is_hex($hex) { // regex is for weenies $hex = strtolower(trim(ltrim($hex,"0"))); if (empty($hex)) { $hex = 0; }; $dec = hexdec($hex); return ($hex == dechex($dec)); }
     
    Find the occurrences of

    if ($http->Get('/shippingAPI.dll?' . $request)) $body = $http->getBody();
    and change to

    if ($http->Get('/shippingAPI.dll?' . $request)) { $body = preg_replace( array( '{<sup>®</sup>}', /* Registered Trademark symbol - July 2013 update */ '{<sup>™</sup>}', /* Trademark symbol - July 2013 update */ '/<br>/' ), array ( '', '', '' ), htmlspecialchars_decode($this->http_chunked_decode($http->getBody()))); }
     
    All of my quotes come up for both domestic and international without issue.
     
    If someone can update this post with the correct locations within the module that would be great.
  2. Like
    wkdwich reacted to kymation in USPS Rate V4, Intl Rate V2 (official support thread)   
    I've posted an update on the USPS Methods Rates V4 Intl Rates V2 addon. This contains the code posted by @@badlhby on the USPS Methods support thread. I simply modified the module to work with that code.
     
    I have tested both the stock and MVS modules and they seem to work. Please let me know if you find a case where this does not work.
     
    Regards
    Jim
  3. Like
    wkdwich reacted to kymation in USPS Rate V4, Intl Rate V2 (official support thread)   
    I have uploaded the full package with fixes to this Addon package, since it's the only one that is not locked. Please use this location from now on as it will contain the latest version.
     
    Regards
    Jim
  4. Like
    Guest
    wkdwich got a reaction from Guest in Heads Up: July 28, 2013 USPS Name Change for Express Mail   
    It looks to me like the general.php changes he is talking about is not included in the usps methods v6.1x but is in the usps methods v5.2.x.. it involves adding functions by GREG DEETH to both /admin/includes/functions/general.php and to /includes/functions/general.php
     
    I am unsure if this code is needed in the usps methods v6.1x or not.. I know that last year's upgrade had me REMOVING this code which had been there since the dawn of time!
     

    10. If this is a new install or an upgrade from stock or old version, then make the following modifications. If not, then skip to step 13. catalog/admin/includes/functions/general.php Find somewhere around line 767: //// // Alias function for module configuration keys function tep_mod_select_option($select_array, $key_name, $key_value) { reset($select_array); while (list($key, $value) = each($select_array)) { if (is_int($key)) $key = $value; $string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"'; if ($key_value == $key) $string .= ' CHECKED'; $string .= '> ' . $value; } return $string; } Insert After // Alias function for Store configuration values in the Administration Tool function tep_cfg_select_multioption($select_array, $key_value, $key = '') { for ($i=0; $i<sizeof($select_array); $i++) { $search = array(' regimark', ' tradmrk'); $replace = array('<sup>®</sup>', '<sup>™</sup>'); $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value'); $string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"'; $key_values = explode( ", ", $key_value); if ( in_array($select_array[$i], $key_values)) $string .= ' CHECKED'; $string .= '> ' . str_replace($search, $replace,$select_array[$i]); } $string .= '<input type="hidden" name="' . $name . '" value="--none--">'; return $string; } // USPS Methods. Added by Greg Deeth // Alias function for Store configuration values in the Administration Tool. function tep_cfg_multiinput_list($select_array, $key_value, $key = '') { $key_values = explode( ", ", $key_value); for ($i=0; $i<sizeof($select_array); $i++) { $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value'); $string .= '<br><input type="text" name="' . $name . '" value="' . $key_values[$i] . '"> ' . $select_array[$i]; } $string .= '<input type="hidden" name="' . $name . '" value="--none--">'; return $string; } // USPS Methods. Added by Greg Deeth // Alias function for Store configuration values in the Administration Tool. function tep_cfg_multiinput_duallist_oz($select_array, $key_value, $key = '') { $key_values = explode( ", ", $key_value); $string .= '<center>'; for ($i=0; $i<sizeof($select_array); $i++) { $current_key_value = current($key_values); $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value'); $string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>'; $string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>'; next($key_values); $current_key_value = current($key_values); $string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>'; next($key_values); } $string .= '<input type="hidden" name="' . $name . '" value="--none--">'; $string .= '</center>'; return $string; } function tep_cfg_multiinput_duallist_lb($select_array, $key_value, $key = '') { $key_values = explode( ", ", $key_value); $string .= '<center>'; for ($i=0; $i<sizeof($select_array); $i++) { $current_key_value = current($key_values); $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value'); $string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>'; $string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>'; next($key_values); $current_key_value = current($key_values); $string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>'; next($key_values); } $string .= '<input type="hidden" name="' . $name . '" value="--none--">'; $string .= '</center>'; return $string; } 11. Add the following: catalog/includes/functions/general.php Find somewhere around line 287: //// // Wrapper function for round() function tep_round($number, $precision) { if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) { $number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1); if (substr($number, -1) >= 5) { if ($precision > 1) { $number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1'); } elseif ($precision == 1) { $number = substr($number, 0, -1) + 0.1; } else { $number = substr($number, 0, -1) + 1; } } else { $number = substr($number, 0, -1); } } return $number; } Insert After: //// // Round up function for non whole numbers by GREG DEETH // The value for the precision variable determines how many digits after the decimal and rounds the last digit up to the next value // Precision = 0 -> xx.xxxx = x+ // Precision = 1 -> xx.xxxx = xx.+ // Precision = 2 -> xx.xxxx = xx.x+ function tep_round_up($number, $precision) { $number_whole = ''; $num_left_dec = 0; $num_right_dec = 0; $num_digits = strlen($number); $number_out = ''; $i = 0; while ($i + 1 <= strlen($number)) { $current_digit = substr($number, $i, ($i + 1) - $num_digits); if ($current_digit == '.') { $i = $num_digits + 1; $num_left_dec = strlen($number_whole); $num_right_dec = ($num_left_dec + 1) - $num_digits; } else { $number_whole = $number_whole . $current_digit; $i = $i + 1; } } if ($num_digits > 3 && $precision < ($num_digits - $num_left_dec - 1) && $precision >= 0) { $i = $precision; $addable = 1; while ($i > 0) { $addable = $addable * .1; $i = $i - 1; } $number_out = substr($number, 0, $num_right_dec + $precision) + $addable; } else { $number_out = $number; } return $number_out; }
  5. Like
    wkdwich got a reaction from bkpie in [Contribution] - USPS Methods   
    *** REPLY moved from one of the other threads ***
    http://forums.oscommerce.com/topic/393466-heads-up-july-28-2013-usps-name-change-for-express-mail/page__st__100#entry1678284
     
    Evan
    http://http://forums.oscommerce.com/topic/146950-contribution-usps-methods/
    I thoroughly looked through your code and indeed I see all the references to adding handling fees.. however I am still not seeing it.. My client is running osCmax v2.5 (I stated wrong in a few places it as osC v2.5)
    I just un-installed the USPS Methods v5.2 and uploaded/installed your USPS Methods v5.3.
    All quotes seem to be proper, including handling fees, domestic & International
    EXCEPT First Class is still not adding any handling fees on the domestic. It did add it on international:
    First-Class Mail International Large Envelope**
    First-Class Package International Service**
     
    but not the domestic..
     
    So close.. sooooo close...
  6. Like
    wkdwich got a reaction from altoid in USPS Rate V4, Intl Rate V2 (official support thread)   
    *** WARNING *** This WILL be cross posted for clarification across ALL USPS shipping module threads.
     
    There are, for all intent and purpose, TWO different modules, 2 very different modules. One of those modules has morphed itself 3 times in the ADD-ON section of osCommerce.com/info/xxxx
     
    When posting to any USPS module thread PLEASE state which osC vX.X.X as well as which USPS module you are using. If you are unsure what version of the USPS module you are currently using, PLEASE paste the first few lines of /catalog/includes/modules/shipping/usps.php file here so maybe we can help you make the determination.
     
    Here is my take on the module morphing:
    http://addons.oscommerce.com/info/8327
    USPS Rate V4 Intl Rate V2 - v.1.0
    at some point was set to NOT allow uploads to the module, essentially closing it to further updates.
    this morphed into:
    http://addons.oscommerce.com/info/8403
    USPS Rates ServerV4 (for osc2.2)
    which also at some point was set to NOT allow uploads to the module, essentially closing it to further updates.
    this then morphed into:
    http://addons.oscommerce.com/info/8702
    USPS Methods Rates V4 Intl Rates V2 - 01-27-13 Update
    this one is being currently maintained, within thread http://forums.oscommerce.com/topic/383307-usps-rate-v4-intl-rate-v2-official-support-thread albeit with some errors still in regards to First Class rates and handling fees. See post #748 above for that: http://forums.oscommerce.com/topic/383307-usps-rate-v4-intl-rate-v2-official-support-thread/page__st__740#entry1678247
     
    The second module is:
    http://addons.oscommerce.com/info/487
    USPS Methods
    This one is being maintained within the ADD-ON section and within thread
    http://forums.oscommerce.com/topic/146950-contribution-usps-methods/ HOWEVER there are MANY MANY updates there.. 5.2.x 6.x and now 5.3
     
    There is at least one further active USPS module thread:
    http://forums.oscommerce.com/topic/393466-heads-up-july-28-2013-usps-name-change-for-express-mail/
    Heads Up: July 28, 2013 USPS Name Change for Express Mail
    which is mostly referring to the USPS Methods module #487 with some cross posting going on there as well.
     
    So there you have it.. please lets try and post to the proper thread and let everyone know what you are using so we can best help you!
  7. Like
    wkdwich reacted to altoid in [Development] USPS Shipping Module   
    It tested some shipping destinations to countries in the middle east. No problems with the code but now I have an NSA van parked outside my house. o:)
  8. Like
    wkdwich reacted to altoid in [Development] USPS Shipping Module   
    I'll test Jim, thanks for tackling this.
     
    Before your post I was wondering if there was some way to get around having to manually modify the USPS module every time they make changes that changes that cause all this grief. But my limited coding skills won't cut it.
     
    At least I can test....fire away.
  9. Like
    wkdwich reacted to krdito in USPS Rate V4, Intl Rate V2 (official support thread)   
    I have been away from this thread for a couple of days (thanks to resolving my shipping issue!), but someone asked about setting up the zone rates. It's very simple! First, check in your admin panel to see if you have a zone module. If so, you are in good shape. If not, you will need to find the contribution to add it. We already had it, so we didn't have to go looking for it.
     
    The instructions in the module (includes->modules->shipping->zones) tells you how to increase the number of zones within one zone module (I needed 3 zones, one for the US, one for Canada, and one for the rest of the world). Once you have the correct number of zones, go back to your Admin panel and set them up using the instructions for entering the country code and price based on weight. Please note that one zone module is only good for one USPS service! So, once we had Priority Mail set up, we had to duplicate the zone module to create 2 more zone modules to use for Standard Post and Express Mail. We named them z2 and z3. Don't use the word "zone" in the new module name because it does mess up the system. You then have to go into your new module and replace "zone" with "z2" (or whatever you have named your new zone module) for both lower case and upper case. We then did the same thing for z3. We dug up an old thread here that had instructions for duplicating a table module and used the same principles for duplicating a zone module. This thread is: http://forums.oscommerce.com/topic/137263-shipping-duplicating-table-rate/
     
    You will also need to duplicate the language file for the new zones in includes->languages->english->modules->shipping using the same search and replace as you did with the actual zone modules.
     
    Once you have duplicated the zone module and language file (which is the hardest step), you can then set up the new zone modules with the country codes and shipping costs by pound. We looked up prices on the USPS website and used zip code 90026 for US prices, Canada obviously for Canada, and Australia for the rest of the international countries to which we ship. We renamed the zones in the includes->languages->modules-> language files to be Standard Post<sup>®</sup></b> - estimated delivery is 2-9 business days after shipment:, Priority Mail<sup>®</sup></b> - estimated delivery is 2-3 business days after shipment to US addresses and 6-10 business days after shipment to international addresses:, and Express Mail™</b> - estimated delivery is 1-2 business days after shipment to US addresses and 3-5 business days after shipment to international addresses:, so this is what the customer sees during checkout and includes the estimated delivery (not the new "official" estimate from the USPS, but the same basic estimates that have always been in place.
     
    Here is what we have for Priority Mail:
    Enable Zones Method
    True
     
    Tax Class
    --none--
     
    Sort Order
    2
     
    Zone 1 Countries
    US
     
    Zone 1 Shipping Table
    2:10.25,3:12.90,4:16.45,5:18.90,6:21.20,7:23.85,8:26.30,9:41.05,10:41.05,12:41.05,14:41.05,16:67.85,20:81.95,24:81.95,28:81.95,32:81.95
     
    Zone 1 Handling Fee
    1.00
     
    Zone 2 Countries
    CA
     
    Zone 2 Shipping Table
    2:30.60,3:32.95,4:35.30,5:37.65,6:40.00,7:42.35,8:44.70,9:47.05,10:49.40,12:54.50,14:59.60,16:64.70,20:74.90,24:85.10,28:95.30,32:105.50
     
    Zone 2 Handling Fee
    1.00
     
    Zone 3 Countries
    AD,AQ,AS,AT,AU,AW,BE,BR,BS,CH,CL,CN,CZ,DE,DK,ES,FI,FK,FR,FX,GB,GL,GR,GU,HK,HU,IE,IL,IS,IT,JP,KY,LI,LU,MC,MX,NL,NO,NZ,PL,PR,PT,SE,SG,TR,TW,UA,VE,VG,VI,ZA
     
    Zone 3 Shipping Table
    2:44.10,3:48.25,4:52.40,5:56.55,6:60.90,7:65.25,8:69.60,9:73.95,10:78.30,12:87.20,14:96.10,16:137.10,20:159.70,24:182.30,28:204.90,32:227.50
     
    Zone 3 Handling Fee
    1.00
     
     
     
    For Standard Post:
    Enable Z2 Method
    True
     
    Tax Class
    --none--
     
    Sort Order
    1
     
    Zone 1 Countries
    US
     
    Zone 1 Shipping Table
    2:8.92,3:10.81,4:12.07,5:12.66,6:14.20,7:15.98,8:17.62,9:19.06,10:20.97,12:25.02,14:27.50,16:30.21,20:30.21,24:30.74,28:31.39,32:32.10
     
    Zone 1 Handling Fee
    1.00
     
     
     
    and for Express Mail:
    Enable Z3 Method
    True
     
    Tax Class
    --none--
     
    Sort Order
    3
     
    Zone 1 Countries
    US
     
    Zone 1 Shipping Table
    2:38.10,3:43.90,4:49.45,5:55.00,6:60.45,7:66.05,8:71.70,9:77.25,10:81.20,9:77.25,10:81.20,12:88.95,14:96.50,16:104.70,20:120.25,24:137.35,28:152.55,32:170.70
     
    Zone 1 Handling Fee
    1.00
     
    Zone 2 Countries
    CA
     
    Zone 2 Shipping Table
    2:41.40,3:45.45,4:49.50,5:53.55,6:57.85,7:62.15,8:66.45,9:70.75,10:75.05,12:83.55,14:92.05,16:204.20,20:244.95,24:244.95,28:244.95,32:244.95
     
    Zone 2 Handling Fee
    1.00
     
    Zone 3 Countries
    AD,AQ,AS,AT,AU,AW,BE,BR,BS,CH,CL,CN,CZ,DE,DK,ES,FI,FK,FR,FX,GB,GL,GR,GU,HK,HU,IE,IL,IS,IT,JP,KY,LI,LU,MC,MX,NL,NO,NZ,PL,PR,PT,SE,SG,TR,TW,UA,VE,VG,VI,ZA
     
    Zone 3 Shipping Table
    2:59.50,3:64.65,4:69.80,5:74.95,6:80.60,7:86.25,8:91.90,9:97.55,10:103.20,12:114.50,14:125.80,16:294.70,20:359.05,28:359.05,32:359.05
     
    Zone 3 Handling Fee
    1.00
     
    Our largest weight is 32 pounds, but you can go higher if needed, based on what you sell. We don't use First Class, but if you do, you would need a separate zone module for that class. We set the sort order so the zones would show up in order of cheapest to most expensive.
     
    If USPS rates go up in the future (of course they will!), we can either figure out the new rates on the USPS site or bump up the handling fee to cover the increase.
     
    Using these zone modules, we are no longer have to connect to the USPS for service and price quotes. If they ever change service names, it's a simple name change to our current language file.
     
    The only downside of the zone modules is we used a Califoria zip code for calculating costs for US shipping. Customers living closer will pay more than they should have, but the different is usually just a few dollars, so we didn't sweat it. It was more important to us to have a module that worked, over which we have complete control, than risk losing more sales waiting on a fix for the current mess we found ourselves in on July 28th...and last Januar with those USPS updates.
     
    I can tell you I have slept so much better since we implemented our zone modules. No worries ever again about changes by the UPSPS that bring our sales to a grinding halt!
     
    Anyone with questions is more than welcome to message me. I am happy to help! My husband, avec, is a regular poster here and did the zone module duplication when I had the idea that duplicating and using zone modules could be a good fix for us...and it was!
  10. Like
    wkdwich reacted to kymation in [Development] USPS Shipping Module   
    The current USPS shipping modules (USPS Methods, USPS Rate V4, Intl Rate V2, stock osCommerce 2.3x) all have a major problem -- they depend on the Service names that USPS supplies. Since USPS seems determined to change these names every six months or so, these modules break and must be patched twice a year. This should not happen, and it doesn't need to.
     
    The quotes that USPS returns are keyed to a Service ID (called CLASSID.) These are (mostly*) unique numbers that never change, or only change when a service is deleted or added. These numbers are a much better way to select the service(s) desired, as the module will not break when USPS changes the service names.
     
    If this system had been in use before the July changes, the only difference that anyone would have noticed would have been different service names showing up on the checkout page. No broken checkout, no thrashing to get a fix implemented, no lost sales.
     
    I've done some preliminary testing, and I have a plan to fix this. I intend to use some of the code from the USPS Rate V4, Intl Rate V2 module since I like the way it is set up in the Admin. The rest of the code will be rewritten.
     
    I have in mind an adaptive model that will require an extra step in the install process. The first edit of the module upon install will require a valid USPS Web Tools username. That will be used to send a dummy quote request to the USPS server for all available services, domestic and international. The response to that will be stored and presented in the second step as a list of services that may be selected. The selected values will then be stored in that step.
     
    The installer will allow the selection of services by their current names. The names in the Admin will not change if USPS changes their API since those values are stored in the database. However, we are only comparing against the CLASSID, so the store side will continue to work and show the updated names.
     
    Updating the names on the Admin side can be done by uninstalling/reinstalling the module, but that will normally not be necessary. You will only need to do that if USPS has added a new service that you want to offer to your customers or they have removed a service that you were offering. Doing an uninstall and reinstall is a lot simpler than modifying the code to make it work again.
     
    *Yes, there's one problem with this approach -- the CLASSID for all First Class services is 0. That will have to be treated as a special case. That makes First Class more fragile, but USPS doesn't seem to change those services very often, so it's not likely to be a huge problem.
     
    Any and all help with this is very welcome. I can use help with the code, of course, but feature suggestions and testing help are appreciated as well. Let's see what we can do with this.
     
    Regards
    Jim
  11. Like
    wkdwich reacted to kymation in USPS Rate V4, Intl Rate V2 (official support thread)   
    The main problem that everyone is having with this is that both addons are trying to key on the service name that USPS returns. Since USPS seems determined to change those names every six months, this is a really bad idea. I think we should be using the CLASSID for each service as those numbers never (or rarely) change. I'm working on a proof-of-concept of an adaptive module that would never need these twice-yearly changes. I suppose I should start a development thread, as this is looking really good.
     
    Regards
    Jim
  12. Like
    wkdwich reacted to videod in USPS Rate V4, Intl Rate V2 (official support thread)   
    @@wkdwich had to venture out for a while.
    Look for:
    $this->quotes = array (
    'id' => $this->code,
    'module' => $this->title . ' ' , //$this->pounds . ' lbs, ' . $this->ounces . ' oz', (hides displaying of weight)
    'methods' => $methods,
     
    Note: I put a comma after the 2 single quotes, and put the // just before the $this->pounds to comment out the rest of the line. This hides the weight display in USPS on checkout. This was actually documented in one of the threads. But I think there was an extra space that didn't allow me to do a search and replace. So I manually tracked it down (I am really slow when it comes to code).
  13. Like
    wkdwich got a reaction from videod in USPS Rate V4, Intl Rate V2 (official support thread)   
    Just as a point of info.. if you keep making changes and are not progressing where you think you should be.. check your database the CONFIGURATION TABLE to see if there are any USPS entries that were not removed the last time you uninstalled. Clearing CACHE & COOKIES might also help but the bigger finger pointing is to left over stuff in the database..
  14. Like
    wkdwich reacted to tomt in Heads Up: July 28, 2013 USPS Name Change for Express Mail   
    That's the hole I am in now. Everything looks good until you actually select a USPS choice and continue. Shipping screen comes back but the USPS section says "An error occured with USPS shipping calculations..." But where did the shipping numbers come from just a few seconds ago?
     
    (I'm seriously thinking of changing that message to "HEY, if you order more than $50 of stuff shipping is free so why not just do that?")
×