Search code examples
x-cartshipping-method

Adding a new real-time shipping system to older X-Cart


Trying to add a new real time shipping system to an existing, older (4.2.x) version of X-Cart and I can not figure out how to implement it properly. Plan is to put the lookup into a new shipping/mod_*.php file and from what I can tell merge $intershipper_rates with the response I get from the rating API. I just don't know how to reliably integrate it nor if I need to manually add anything into the database to make it work properly. There doesn't seem to be any reference material or documentation for the older version I can easily access to figure it out, either. If anybody can give me a hand wrapping my head around this, I'd appreciate it.


Solution

  • In the code below replace the 'CPC' substring with your new shipper code.


    1) Create functions like

    • func_shipper_CPC
    • func_get_package_limits_CPC
    • func_check_limits_CPC

    in a new file like shipping/mod_CPC.php

    2) Change the array

    $mods = array("USPS", "CPC", "ARB", "FEDEX");
    

    in the shipping/myshipper.php

    3) Add a row to the shipping options table

    $params = func_query_first ("SELECT * FROM $sql_tbl[shipping_options] WHERE carrier='CPC'");
    

    4) Add possible shipping methods in the xcart_shipping table

    INSERT INTO xcart_shipping VALUES (null,'Canada Post Expedited','','L','CPC','81',20,'Y','CEX',0.00,0.00,1020,'','');
    INSERT INTO xcart_shipping VALUES (null,'Canada Post Regular','','L','CPC','82',10,'Y','CRE',0.00,0.00,1010,'','');
    INSERT INTO xcart_shipping VALUES (null,'Canada Post Xpresspost USA','','I','CPC','89',90,'Y','',0.00,0.00,2030,'','');
    .....