Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pinball

Pioneers
  • Posts

    71
  • Joined

  • Last visited

Posts posted by Pinball

  1. Interesting contribution I do get a number of people who have trouble... however we need a modification where any accents in a name or address must be removed otherwise our shipping service gets annoyed. FedEx, UPS, and Canada Post (!) do not like accents in names or addresses. Is there any way to strip them out using your contribution?

    Thank you!

  2. Has anyone integrated FedEx Web Services with something like Canada Post sellonline (or UPS packing - which I haven't figured out)? i ask because sellonline does the packing for you and then returns the recommended box size (based on your list of boxes available) and the total weight. It would be great to integrate that into FedEx and/or UPS to get a more accurate box size rather than the system appearing to go just one weight. So large, but light objects are undercharged.

    I've tried searching for 'packing & Fedex Wed Services' but no real obvious results.

    Suggestions? I should just read the code but I'm hoping someone else who has more free time and is interested will look into this.

    Thanks!

  3. Loic, looks like you wrote new code (based on http://www.geoplugin.net/json.gp?ip=) to do much the same job that the original program did with http://api.wipmania.com/.

     

    However I'm no code jockey so I can't easily tell if this code is stand alone, or if it replaced the code that was originally intended to go in application_top.php - can you explain better what your code is supposed to do?

     

    For example, this program should only happen once - when the customer goes to your site. Afterwards the customer should be able to change the currency to whatever they prefer, and this program snippet should not try to force them back to their IP signed currency.

  4. Hi All, I'm not sure if anyone is using this addon - or following this thread... I'm not a professional coder by any stretch - just a shop owner with enough knowledge to be dangerous.

     

    I have re-wrote this addon to use the ip2location module created for this addon - http://addons.oscommerce.com/info/6955

     

    I did this to improve the realiabiliy of the addon. Thinking the wipmania API is only 99.9%  - that would mean one in evey 1000 hits the API fails (that is several customers per day for me).

     

    I was having issues, I had presumed, where 1 in every 100+ or so orders customers are 0 (no currecy, symbol or decimal). In additional I was receving phone calls about 1 every 2 or 3 days with the complaint of no prices showing.

     

    So, although my addon works - it did not fix the issues mentioned above. So, I NOW presume the issues caused by the code I carried forwared in appliation top but not sure why or where? I presumed this if statement would return default currency if the location was blank?

    if ($location == ''){
    		// $location is blank, use default method so we don't get $0 prices or in some cases no product listed.
    		$currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
    

    But aparently it's not working... or I'm not understanding????

     

    Anyway here is my code...

    	require_once (DIR_WS_MODULES . 'ip2location/ip2location.php');
    
    	$ip = IP2Location_open(DIR_WS_MODULES . 'ip2location/IP-COUNTRY-REGION-CITY-SAMPLE.BIN', IP2LOCATION_STANDARD);
    	$record = IP2Location_get_all($ip, $_SERVER['REMOTE_ADDR']);
    	IP2Location_close($ip);
    		
    	$location = $record->country_short;
    	
    	if ($location == ''){
    		// $location is blank, use default method so we don't get $0 prices or in some cases no product listed.
    		$currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
    	}else{
    		//since it has not been determined, find the currency it needs to be changed to
    		$currency_id_result=tep_db_query("SELECT countries_currencyid FROM countries WHERE countries_iso_code_2='".$location."'");
    		
    		while($currency_row=tep_db_fetch_array($currency_id_result)) {
    			$currency_id=$currency_row['countries_currencyid'];
    		};
    	
    		//create session variable to show that it has now been determined
    		$currency=$currency_id;
    		$_SESSION['locationset']=$location;
    		$_SESSION['currency']=$currency;
    	}
    
    //END OF ALTERATIONS
    

    My latest version of this code "seems" reliable.... However, I'm don't understand why the above is not working and my new code changes the last lines to hard code the currency... Making it less useable by the community in general

    		//create session variable to show that it has now been determined
    		if ($currency_id != 'CAD') {
    		$currency='USD'; }
    		else {
    		$currency='CAD'; }
    		$_SESSION['locationset']=$location;
    		$_SESSION['currency']=$currency;
    

    Does this mean its not setting the session??? Or is the "if statement" mentioned above not placed correctly????

     

    Hi Scott,

     

    I too am a fellow shop owner, not a trained coder, but can hack my way through some code...

     

    Not sure if you are still looking at this program, but I am working on a variation for osCmax (it will also work in osCommerce to keep on topic here) and will post any changes needed to get it working. I do believe that nouveau9's suggestion just above this post will resolve your posted problem with a few miner tweaks. For example I do not think the countries_id needs to be 300, unless he wanted it always at teh very end of the countries list...

     

    John :-#)#

  5. I have been able to get past the login on this program, but I am stuck at the next step.

     

    Here is my code up to where it breaks down - works up to the point where the destination is selected. If you replace your code with this up to the same line (fill in your password, etc. but NOT your credit card info!) you will see that the screen for est.canadapost.ca/esto appears twice near the bottom of your test posting to CP.

    Do not fill in any credit card info so the process will always crash near the end once it gets to payment.

    Next best thing to a sandbox...

    <?php
    /*
    $Id: index.php 1692 2012-02-26 01:26:50Z [email protected] $
     - lines 15 to 23 here were borrowed from index.php to be inserted at the top of ship_canadapost.php - delete second instance of require(includes/application_top.php'); for it to work - otherwise the search tabs are broken in osCmax 2.5.x
      osCmax e-Commerce
      http://www.oscmax.com
    
      Copyright 2000 - 2011 osCmax
    
      Released under the GNU General Public License
      
      fresh edit from previously (to 2013) ship_canadapost.php by John Robertson
    */
    
    //  require('includes/application_top.php'); // can delete this line...
      
      if (isset($_GET['setasdefault'])) {
        tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $_GET['setasdefault'] . "' where configuration_key = 'INDEX_TAB'");
    	// Configuration Cache modification start
        require ('includes/configuration_cache.php');
        // Configuration Cache modification end
        tep_redirect(tep_href_link(FILENAME_DEFAULT));
      }
    ?>
    <!-- end of additional section to enable ship_canadapost.php to work correctly with osCmax 2.5.x -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <link rel="stylesheet" type="text/css" href="includes/javascript/jquery-ui-1.8.2.custom.css">
    <script type="text/javascript" src="includes/general.js"></script>	
    </head>
    <body>
    <?php
    $debug = 1; // setting to 1 displays all responses from Canada Post, 0 is off.
      
    require('includes/application_top.php');
    require(DIR_WS_FUNCTIONS . 'ship_canadapost.php'); // in languages/english/
    require_once(DIR_FS_ADMIN . DIR_WS_CLASSES . 'shipping_form.php'); //labels for shipping form
    include(DIR_WS_INCLUDES . 'abbreviate.php'); // used to abbreviate state & country names
    
    $action = $_GET['action'];
    $order_id = $_GET['oID'];
    
    $form = new shipping_form();
    // Enable next two lines to activate error levels for debugging 
    error_reporting(E_ALL & E_STRICT & ~E_DEPRECATED);
    ini_set('display_errors',1); 
    
    /*******************************************************************************
    *** EDIT VARIABLES BELOW                                                     ***
    *******************************************************************************/
    // Canada Post account
    $cp_user = '';
    $cp_password = '';
    $cp_contract = '';  // if you have a CP contract, put it here to pay via
                               // account instead of credit card
    $cp_use_account = 0;       // set to 1 to pay via account instead of credit card (0)
    
    // Sender data (the address is already stored in Canada Post account)
    $cp_shipper_name = '';
    $cp_shipper_phone = '';
    $cp_shipper_pc = ''; // postal code of the form A1B 2C3
    $cp_cc_alias = 'xxxx********xxxx'; // card number on file at CP only fill in below if you do not have (or want to have) CC number stored at CP
    
    // Credit card data (more secure to store it here than in the database, but use SFTP...)
    $cp_cc_hard_code = FALSE; // set to TRUE if you would like to use the values below
    $cp_cc_type = 'MC1'; // AME1, MC1 or VIS1 for Amex, MasterCard or Visa
    $cp_cc_number = '<cc number>';
    $cp_cc_expiry = 'xx/yy'; // MM/YY
    $cp_cc_owner = '<name on cc>';
    $cp_cc_cvv = '<security code>';
    
    // Other configuration
    $send_email_on_shipping = TRUE; // notify customer that the order has shipped
                                    // and provide tracking number if available
                                    
    $default_length = '35.0';       // provide package size (could add some kind
    $default_width = '25.0';        // of manager in the future)
    $default_height = '4.0';        // FYI Canada Post breaks with some combinations
    
    $default_reason_for_export = 'OTH'; // SAM, GIF, TRD, REP, DOC, OTH
    $weight_factor = 1.000; // factor to convert weight in database to kg
    
    // Order status to set when order shipped
    define('CANADAPOST_ORDER_STATUS_SHIPPED', 4);
    
    /*******************************************************************************
    *** No need to edit anything below                                           ***
    *******************************************************************************/
    
    
    
    if (!$order_id) {
      die (ERROR_NO_ORDER_NUMBER);
    }
    
    // get all information from the order record
    $order_query = tep_db_query("select * from orders where orders_id = '$order_id'");
    $order_info = tep_db_fetch_array($order_query);
    
    $countries_query = tep_db_query("select countries_iso_code_2 from " . TABLE_COUNTRIES . " where countries_id = '" . tep_get_country_id($order_info['delivery_country']) . "'");
    $countries = tep_db_fetch_array($countries_query);
    $delivery_country_iso_code_2 = $countries['countries_iso_code_2'];
    // abbreviate the delivery state (function is in abbreviate.php)
    $delivery_state_abbrev = abbreviate_state($order_info['delivery_state']);
      
    $label_file = DIR_WS_IMAGES . 'canadapost/' . $order_id . '.pdf';
    
    /*******************************************************************************
      Make a new ship request
        Shows configuration page 
    *******************************************************************************/
    
    if($action=='new') {
      $order_id = $_GET['oID'];
    
      // arrays for shipping options; include as many or as few as you like
      
      $reason_for_export = array();
      $reason_for_export[] = array('id' => 'SAM', 'text' => 'Commercial Sample'); 
      $reason_for_export[] = array('id' => 'GIF', 'text' => 'Gift');
      $reason_for_export[] = array('id' => 'TRD', 'text' => 'Trade Show Exhibit');
      $reason_for_export[] = array('id' => 'REP', 'text' => 'Repair/Warranty');
      $reason_for_export[] = array('id' => 'DOC', 'text' => 'Document');
      $reason_for_export[] = array('id' => 'OTH', 'text' => 'Other');
    
      $service_type = array();
      $shipping_method_keywords = array();
      if ($delivery_country_iso_code_2 == 'CA') { // Canada
        $service_type[] = array('id' => '000000000000000967', 'text' => 'Expedited Parcel Piece Rated');
        $service_type[] = array('id' => '000000000000000966', 'text' => 'Regular Parcel Piece Rated');
        $service_type[] = array('id' => '000000000000001469', 'text' => 'Priority Courier Piece Rated');
        $service_type[] = array('id' => '000000000000001654', 'text' => 'Priority Courier Prepaid Ind');
        $service_type[] = array('id' => '000000000000000908', 'text' => 'Xpresspost Piece Rated');
        $service_type[] = array('id' => '000000000000000926', 'text' => 'Xpresspost Prepaid Induction');
        
        $shipping_method_keywords = array('000000000000000966' => 'Regular',
                                          '000000000000000967' => 'Expedited',
                                          '000000000000000908' => 'Xpresspost',
                                          '000000000000001469' => 'Priority');
      } elseif ($delivery_country_iso_code_2 == 'US') { // USA
        $service_type[] = array('id' => '000000000000010103', 'text' => 'Priority Worldwide EnvelopeUSA');
        $service_type[] = array('id' => '000000000000010104', 'text' => 'Priority Worldwide Pak USA');
        $service_type[] = array('id' => '000000000000010105', 'text' => 'Priority Worldwide Parcel USA');
        $service_type[] = array('id' => '000000000000001917', 'text' => 'Xpresspost USA');
        $service_type[] = array('id' => '000000000000002125', 'text' => 'Xpresspost USA Prepaid Ind');
        $service_type[] = array('id' => '000000000000006461', 'text' => 'Commercial* Expedited-USA');
        $service_type[] = array('id' => '000000000000006470', 'text' => 'Expedited Parcel-USA');
        $service_type[] = array('id' => '000000000000001123', 'text' => 'USA Small Packets Air Mail');
        $service_type[] = array('id' => '000000000000001124', 'text' => 'USA Small Packets Surface');
        
        $shipping_method_keywords = array('000000000000001123' => 'Small Packets Air',
                                          '000000000000001124' => 'Small Packets Surface',
                                          '000000000000006461' => 'Expedited US Business',
                                          '000000000000001917' => 'Xpresspost',
                                          '000000000000002020' => 'Purolator');
      } else {  // International
        $service_type[] = array('id' => '000000000000010100', 'text' => 'Priority Worldwide EnvelopeINT');
        $service_type[] = array('id' => '000000000000010101', 'text' => 'Priority Worldwide Pak INTL');
        $service_type[] = array('id' => '000000000000010102', 'text' => 'Priority Worldwide Parcel INTL');
        $service_type[] = array('id' => '000000000000006210', 'text' => 'Xpresspost - International');
        $service_type[] = array('id' => '000000000000000985', 'text' => 'International Parcel Air');
        $service_type[] = array('id' => '000000000000000984', 'text' => 'International Parcel Surface');
        $service_type[] = array('id' => '000000000000009611', 'text' => 'Intl Small Packets Surface');
        $service_type[] = array('id' => '000000000000009610', 'text' => 'Intl Small Packets Air');
        
        $shipping_method_keywords = array('000000000000009610' => 'Small Packets Air',
                                          '000000000000009611' => 'Small Packets Surface',
                                          '000000000000006210' => 'Xpresspost',
                                          '000000000000002020' => 'Purolator',
                                          '000000000000000985' => 'Parcel Air',
                                          '000000000000000984' => 'Parcel Surface');
      }
    
      // get the shipping method
      $shipping_type = '';
      $shipping_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $order_id . "' and class='ot_shipping'");
      $shipping_method = tep_db_fetch_array($shipping_query);
      $shipping_method = trim($shipping_method['title'], ':');
    
      while (list($shipping_index, $shipping_keyword) = each($shipping_method_keywords)){
        if (false !== stripos($shipping_method, $shipping_keyword, 1)){
              $shipping_type = $shipping_index;
              break 1;
          }
        }
    
    // get the order qty and item weights
      $order_qty_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $order_id . "'");
      $order_qty = 0;
      $order_weight = 0;
      $order_item_html = '';
      if (tep_db_num_rows($order_qty_query)) {
        while ($order_qtys = tep_db_fetch_array($order_qty_query)) {
          $order_item_html = $order_item_html . '          <tr>' . "\n" .
                                                '            <td class="smallText" align="left">' . $order_qtys['products_quantity'] . ' * ' . $order_qtys['products_name'] . '</td>' . "\n" .
                                                '            <td class="smallText" align="left">';
          $order_qty = $order_qty + $order_qtys['products_quantity'];
          $products_id = $order_qtys['products_id'];
          $products_weight_query = tep_db_query("select * from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
          if (tep_db_num_rows($products_weight_query)) {
            $products_weights = tep_db_fetch_array($products_weight_query);
            $order_weight = $order_weight + ($order_qtys['products_quantity'] * ($products_weights['products_weight']));
            $item_weights[] = $products_weights['products_weight'];
          }
        }
    
        $order_weight = $order_weight + SHIPPING_BOX_WEIGHT;
        
        /*
        // Find out which weighs more tare or percentage shipping rate and display that rate
        $order_weight_tar = $order_weight + SHIPPING_BOX_WEIGHT;
        $order_weight_percent = ($order_weight * (SHIPPING_BOX_PADDING / 100 + 1));
    
        if ($order_weight_percent < $order_weight_tar) {
        $order_weight = $order_weight_tar;
        } else {
        $order_weight = $order_weight_percent;
        }
        */
            
        $order_weight = round($order_weight * $weight_factor,3);
        $order_weight = sprintf("%01.3f", $order_weight);
      }
    }
    
    /*******************************************************************************
      Start writing webpage HTML
    *******************************************************************************/
    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?php echo HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <script language="javascript" src="includes/general.js"></script>
    <?php $form->print_js(); ?>
    </head>
    <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
    <!-- header //-->
    <?php
      require(DIR_WS_INCLUDES . 'header.php');
    ?>
    <!-- header_eof //-->
    
    <!-- body //-->
    <table border="0" width="100%" cellspacing="2" cellpadding="2">
      <tr>
        <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
    <!-- left_navigation //-->
    <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
    <!-- left_navigation_eof //-->
        </table></td>
    <!-- body_text //-->
        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
                  <td width="100%">
    <?
    /*******************************************************************************
      Make a new ship request
        Shows form to fill out
    *******************************************************************************/
    
    if ($action=='new') {
      $form->dim_type = 'cm';
      $form->weight_type = 'kg';
      $form->weight_factor = 1.0;
      
      $check_status_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
      $check_status = tep_db_fetch_array($check_status_query);
      if ($check_status['orders_status'] == CANADAPOST_ORDER_STATUS_SHIPPED) {
        echo '<div style="font-weight: bold; color: white; background-color: red; border: 1px solid gray; padding: 5px;">Warning: Order already shipped</div>';
      }
      
      /*
      $address1 = trim($order_info['delivery_street_address']);
      $address2 = '';
      if (strlen($address1) > 44) { // maximum is 44 letters
        if(strstr($address1, '-') !== FALSE) {
          ereg("(.+)-([^-]+)$", $address1, $matches);
          $address1 = trim($matches[1]);
          $address2 = trim($matches[2]);
        } else if(strstr($address1, ',') !== FALSE) {
          ereg("(.+),([^,]+)$", $address1, $matches);
          $address1 = trim($matches[1]);
          $address2 = trim($matches[2]);
        } else if(stristr($address1, ' ') !== FALSE) {
          ereg("(.+) ([^ ]+)$", $address1, $matches);
          $address1 = trim($matches[1]);
          $address2 = trim($matches[2]);
        }http://www.canadapost.ca/cpo/mc/default.jsf?LOCALE=en
      }
      */
      
      echo tep_draw_form('ship_form', FILENAME_SHIP_CANADAPOST, 'cPath=' . $cPath . '&cID=' . $_GET['cID'] . '&oID=' . $order_id . '&action=ship', 'post', 'enctype="multipart/form-data"  onsubmit=""');
      $form->print_form($order_id, !$cp_use_account && !$cp_cc_hard_code, $order_weight, $default_length, $default_width, $default_height, $service_type, $shipping_type, $reason_for_export, $default_reason_for_export);
      echo '</form>';
    } else if($action=='ship') {
    /*******************************************************************************
      Process shipment with Canada Post
        Does all the transactions with Canada Post servers and provides a label
    *******************************************************************************/
      $check_status_query = tep_db_query("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
      $check_status = tep_db_fetch_array($check_status_query);
      if ($check_status['orders_status'] == CANADAPOST_ORDER_STATUS_SHIPPED) {
        echo '<div style="font-weight: bold; color: white; background-color: red; border: 1px solid gray; padding: 5px;">Error: Order already shipped</div>';
        die();
      }
    
    
      $countries_query = tep_db_query("select countries_iso_code_2 from " . TABLE_COUNTRIES . " where countries_id = '" . tep_get_country_id(cp_post_var('delivery_country')) . "'");
      $countries = tep_db_fetch_array($countries_query);
      $delivery_country_iso_code_2 = $countries['countries_iso_code_2'];
      // abbreviate the delivery state (function is in abbreviate.php)
      $delivery_state_abbrev = abbreviate_state(cp_post_var('delivery_state'));
    
    
      echo '<div class="pageHeading">Canada Post Automatic Labels</div>';
      echo tep_draw_separator('pixel_trans.gif', 1, 20);
      
      // array of characters we don't want in phone numbers
      $unwanted = array('(',')','-','.',' ','/');
      // get rid of dashes, parentheses and periods in customer's telephone number
      $delivery_phone = trim(str_replace($unwanted, '', cp_post_var('delivery_phone')));
    
      ////
      // 1. INITIALIZE
      
      if (file_exists('temp/cp_cookies')) {
        unlink('temp/cp_cookies'); // delete old cookie file
      }
      
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_VERBOSE, 0);
      curl_setopt($ch, CURLOPT_POST, 0);
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt($ch, CURLOPT_REFERER, 'https://est.canadapost.ca/esto/');
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  //Windows 2003 Compatibility 
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
      curl_setopt($ch, CURLOPT_HEADER, 1);
      
      curl_setopt($ch, CURLOPT_COOKIEFILE, 'temp/cp_cookies');
      curl_setopt($ch, CURLOPT_COOKIEJAR, 'temp/cp_cookies');
      
      // Sanity Check and Progress Report
      cp_progress(1, 'Initialized.');
      
      ////
      // 2. LOG IN
    echo "<br>" . "hi! - log in" . "<br>"; //Test
    //  $response = cp_get_page($ch, 'https://sso.epost.ca/sso/lfe/ui/login?'); is this line needed? Sept 2, 2015
      
      // original  was 'https://www.canadapost.ca/cpid/login.jsp?SSO_REFERRER_URL=https://www.canadapost.ca');
      
      $query_string = 'cpidSignIn:signIn.x=46&cpidSignIn:signIn.y=11&cpidSignIn_SUBMIT=1'
                    . '&cpidSignIn:sso_username=' . urlencode($cp_user)
                    . '&cpidSignIn:sso_password=' . urlencode($cp_password)
                    . '&cpidSignIn:rememberUserName=true'
                    . '&destination=https://est.canadapost.ca';
    
    // one ends up here: https://www.canadapost.ca/web/en/home.page?forceVouchFor=true                     
      $response = cp_post_page($ch, 'https://sso.epost.ca', $query_string);
    
      echo "<br>" . "Hi! Sign in query string: " . $query_string . '<br>' . "<br>" ;
    
      
    echo  "<b>Seems to work to here, line 368 - get to login page fine. Below is on the page https://sso.epost.ca/...</b><br><br>";  
    
      $response = cp_get_page($ch, 'https://sso.epost.ca/sso/lfe/ui/login?');
      
      $query_string = 'SHOP=CPFRCOMM&SSO_ITS_URL=%2Fcpid%2Flogin.jsp&SSO_ACTION=0&P_SHOP=CPFRCOMM'
                    . '&login_type=2&password_length=0&%7Elanguage=EN&APP_ID=B2B'
                    . '&SSO_USERNAME=' . urlencode($cp_user)
                    . '&SSO_PASSWORD=' . urlencode($cp_password);
    echo "hi from line 378!";  //Test               
      $response = cp_post_page($ch, 'https://est.canadapost.ca/esto/', $query_string);
     echo $response;  //Test
    
    
      // get Canada Post customer number - is this step needed??
      $regexp = "SSO_CUSTOMER_NUMBER\" value=\"([0123456789]*)(,|\")";
      $matches = '';
      preg_match("/$regexp/siU", $response, $matches);
      $cp_customer = $matches[1];
     echo "hi from line 388!<br>";   
      $response = cp_submit_page($ch, $response, 'https://est.canadapost.ca/esto/');
     
    echo "hi from line 395!<br>"; //Test
    echo $response; //Test
    
      // Sanity Check and Progress Report - 
    echo "we are getting to the login test, and we actually have reached the page after login successfull!, looking for hidden name = sso_version_major, value of '3'";
      if (strstr($response, '<input type=hidden name="Set-Cookie:">') === ESTO_JSESSIONID) {
        cp_error(2, 'Log-In Failed check in ' . __FILE__ . ' at line ' . __LINE__  . '. This most likely means that Canada Post has changed their user interface or your login info is incorrect. You need to update your Canada Post Automatic Shipping Labels module.');
        curl_close($ch); die(); /////////////////////
      } else {
        cp_progress(2, 'Logged in.');
      }
      echo "logged in!<br><br>"; //Test
       
    echo "Start Shipping<br><br>"; //Test
      ////
      // 3. START SHIPPING - Select iso code
      
      $form_prefix = '';
      if ($delivery_country_iso_code_2 == 'CA') {
        $form_prefix = 'domestic';
      } elseif ($delivery_country_iso_code_2 == 'US') {
        $form_prefix = 'us';
      } else {
        $form_prefix = 'international';
      }
      
    //  $response = cp_get_page($ch, 'https://est-oee.canadapost-postescanada.ca/shipping/estShipping.jsp?locale=en_CA&formId=' . $form_prefix . '0&isV1=true');
     $response = cp_get_page($ch, 'https://est.canadapost.ca/esto/app/shipment/' . $form_prefix . '?execution=e1s1'); 
     
      $regexp = "URL=([^\"]*)\"";
      $matches = '';
      preg_match("/$regexp/siU", $response, $matches);
      $url = $matches[1];
      echo "regexp= ";
      echo $regexp;
           echo ", url= ";
        echo $url;
        echo ", ch= ";
        echo $ch;
    //      echo ", response= ";
    //    echo $response;
          echo ", form_prefix= ";
        echo $form_prefix;
     // $response = cp_get_page($ch, $url);
      $response = cp_submit_page($ch, $response);
    echo $response;  //test
      /**/
      $regexp = "URL=([^\"]*)\"";
      $matches = '';
      preg_match("/$regexp/siU", $response, $matches);
      $url = $matches[1];
      
      $response = cp_get_page($ch, $url);
          echo ", response2 = ";
        echo $response;
      $response = cp_submit_page($ch, $response);
         echo "matches = ";
        echo $matches;
        echo ", ch1 = ";
        echo $ch;
          echo ", response1 = ";
        echo $response;
          echo ", form_prefix = ";
        echo $form_prefix;
      /**/
      
      // Sanity Check and Progress Report
      if (stristr($response, '<input type="hidden" name="formId" value="' . $form_prefix . '0">') === FALSE) {
        cp_error(3, 'Ship To Country Select Failed check in ' . __FILE__ . ' at line ' . __LINE__  . '. This most likely means that Canada Post has changed their user interface. You need to update your Canada Post Automatic Shipping Labels module.');
        curl_close($ch); die(); /////////////////////
    
  6. While I have the rate quoting working using rateservice_v9.wsdl, there are some shortfalls - it appears that insurance is not calculated into the price even though the insurance amount is passed to the FedEx server:

     

    <ns1:TotalInsuredValue><ns1:Currency>USD</ns1:Currency><ns1:Amount>219.00</ns1:Amount></ns1:TotalInsuredValue>

     

    With or without an insurance amount there, the cost to the customer does not change.

     

    Thus I was thinking that it may be time to update to the latest rateservice_v18.wsdl file, but adding that to the /wdsl directory (and editing the fedexwebservices.php file so it uses it) doesn't work.

     

    I get this error back:

     

    xmlns="http://fedex.com/ws/rate/v18"><HighestSeverity>ERROR</HighestSeverity><Notifications><Severity>ERROR</Severity><Source>crs</Source><Code>300</Code><Message>Package1 - Group package count must be at least a value of 1.</Message><LocalizedMessage>Package 1 - Group package count must be at least a value of 1.</LocalizedMessage>

     

    which means that v18 wants parameters sent to the server that aren't considered in v9, so one has to add something to take care of group packages - even if the best way to start is setting it to default to "1".

     

    The error list page on FedEx says error 300:

     

    Package {PACKAGE_INDEX} - Group package count must be at least a value of 1.

     

    so one needs to introduce PACKAGE_INDEX - somewhere!

     

     

     

    I was also looking at using the label generation - but that is for another day.

  7. For those struggling with Error Code 1000 (detailed report below) I found a fix. It's been talked about before on this thread, but looks like the specific bits have changed a little.

     

    If you're using test credentials, the standard s1:address will not work, and you'll be rejected form the server. I think this has been mentioned elsewhere in the thread, but I couldn't find any exact details. To make it all work with test creds, change:

    <s1:address location="https://gateway.fedex.com/web-services/"/>

    to 

    <s1:address location="https://wsbeta.fedex.com:443/web-services/rate"/>

    and back again when you're done and want to use production info. Obviously, this can change frequently at FedEx' prerogative. So tread lightly and keep an eye out! 

    I reworked that somewhat, created two RateService file in /catalog/includes/wsdl/ - one called RateService_v9.wsdl (the default one) and a second called RateService_Test_v9.wsdl where I modified the line to:

    <s1:address location="https://gatewaybeta.fedex.com:443/web-services/rate"/>
    

    but left the default file as usual.

     

    Then in catalog/includes/modules/shipping/fedexwebservice.php I added (around line 83):

    // added for Web Services Testing - Sept 1, 2015
         if ((MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEST) == 'true') {
         $path_to_wsdl = DIR_FS_CATALOG . DIR_WS_INCLUDES . "wsdl/RateService_v9_Test.wsdl"; 
         } else { 
         $path_to_wsdl = DIR_FS_CATALOG . DIR_WS_INCLUDES . "wsdl/RateService_v9.wsdl";
         }
    // End addition for Web Services testing  
    

     and then at line 519:

        tep_db_query ("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Test Mode', 'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEST', 'false', 'Testing using gatewaybeta.fedex.com', '6', '19', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
    
    

    and line 571 (just after module_shipping_debugging'; !!! Add a comma after module_shipping_debugging !!!

                     'MODULE_SHIPPING_FEDEX_WEB_SERVICES_TEST'
    

    and the reinstalled fedexwebservices.php to install the changes.

     

    Now it is easier to switch between the test and production environment - of course you have to change passwords, signin stuff, etc.!

  8. Playing with insurance I like using Echo statements to show waht is happening with variables - for example to try and figure out what the value for insurance should be (sub_total - text) on the page I use:

     

          echo "Order amount for insurance purposes: " . $totals . "<br>";

     

    However this shows as blank unless you enable one of the previous commented out statements (around line 144)

     

    // Depending on your version of Order Editor, any one of the following lines may be appropriate for your setup.
    //    $totals = $order->info['subtotal'] = $cart->total;  // from CRE Loaded code - testing - this may be the one for all? // 09/04/2014 -  Disabling this as it may no longer be necessary and it screws up the sub-totals
    //    $totals = $order->info['subtotal'] = $_SESSION['cart']->show_total();  // original code
    //    $totals = $order->info['subtotal'] || $_SESSION['cart']->show_total();  // or perhaps this is better
    //    $totals = $cart->show_total();  // this seems to work for most - needed for insurance to get sub-total amount

     

    I enable the last one to show the sub-totals in my echo statement that shows up in my test setup (localhost) at the left top of the screen. This value IS handed to the data sent to FedEx (when $totals shows a value), however it doesn't appear to come back as anything in the price that makes a difference. Unless the value in my shopping cart is too low during this test ($219USD).

     

    I'll play some more and see what happens...

  9. Yes, I understand the logic, however I am not about to recalculate all my weights just yet.

     

    Mind you the FedEx Web Services contribution only works from weight and I have to wonder if that (volumetric weight of each item) is the way to go...what I thought would be fun was to use the box as defined by sellonline as the same box for Fedex, however this is getting off topic now...

  10. @@Pinball I'm using this without the dimensional support (I have almost a 3000 sku's.... Rather impossible as far as I can tell to use box sizing when ppl purchase any combination of those sku's)

     

    I have about 2500 items in my store and have dimensions for all of them, it just takes time to generate that data. So does your contribution only work by using weight? I thought CP lost a class action lawsuit over that very issue - Volumetric Weight. and they have to change by Oct 30, 2015. Are you finding the quotes accurate though when you just use the weight of the items? If your items are all small that is fine, but mine range from items about 1 cubic cc to things 30 x 20 x 15cm in size, and sellonline handles that very well and figures out the correct box from my posted list.

    I may have to install the SOAP or REST process for generating labels unless I can fix the existing contribution that used HTML scripts...I have found a workaround that is very nice for that - at least when I enter it manually after logging in and arriving at the select page.

  11. Sellonline is back up now. I know that CP still considers sellonline as a moderate priority as I did get a few tech support notices after calling to complain on Monday.

     

    I still prefer sellonline as it does the box calculations better than the UPS packages.php module. I am thinking that it might be a way to do the best packaging setup for other programs - in other words, use CPs packing methods, and then take the boxes it selects and run them through REDEX, UPS, etc. to get the closest rates for our customers. Not sure how to implement this, but CP does send back the box(es) needed to ship the items, and I see no reason a sectioncan be added to other shipping modules to use that as the weight and size of the box for getting a quote.

    This will only work for Canadians who are registered with sellonline.canadapost.ca, however we are all Cunuks here anyway!

  12. Great work! Much appreciated!!

     

    Like many I've found that CP has broken sellonline, and it appears to be something related to port 30000 - I was chatting with tech support today and they said a number of clients were all saying much the same thing, so sellonline should be fixed soon - I hope.

     

    That said I have to confess that I am not a fan of the packaging addition as it doesn't sound anywhere near as good as the one found on sellonline, but until CP fixes that interface I shall see what happens with your latest REST version.

     

    I am running osCmax 2.5.4, but the changes are usually minor to get contributions for osCommerce to work properly.

  13. Cross-over post from

    osc234 w/ Bootstrap & Canada Post Shipping Module

     

    Well, I've been struggling with the other end, trying to get the original admin interface working for generating labels - and I think I may have found the script to do just that. This doesn't use REST or SOAP, rather it gets you from the login screen directly to the Canadian destination data entry page where the original script should run just fine. While you are in the Canadian data page you can change to the US or International pages  OR you can write PHP code so the final line of the following script will sort out the destination Domestic/US/International.

     

    Note this was done using Firefox running on OSX Yosemite and the Selenium extension.

     

    Now I am no PHP code jockey, so I can't rewrite the code, but I'm hoping that someone here (greasemonkey or Insaini?) recognizes what I have found and can fix ship_canadapost.php -

    Canada Post Automated Labels 2.0 AND Canada Post Shipping Module 4.0

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head profile="http://selenium-ide.openqa.org/profiles/test-case">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="selenium.base" href="https://sso.epost.ca/sso/lfe/ui/login?" />
    <title>CanadaPostSeleniumLoginShipment-PrivateBrowsing1</title>
    </head>
    <body>
    <table cellpadding="1" cellspacing="1" border="1">
    <thead>
    <tr><td rowspan="1" colspan="3">CanadaPostSeleniumLoginShipment-PrivateBrowsing1</td></tr>
    </thead><tbody>
    <tr>
        <td>open</td>
        <td>https://sso.epost.ca/sso/lfe/ui/login?</td>
        <td></td>
    </tr>
    <tr>
        <td>assertTitle</td>
        <td>Sign in or sign up to Canada Post or epost | Canada Post</td>
        <td></td>
    </tr>
    <tr>
        <td>click</td>
        <td>id=sso_username</td>
        <td></td>
    </tr>
    <tr>
        <td>type</td>
        <td>id=sso_username</td>
        <td>#your CP number#</td>
    </tr>
    <tr>
        <td>click</td>
        <td>id=sso_remember</td>
        <td></td>
    </tr>
    <tr>
        <td>click</td>
        <td>id=sso_password</td>
        <td></td>
    </tr>
    <tr>
        <td>type</td>
        <td>id=sso_password</td>
        <td>#your CP password#</td>
    </tr>
    <tr>
        <td>click</td>
        <td>id=sso_action</td>
        <td></td>
    </tr>
    <tr>
        <td>open</td>
        <td>https://est.canadapost.ca/esto/app/shipment/domestic?execution=e1s1</td>
        <td></td>
    </tr>
    </tbody></table>
    </body>
    </html>
    

    Note that for the Rates portion (customers side) I am using canadapost.php which is the other part of the above links package. Which works fine for me, it is accurate and uses dimensions which are forwarded to sellonline.canadapost.ca where it looks up your boxes and sees which box it can stuff the items into, giving you the box name and costs back to your shopping cart customer.

  14. Does anyone know the rational for adding the alter table bits in AttributeManagerConfig.class.php? These affect products_weight and other areas and stop one from modifying the tables if one wants something outside of decimal(6,3) and default weight of 0.000.

  15. Ignore my post #22 just above!

     

    I was in error about the pricing in USD being wrong for Canadians - had forgotten to allow for insurance which is not a line item on the Canada Post rate quote. So the system does charge both US and Canadian customer correctly for the rate quote.

     

    So sorry about the previous post just above (#22), I should have double checked prior to posting it.

     

    Gah!

  16. I've noticed that my USD based store seems to charge Canadian customers postage as if the rate calculated was in USD. So instead of a charge of $20CAD they get a charge of around $30USD. Calculating online gets the correct value of course. We do have CAD and USD as currency options for customers. US customers are not overcharged by the way...just Canadians!

     

    Not sure where the currency setting is for the CP module, certainly not in the settings under admin!

     

    I'm going to work on getting the REST or SOAP running for generating the labels, it takes too long for staff to type them in manually...

  17. Hello,

     

    I am also getting the same error as "simple190"

     

     

    It is happening in the checkout when try to show sipping options.

     

    Also is there any way to make it print out the error code it is getting?

     

    I am running this on Version: 2.3.3.4

     

    Thanks,

     

    When you are using the packaging side of Canada Post you must be SURE to have all your dimensions larger than or equal to 0.001 (units). Any zero value will result in either the module or CP rejecting the operation and your customer will not get a postal quote option and so they think the shipping is included (or not, depends on the customer). We had a heck of a time figuring this undocumented fault, and it was only after we had a few customers ordering particular items that we realized what was happening. Downloading the data dimensions and product # & name and then sorting by weight (ascending) found the ten items out of 4,000 that had zero weights. Did the same for Length, Width, and Height as there were a few there too.

    Although in fact the database length dimensions default to 12, the weight defaults to 0.000 - so edit that to something like 0.010 (KGS/LBS) so you don't have that particular problem.

    At this time I don't know how to get the error codes to display, however Canada Post Developers Site does provide you with the full set of error codes so you can implement them if you can (I can't so far - not proficient at PHP).

  18. Any news on the Canada Post shipping front with respect to OSC ?

     

    I'd love to get real-time rates based on dimensions, weight, source postal code and destination postal code. I'm trying to follow all these various threads and cannot even determine if any of the contribs work at all ?

     

    The Canada Post Shipping Module - http://addons.oscommerce.com/info/391 - works just fine. My customers use it all the time...

     

    It is the admin side of things that is broken - the Canada Post Automated Labels (CPAL) bit from http://addons.oscommerce.com/info/5842, this is where one needs to either integrate the REST module from http://addons.oscommerce.com/info/8887 or figure out the code to fix the java script breakdown that I mention. CPAL for the admin is a simple checkscreen where you make sure the data going to CP is correct, and you then click the 'submit' button and the script did the rest.

     

    Anyone in Vancouver, BC area of Canada who wants to work with me on sorting this out? I'm sure two people and some tea/coffee and an afternoon can figure out how to fix the code.

     

    You see the CP Automated Labels (CPAL) - almost - works. It is breaking down after the login page, it now goes to a page that requires java script to get out of and the original CPAL didn't see this page. Oddly enough if you manually put the page URLs in twice it DOES go to the correct page to fill in for the Domestic, US, or International customer's field entries and would probably work from there. I just don't know enough coding to figure out how to get around that second page.

  19. A work-around that needs to be added to the Canada Post label module to deal with the upgrade this past spring (2013) by Canada Post.

     

     

    It appears that a double post of https://obc.canadapost.ca/zcpb2b/b2b/zisa_choice.do?targetPage=eorder&language=EN

     

    is needed to get the admin side of Automatic labels to work.

     

    The first time the software sends the id and password, then the second time it simply simply send https://obc.canadapost.ca/zcpb2b/b2b/zisa_choice.do?targetPage=eorder&language=EN again.

     

    Alternatively it may be that you have to double post:

     

    https://www.canadapost.ca/cpid/apps/signIn

     

    instead, one of them will work the best...

     

    I will see what I can do to get this running and post the results.

     

    This will shift to the EST (Electronic Shipping Tools) page where you then select Canada/US/International (or at least the software then can take over.

     

    Should work until someone makes an easy way to integrate REST or SOAP to OSC.

     

     

    John :-#)#

  20. One cause of XML parsing errors is if the address country or province/state has special characters in it. Canada Post (for example) does not accept special characters such as umlauts or accents on names. There are a number of these in your address bank - check for example Switzerland - Zurich, does the 'u' of Zurich have the double dot above it (ü)? If so, Canada Post will reject that as a valid state/province.

    I suspect this is true for Fedex, UPS, and others too.

  21. It looks like the old API system will have to be updated to the new Web Services connection method. We have sent the project outline to a development company we use for cost and time frame. I will post any detail on progress as we get them.

     

    Anything to report Jeff? It's been months...we are still manually doing our CP labels...

  22. I spoke to Fabien Clermont at CanadaPost. He is the one addressing this issue. It sounds like they will want everyone to go over to the web services system eventually but I am trying to work out a solution so we can get our current code working and then move on to an update for the web services for a future upgrade.

     

    They are going to send over the new URL's and formats. I will try to apply to the existing code to get it working. I'll post any results and findings.

     

    Jeff,

     

    Did you ever get the new URLs and formats?

     

    Thanks,

     

    John :-#)#

  23. Does anyone know how the numbers for the "ID" (Primary) of XSell in products_xsell are generated? If they are simply adding one to the previous number that is great, but I see large gaps in the number sequence so was trying to figure out what made it. I do know that products_id is the number of the 1st product item, and that xsell_id is the cross-reference to the other items products_id, and finally that sort_order is, well, the order several items are show if there is more than one XSell item (each is linked to the next until you reach the end of the chain).

     

    I am working on an open source database manager using LibreOffice BASE (OpenOffice BASE didn't work so well when I tried it earlier this year) and this question popped up on me while experimenting with displaying the XSell data relative to the Product ID.

     

    I could read through the XSell code I guess, but was hoping someone knew off the top of their head what the answer is.

×
×
  • Create New...