Results 1 to 6 of 6

Thread: Adding shipping boxes to UPS and FEDEX

  1. #1
    Active Member
    Adding shipping boxes to UPS and FEDEX


    Join Date
    Sep 2009
    Location
    Vancouver, BC, Canada
    Posts
    476
    Total Contributions For

    JRR     $ 180.00
    Rep Power
    67


    Default Adding shipping boxes to UPS and FEDEX

    I'm looking to update the UPS and FEDEX functions in osCmax, and am finding for the UPS side that the code used is not very current. For example the xml.php code is based on 1.2b, whereas the current is 1.5 and there are some differences. I can't tell if the changes are for osCmax or are because the updated code is simply fresher. Nothing in the archives covers this that I can find easily.

    Here is what I am talking about - note that the ver numbers I am referring to are the xml.php internal versions. My version osCmax is 2.5.4, and the version of UPS used by osCmax 2.5.4 is UPSXML_v1_5 2. The osCommerce Ver 1.5 reference is to the most recent contribution of UPS XML.PHP which is version 1.5

    osCmax, ver 1.2b
    Code:
    function & XML_unserialize(&$xml){
        $xml_parser = &new XML();
        $data = &$xml_parser->parse($xml);
    osCommerce ver 1.5 (an apersand in front of new was removed)
    Code:
    function & XML_unserialize($xml){
        $xml_parser = new XML();
        $data = $xml_parser->parse($xml);

    osCmax, ver 1.2b

    Code:
    if(is_array($value) and array_key_exists(0, $value)){

    osCommerce ver 1.5
    (added space after if)
    Code:
    if (is_array($value) and array_key_exists(0, $value)){

    osCmax, ver 1.2b

    Code:
                    if(is_null($value)) echo " />\n";
                    elseif(!is_array($value)) echo '>',htmlspecialchars($value),"</$tag>\n";
    osCommerce ver 1.5 (added space after if)
    Code:
                    if (is_null($value)) echo " />\n";
                    elseif (!is_array($value)) echo '>',htmlspecialchars($value),"</$tag>\n";

    osCmax, ver 1.2b

    (line 60 - nothing)

    osCommerce ver 1.5
    Code:
    // used by XML class to find the number of numeric array keys in an array
    function count_numeric_items(&$array){
        return is_array($array) ? count(array_filter(array_keys($array), 'is_numeric')) : 0;
    }
    
    if (PHP_VERSION >= '5.0.0') { // PHP 5 does not need to use and no longer allows call-time pass by reference

    osCmax, ver 1.2b

    Code:
    # XML class: utility class to be used with PHP's XML handling functions
    osCommerce ver 1.5
    Code:
    # XML class for PHP version 5 or later : utility class to be used with PHP's XML handling functions
    ###################################################################################
    class XML{
        var $parser;   #a reference to the XML parser
        var $document; #the entire XML structure built up so far
        var $parent;   #a pointer to the current parent - the parent will be an array
        var $stack;    #a stack of the most recent parent at each nesting level
        var $last_opened_tag; #keeps track of the last tag opened.
    
        function XML(){
             $this->parser = &xml_parser_create();
        xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
        xml_set_object($this->parser, $this);
          xml_set_element_handler($this->parser, 'open', 'close');
          xml_set_character_data_handler($this->parser, 'data');
        }
        function destruct(){
        xml_parser_free($this->parser);
      }
        function parse(&$data){
            $this->document = array();
            $this->stack    = array();
            $this->parent   = &$this->document;
        return (xml_parse($this->parser, $data, true) ? $this->document : NULL);
        }
        function open(&$parser, $tag, $attributes){
            $this->data = ''; #stores temporary cdata
            $this->last_opened_tag = $tag;
            if (is_array($this->parent) and array_key_exists($tag,$this->parent)) { #if you've seen this tag before
                if (is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])) { #if the keys are numeric
                    #this is the third or later instance of $tag we've come across
                    $key = count_numeric_items($this->parent[$tag]);
                } else {
                    #this is the second instance of $tag that we've seen. shift around
                    if(array_key_exists("$tag attr",$this->parent)){
                        $arr = array('0 attr'=>&$this->parent["$tag attr"], &$this->parent[$tag]);
                        unset($this->parent["$tag attr"]);
                    } else {
                        $arr = array(&$this->parent[$tag]);
                    }
                    $this->parent[$tag] = &$arr;
                    $key = 1;
                }
                $this->parent = &$this->parent[$tag];
            } else {
                $key = $tag;
            }
            if ($attributes) $this->parent["$key attr"] = $attributes;
            $this->parent  = &$this->parent[$key];
            $this->stack[] = &$this->parent;
        }
        function data(&$parser, $data){
            if ($this->last_opened_tag != NULL) #you don't need to store whitespace in between tags
                $this->data .= $data;
        }
        function close(&$parser, $tag){
            if ($this->last_opened_tag == $tag) {
                $this->parent = $this->data;
                $this->last_opened_tag = NULL;
            }
            array_pop($this->stack);
            if ($this->stack) $this->parent = &$this->stack[count($this->stack)-1];
        }
    }
    
    } else { // PHP versions earlier than 5 require this class to use call time pass by reference
    
    ###################################################################################
    # XML class for PHP versions earlier than 5: utility class to be used with PHP's XML handling functions

    osCmax, ver 1.2b

    Code:
        function destruct(){ xml_parser_free(&$this->parser); }
        function & parse(&$data){
    osCommerce ver 1.5 (ampersand in front of parse removed)
    Code:
        function destruct(){ xml_parser_free(&$this->parser); }
        function parse(&$data){

    osCmax, ver 1.2b

    Code:
            return xml_parse(&$this->parser, &$data, true) ? $this->document : NULL;
    osCommerce ver 1.5 (brackets () added)
    Code:
            return (xml_parse(&$this->parser, &$data, true) ? $this->document : NULL);

    osCmax, ver 1.2b
    Code:
            if(is_array($this->parent) and array_key_exists($tag,$this->parent)){ #if you've seen this tag before
                if(is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])){ #if the keys are numeric


    osCommerce ver 1.5
    (space added after if)
    Code:
            if (is_array($this->parent) and array_key_exists($tag,$this->parent)) { #if you've seen this tag before
                if (is_array($this->parent[$tag]) and array_key_exists(0,$this->parent[$tag])) { #if the keys are numeric

    osCmax, ver 1.2b

    Code:
            if($attributes) $this->parent["$key attr"] = $attributes;

    osCommerce ver 1.5
    (space added after if)
    Code:
            if ($attributes) $this->parent["$key attr"] = $attributes;

    osCmax, ver 1.2b

    Code:
            if($this->last_opened_tag != NULL) #you don't need to store whitespace in between tags
    osCommerce ver 1.5 (space added after if)
    Code:
            if ($this->last_opened_tag != NULL) #you don't need to store whitespace in between tags

    osCmax, ver 1.2b

    Code:
            if($this->last_opened_tag == $tag){
    osCommerce ver 1.5 (space added after if)
    Code:
            if ($this->last_opened_tag == $tag) {

    osCmax, ver 1.2b

    Code:
            if($this->stack) $this->parent = &$this->stack[count($this->stack)-1];
    osCommerce ver 1.5 (space added after if)
    Code:
            if ($this->stack) $this->parent = &$this->stack[count($this->stack)-1];

    osCmax, ver 1.2b
    (code not found in osCommerce 1.5)
    Code:
    function count_numeric_items(&$array){
        return is_array($array) ? count(array_filter(array_keys($array), 'is_numeric')) : 0;
    }
    osCommerce ver 1.5 (code was moved upstream to around line 52 the final bracket is the close for that code)
    Code:
    } // end elseif PHP version < 5
    OK, I doubt the added spaces mean anything, and I am ignoring other added spaces, however the code changes may be important updates...anyone else looking into boxes on UPS/FEDEX orders
    Last edited by JRR; 06-27-2016 at 08:31 PM. Reason: clarified reference info. updated final code info., typo

  2. #2
    osCMax Development Team

    Adding shipping boxes to UPS and FEDEX

    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    4,129
    Total Contributions For

    ridexbuilder     $ 15.00
    Rep Power
    96


    Default Re: Adding shipping boxes to UPS and FEDEX

    With Michael_S taking more than just a back seat with the 'max project, many of the core modules have stagnated - he used to update the postal and payments modules, amongst other stuff.

    All you can do is try out the new module and see if it works. I was in the same boat with the ridiculous USPS code, which changes EVERY year. Perhaps the ampersands are/were bugs which are now resolved - I don't understand the syntax being used there. Good work on highlighting the difference when presenting your opening post.


    [The 'extra' close brace is probably to complete the line 60 code.]
    Last edited by ridexbuilder; 06-27-2016 at 04:01 AM.

    Developers resource at bitbucket
    *** *** ***
    oscmax.co.uk / ejsolutions.co.uk
    Hosting plans with installation, configuration, contributions, support and maintenance.
    *** FREE osCmax hosting available ***
    oscmaxtemplates.com

  3. #3
    osCMax Development Team

    Adding shipping boxes to UPS and FEDEX

    pgmarshall's Avatar
    Join Date
    Feb 2009
    Location
    London
    Posts
    3,517
    Total Contributions For

    pgmarshall     $ 35.00
    Rep Power
    77


    Default Re: Adding shipping boxes to UPS and FEDEX

    Hi JRR

    Please commit to GitHub if this works! Only by working together can we make oscmax better for all.

    regards
    pgmarshall
    _______________________________

  4. #4
    Active Member
    Adding shipping boxes to UPS and FEDEX


    Join Date
    Sep 2009
    Location
    Vancouver, BC, Canada
    Posts
    476
    Total Contributions For

    JRR     $ 180.00
    Rep Power
    67


    Default Re: Adding shipping boxes to UPS and FEDEX

    Hi pg and ridex,

    I will see what I can do to document my findings. However I really have little time to figure out the nomenclature for GitHub.

    GitHub found at https://github.com/osCmax/oscmax2 doesn't have many changes that I can see. There appear to be two tracks - osCmax 2.5.4 and 2.5.5, however 2.5.5 isn't officially out or have I missed that post. I know there was a flurry a year or so ago about getting 2.5.5. up.

    For now I will keep plodding along but I don't have the skills nor the time to be more than a hacker lurking at the edges of this cacophony of codes trying to fix the odd annoying problems and figure out the roots of the various components that go into this assemblage. The page http://www.oscmax.com/what_is_oscmax_0 lists many of the contributions to osCmax, however that page is from no later than 2006 so it is WAY out of date.
    Last edited by JRR; 06-27-2016 at 07:18 PM.

  5. #5
    Active Member
    Adding shipping boxes to UPS and FEDEX


    Join Date
    Sep 2009
    Location
    Vancouver, BC, Canada
    Posts
    476
    Total Contributions For

    JRR     $ 180.00
    Rep Power
    67


    Default Re: Adding shipping boxes to UPS and FEDEX

    OK I went through the code in XML.PHP and it appears that it fixes the PHP 5 issues and tidied up some code. I believe that will work just fine in osCmax 2.5.4.

    I am working against a Canada Post deadline for a lockout starting next week so I have to offer my customers at least one other alternative shipping method to Canada Post. I will start with UPS and then run through FEDEX.

    Next I have to figure out how to get the boxes sorted out so the more recent versions of UPS will stuff my customers products into the correct boxes for shipping calculations.

    Canada Post is much easier - you load a list of your boxes onto their support site under your name, and then you send the dimensions of the products you want to fit into one of your shipping boxes. Their software takes the product dimensions and figures out the closest box that will take your products and returns that information to you as the box name you assigned.

    My long term goal is to use that packing process for Canada Post, UPS, and FEDEX as it is far superior to the PHP packing process according to comments I've seen on the support pages. I would still keep the PHP packing program as a backup in case Canada Post's web site is down (hey, it happens, eh?) and so if the CP process fails then the PHP process takes over.

    It will only work in CANADA though, as you need to have a Venture One account with Canada Post. Sorry to any non-Canadians who are thinking of using my code for that process. Now if USPS has a packing routine you can use, then great - go for it!

  6. #6
    osCMax Development Team

    Adding shipping boxes to UPS and FEDEX

    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    4,129
    Total Contributions For

    ridexbuilder     $ 15.00
    Rep Power
    96


    Default Re: Adding shipping boxes to UPS and FEDEX

    I hear ya, with regards to github. I just can't get my head around the system at all and too many other things tax my grey matter.
    2.5.4 is the current release; 2.5.5 is unstable in that development is ongoing (though not by me, due to forementioned brain drain).
    [I found sourceforge marginally easier.]

    Developers resource at bitbucket
    *** *** ***
    oscmax.co.uk / ejsolutions.co.uk
    Hosting plans with installation, configuration, contributions, support and maintenance.
    *** FREE osCmax hosting available ***
    oscmaxtemplates.com

Similar Threads

  1. Adding Info Boxes
    By simplyjim in forum osCMax v2 Features Discussion
    Replies: 1
    Last Post: 02-26-2010, 05:12 AM
  2. Adding Boxes
    By mrocket in forum osCommerce 2.2 Modification Help
    Replies: 0
    Last Post: 04-27-2006, 11:13 AM
  3. Adding Boxes to pages OUTSIDE oscmax
    By rjavery in forum osCmax v2 Customization/Mods
    Replies: 4
    Last Post: 08-02-2005, 07:33 AM
  4. HELP!! adding boxes
    By thedesignbase in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 01-30-2005, 10:45 AM
  5. Adding outside links to info boxes
    By chardae in forum osCommerce 2.2 Modification Help
    Replies: 2
    Last Post: 11-15-2002, 09:46 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
  •