Full service web hosting, great prices and support. Starts at $1.99/month!
Results 1 to 1 of 1

Thread: eShipper integration with osCmax 2.5.4

  1. #1
    Active Member
    eShipper integration with osCmax 2.5.4


    Join Date
    Sep 2009
    Location
    Vancouver, BC, Canada
    Posts
    486
    Contribute If you enjoy reading the
    content here, click the below
    image to support our site.
    Click Here To Contribute To Our Site

    Total Contributions For

    JRR     $ 180.00
    Rep Power
    70


    Default eShipper integration with osCmax 2.5.4

    I am adding eShipper.com's shipping module to my site here in Canada. I think it also works in the USA. Has anyone else installed it? I am making notes on converting their osCommerce (see below). It is basically working but I can't change the country from the USA to Canada, and so the only way to test it was to go into the SQL data files and edit the country code stored for eShipper and then I could set the province. Obviously something is wrong with how the Country Code lookup is working and I will fix it I swear, once I have some free time.

    These notes are a WORK IN PROGRESS so there are errors and omissions. I've posted them so anyone interested can setup an account on eShipper.com and download the osCommerce file and try it themselves.

    -----------Edit e-shipper for osCmax 2.5.4---------------

    Notes:

    eShipper PRODUCTION API credentials: LIVE (PRODUCTION) URL: http://web.eshipper.com/fetch_rates
    API username:YourLoginID
    API password:YourPassword
    eShipper TEST API credentials: TEST URL: http://test.eshipper.com/fetch_rates
    TEST API Username:YourLoginID
    TEST API Password: 1234

    Files to copy into your catalog from eShipper installation directory called 'uploads':

    Catalog/includes/languages/english/modules/shipping/eshipper.php
    Catalog/includes/modules/shipping/eshipper.php
    Catalog/admin/getcountry.php

    All the other files are left, you just need to edit the EXISTING osCmax files as below:

    *** in Catalog/checkout_shipping.php (not sure if anything needs changing - seems to work)

    *** in Catalog/includes/database_tables.php before final ?> add:

    //table for eshipper module
    define('TABLE_ESHIPPER_STATUS', 'eshipper_status');
    //table for weight class
    define('TABLE_WEIGHT_CLASS', 'weight_class');

    *** in Catalog/includes/classes/shipping.php

    at or around line 119 - 128 replace:

    while (list(, $value) = each($this->modules)) {
    $class = substr($value, 0, strrpos($value, '.'));
    if (tep_not_null($module)) {
    if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
    $include_quotes[] = $class;
    }
    } elseif ($GLOBALS[$class]->enabled) {
    $include_quotes[] = $class;
    }
    }

    with:


    // while (list(, $value) = each($this->modules)) {
    // $class = substr($value, 0, strrpos($value, '.'));
    // if (tep_not_null($module)) {
    // if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
    // $include_quotes[] = $class;
    // }
    // } elseif ($GLOBALS[$class]->enabled) {
    // $include_quotes[] = $class;
    // }
    // }

    foreach($this->modules as $value)
    {
    $class = substr($value, 0, strrpos($value, '.'));
    // if (tep_not_null($module)) {
    // if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {
    // $include_quotes[] = $class;
    // }
    // } elseif ($GLOBALS[$class]->enabled) {
    // $include_quotes[] = $class;
    // }
    $include_quotes[] = $class;
    }

    //echo "<pre>"; print_r($include_quotes); exit;


    *** in Catalog/includes/languages/english/modules/shipping/ add eshipper.php

    *** in Catalog/includes/modules/shipping/ add eshipper.php

    *** in Catalog/admin/includes/languages/english/core.php add before final ?>:

    //eshipper definitions
    define('MODULE_SHIPPING_ESHIPPER_TEXT_TITLE', 'eShipper');
    define('MODULE_SHIPPING_ESHIPPER_TEXT_DESCRIPTION' , 'install eShipper');
    //end shipper definitions

    *** in Catalog/includes/languages/english/core.php add before final ?>:

    //eshipper definitions
    define('MODULE_SHIPPING_ESHIPPER_TEXT_TITLE', 'eShipper');
    //end shipper definitions


    *** in Catalog/admin/includes/database_tables.php before final ?> add:

    //table for eshipper module
    define('TABLE_ESHIPPER_STATUS', 'eshipper_status');
    //table for weight class
    define('TABLE_WEIGHT_CLASS', 'weight_class');

    *** in Catalog/admin/includes/functions/general.php at or around line 852 replace:

    function tep_cfg_pull_down_zone_list($zone_id) {
    return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);
    }

    with:

    function tep_cfg_pull_down_zone_list($zone_id, $key = '') {
    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
    $zone_query = tep_db_query("SELECT * FROM " . TABLE_CONFIGURATION . " WHERE `configuration_key` = 'ESHIPPER_STORE_COUNTRY'");
    $zone_data = tep_db_fetch_array($zone_query);
    return tep_draw_pull_down_menu($name, tep_get_country_zones($zone_data['configuration_value']), $zone_id);
    }

    *** in Catalog/admin/includes/functions/general.php before the final ?> add:


    // eshipper

    function tep_get_eshipper_status($status_id, $language_id = '') {
    global $languages_id;

    if ($status_id < 1) return TEXT_DEFAULT;

    if (!is_numeric($language_id)) $language_id = $languages_id;

    $status_query = tep_db_query("select status_name from " . TABLE_ESHIPPER_STATUS . " where status_id = " . $status_id);
    $status = tep_db_fetch_array($status_query);

    return $status['status_name'];
    }

    function tep_cfg_pull_down_eshipper_status($status_id, $key = '') {
    global $languages_id;

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $status_array = array(array('id' => '0', 'text' => TEXT_DEFAULT));
    $status_query = tep_db_query("select status_id, status_name from " . TABLE_ESHIPPER_STATUS . " order by status_id");
    while ($statuses = tep_db_fetch_array($status_query)) {
    $status_array[] = array('id' => $statuses['status_id'],
    'text' => $statuses['status_name']);
    }

    return tep_draw_pull_down_menu($name, $status_array, $status_id);
    }

    //weight class

    function tep_get_weight_class($weight_class_id, $language_id = '') {
    global $languages_id;

    if ($weight_class_id < 1) return TEXT_DEFAULT;

    if (!is_numeric($language_id)) $language_id = $languages_id;

    $weight_query = tep_db_query("select weight_class_name from " . TABLE_WEIGHT_CLASS . " where weight_class_id = " . $weight_class_id);
    $weight = tep_db_fetch_array($weight_query);

    return $weight['weight_class_name'];
    }

    function tep_cfg_pull_down_weight_class($weight_class_id, $key = '') {
    global $languages_id;

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $weight_array = array(array('id' => '0', 'text' => TEXT_DEFAULT));
    $weight_query = tep_db_query("select weight_class_id, weight_class_code, weight_class_name from " . TABLE_WEIGHT_CLASS . " order by weight_class_id");
    while ($weight = tep_db_fetch_array($weight_query)) {
    $weight_array[] = array('id' => $weight['weight_class_id'],
    'text' => $weight['weight_class_name']);
    }

    return tep_draw_pull_down_menu($name, $weight_array, $weight_class_id);
    }

    *** in Catalog/admin/includes/functions/html_output.php at or around line 316 replace:

    $field = '<select name="' . tep_output_string($name) . '"';

    if (tep_not_null($parameters)) $field .= ' ' . $parameters;


    with:

    $field = '<select name="' . tep_output_string($name) . '"';

    if($name == 'configuration[ESHIPPER_STORE_COUNTRY]') { $field .= ' onchange="javascript:getCountryId(this.value)"';}

    if (tep_not_null($parameters)) $field .= ' ' . $parameters;

    *** in Catalog/admin/includes/general.js before final } add:

    function getCountryId(country)
    {
    $.get('getcountry.php', {country_id: country}, function (data) {
    console.log(data);
    var mySelect = $('select[name="configuration[ESHIPPER_STORE_PROVINCE]"]');
    $(mySelect).html(data);
    });

    -------------end edits----------------

    Note that you do NOT replace the above osCmax original files to be edited with the files in the eShipper zip file - that WILL break your osCmax.

    BACKUP, BACKUP, BACKUP!!!

    TEST on a LOCALHOST or similar setup, not your live store!!

    I will add to this over the next couple of days as I debug it, but wanted to get this down for others to play with if they were so inclined.

    John :-#)#
    Last edited by JRR; 08-29-2016 at 10:28 PM.

Similar Threads

  1. Replies: 0
    Last Post: 07-13-2008, 11:01 AM
  2. Replies: 0
    Last Post: 06-09-2008, 12:00 PM
  3. Replies: 0
    Last Post: 03-24-2008, 04:11 PM
  4. Replies: 0
    Last Post: 03-03-2008, 04:31 PM
  5. Replies: 0
    Last Post: 01-30-2008, 09:13 PM

Tags for this Thread

Bookmarks

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
  •