Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Canpar contribution


stuffy

Recommended Posts

Hello, i tried to use the Canpar contribution, but am receiving $0 for shipping quotes.

This was last updated in Aug 26 2007, and maybe Canpar has updated their site since then.

 

I am not into coding at all, but would appreciate if someone could take a look and see if they can get this working.

 

Thanks in advance.

Link to comment
Share on other sites

  • 1 month later...
Hello, i tried to use the Canpar contribution, but am receiving $0 for shipping quotes.

This was last updated in Aug 26 2007, and maybe Canpar has updated their site since then.

 

I am not into coding at all, but would appreciate if someone could take a look and see if they can get this working.

 

Thanks in advance.

 

There was a problem with the http->Connect method used and was replaced with a file_get_contents() approach instead for a Zen Cart implementation.

 

Its still a less than stellar approach, but is the best that can be achieved with Canpar unfortunately due to lack of a formal API.

 

Change Lines 50-78 (approx) in /catalog/includes/modules/shipping/canpar.php FROM:

      //Connect to CanPar here to get quote, and parse XML.
     $request = join('&', array('service=1',
                                'quantity=' . $shipping_num_boxes,
                                'unit=L',
                                'origin=' . $srcFSA,
                                'dest=' . $desFSA,
                                'cod=0',
                                'weight=' . intval($shipping_weight),
                                'put=0',
                                'xc=0',
                                'dec=0'));

     $http = new httpClient();

     if ($http->Connect('www.canpar.com', 80)) {
       $http->addHeader('Host', 'www.canpar.com');
       $http->addHeader('User-Agent', 'osCommerce');
       $http->addHeader('Connection', 'Close');

       if ($http->Get('/CanparRateXML/BaseRateXML.jsp?' . $request)) $body = $http->getBody();

       $http->Disconnect();
     } else {
       return 'error';
     }

     $body_array = explode("<BaseRate>", $body);
     $ShippingCost = $body_array[1];
     $ShippingCost = ereg_replace('</BaseRate></CanparCharges></CanparRate>', '', $ShippingCost);

 

TO:

$request = join('&', array('service=1',
                                'quantity=' . $shipping_num_boxes,
                                'unit=L',
                                'origin=' . $srcFSA,
                                'dest=' . $desFSA,
                                'cod=0',
                                'weight=' . intval($shipping_weight),
                                'put=0',
                                'xc=0',
                                'dec=0'));

  $body = file_get_contents('http://www.canpar.com/CanparRateXML/BaseRateXML.jsp?' . $request);
     $body_array = explode("<BaseRate>", $body);

     $ShippingCost = $body_array[1];
     $ShippingCost = ereg_replace('</BaseRate></CanparCharges></CanparRate>', '', $ShippingCost);

Edited by cookie_guy
Link to comment
Share on other sites

  • 1 year later...

I am still having this problem.

 

Installed canpar module, applied update and am getting quotes for $0.

 

Any new updates on this since 2007?

 

There was a problem with the http->Connect method used and was replaced with a file_get_contents() approach instead for a Zen Cart implementation.

 

Its still a less than stellar approach, but is the best that can be achieved with Canpar unfortunately due to lack of a formal API.

 

Change Lines 50-78 (approx) in /catalog/includes/modules/shipping/canpar.php FROM:

      //Connect to CanPar here to get quote, and parse XML.
     $request = join('&', array('service=1',
                                'quantity=' . $shipping_num_boxes,
                                'unit=L',
                                'origin=' . $srcFSA,
                                'dest=' . $desFSA,
                                'cod=0',
                                'weight=' . intval($shipping_weight),
                                'put=0',
                                'xc=0',
                                'dec=0'));

     $http = new httpClient();

     if ($http->Connect('www.canpar.com', 80)) {
       $http->addHeader('Host', 'www.canpar.com');
       $http->addHeader('User-Agent', 'osCommerce');
       $http->addHeader('Connection', 'Close');

       if ($http->Get('/CanparRateXML/BaseRateXML.jsp?' . $request)) $body = $http->getBody();

       $http->Disconnect();
     } else {
       return 'error';
     }

     $body_array = explode("<BaseRate>", $body);
     $ShippingCost = $body_array[1];
     $ShippingCost = ereg_replace('</BaseRate></CanparCharges></CanparRate>', '', $ShippingCost);

 

TO:

$request = join('&', array('service=1',
                                'quantity=' . $shipping_num_boxes,
                                'unit=L',
                                'origin=' . $srcFSA,
                                'dest=' . $desFSA,
                                'cod=0',
                                'weight=' . intval($shipping_weight),
                                'put=0',
                                'xc=0',
                                'dec=0'));

  $body = file_get_contents('http://www.canpar.com/CanparRateXML/BaseRateXML.jsp?' . $request);
     $body_array = explode("<BaseRate>", $body);

     $ShippingCost = $body_array[1];
     $ShippingCost = ereg_replace('</BaseRate></CanparCharges></CanparRate>', '', $ShippingCost);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...