Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Canpar Shipping Mod


larryjam

Recommended Posts

I have installed the Canpar Shipping Module found here http://www.oscommerce.com/community/contributions,4402

 

My store is located in Canada, and I would like to have it as a shipping option only for shipping to Canadian addresses.

 

There is no option in the admin control panel. Is there a way to confique this for Canada only?

Link to comment
Share on other sites

Is there no one else using the Canpar Shipping Module?

I really could use some help here. Canpar does not provide international shipping services. I only need to to be available to customers in Canada. If it is not possible please let me know.

 

Thank You

Link to comment
Share on other sites

i don't use canpar, but i separate canadian postage costs from international on my site.

 

navigate to the shipping file you want to use for canada only.

(for example, mine is: /public_html/includes/modules/shipping/canpost.php)

 

- back up that file to your desktop (if you break something, it'll be an easy fix)

 

- now open that file and find:

	 $check_flag == $this->enabled;
 $check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");

 

add below & make your code look like this:

if($check = tep_db_fetch_array($check_query)) {

if( $check['zone_country_id'] == 38 ) {

$check_flag = true;

} else {

$check_flag = false;

}

} else {

$check_flag = false;

}

$this->enabled = $check_flag;

 

 

 

i don't remember what the original shipping files look like, because i've used this since the beginning of my shop. so you may have to experiment a bit with this. (otherwise i'd offer step by step instructions to implement!)

 

the part i bolded is what sniffs out the country. 38 is canada on my shop

 

you can get the country id by heading to admin ->locations/taxes -> click on a country -> look at the browser address bar. cID is the country #

Link to comment
Share on other sites

Thanks for your help eww. I tried what you suggested but the code you quoted is not in the capar.php file. I do not know the first thing about php, but I would be able to paste the code you suggested but the other code is not there. I have included the php file, if you or anyone else could help me with this I would appreciate it.

 

Thank You

 

<?php

/*

canpar.php,v 0.1 2006/07/22 10:52:11 hpdl Exp $

 

ORIGINAL CANPAR SCRIPT

Copyright © 2006 J. B. Wallace ([email protected]) 2006.7.22

 

INTEGRATION WITH XML

Copyright © 2006 K. B. Gervais ([email protected]) 2006.8.25

Adaption copyright CyKron Interactive (www.cykron.com).

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class canpar {

var $code, $title, $description, $icon, $enabled;

 

// class constructor

function canpar() {

global $order;

 

$this->code = 'canpar';

$this->title = MODULE_SHIPPING_CANPAR_TEXT_TITLE;

$this->description = MODULE_SHIPPING_CANPAR_TEXT_DESCRIPTION;

$this->mark_up = MODULE_SHIPPING_CANPAR_MARK_UP;

$this->sort_order = MODULE_SHIPPING_CANPAR_SORT_ORDER;

$this->icon = DIR_WS_ICONS . 'canpar.gif';

$this->tax_class = MODULE_SHIPPING_CANPAR_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_CANPAR_STATUS == 'True') ? true : false);

 

}

 

// class methods

function quote($method = '') {

global $order, $shipping_weight,$shipping_num_boxes;

 

$srcFSA = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 3);

$desFSA = substr(strtoupper($order->delivery['postcode']), 0, 3);

 

$srcFSA1stLetter = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 1);

$desFSA1stLetter = substr(strtoupper($order->delivery['postcode']), 0, 1);

 

$PkgWT = $shipping_weight;

 

// Begin Connect Method Patch

$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);

// End Connect Method Patch

 

 

if (strlen($ErrMsg) == 0) {

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_CANPAR_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => MODULE_SHIPPING_CANPAR_TEXT_WAY,

'cost' => $ShippingCost)));

} else {

$this->quotes = array('module' => $this->title,

'error' => $ErrMsg);

}

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = '<br>' . tep_image($this->icon, $this->title);

 

return $this->quotes;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_CANPAR_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

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 ('Enable CANPAR Shipping', 'MODULE_SHIPPING_CANPAR_STATUS', 'True', 'Do you want to offer CANPAR rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Mark Up', 'MODULE_SHIPPING_CANPAR_MARK_UP', '1', 'Use the following mark-up on the shipping list fees.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_CANPAR_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_SHIPPING_CANPAR_STATUS', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', 'MODULE_SHIPPING_CANPAR_MARK_UP', 'MODULE_SHIPPING_CANPAR_SORT_ORDER');

}

}

?>

Link to comment
Share on other sites

Ok, I think I have done it. WOW I am so excited.

All I dd was add all the code you posted above, I had no idea where to put it near the top.

This is what my canpar.php looks like now

<?php

/*

canpar.php,v 0.1 2006/07/22 10:52:11 hpdl Exp $

 

ORIGINAL CANPAR SCRIPT

Copyright © 2006 J. B. Wallace ([email protected]) 2006.7.22

 

INTEGRATION WITH XML

Copyright © 2006 K. B. Gervais ([email protected]) 2006.8.25

Adaption copyright CyKron Interactive (www.cykron.com).

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class canpar {

var $code, $title, $description, $icon, $enabled;

 

// class constructor

function canpar() {

global $order;

 

$this->code = 'canpar';

$this->title = MODULE_SHIPPING_CANPAR_TEXT_TITLE;

$this->description = MODULE_SHIPPING_CANPAR_TEXT_DESCRIPTION;

$this->mark_up = MODULE_SHIPPING_CANPAR_MARK_UP;

$this->sort_order = MODULE_SHIPPING_CANPAR_SORT_ORDER;

$this->icon = DIR_WS_ICONS . 'canpar.gif';

$this->tax_class = MODULE_SHIPPING_CANPAR_TAX_CLASS;

$this->enabled = ((MODULE_SHIPPING_CANPAR_STATUS == 'True') ? true : false);

// ***ADDED CODE FROM EWW***

$check_flag == $this->enabled;

$check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id");

if($check = tep_db_fetch_array($check_query)) {

if( $check['zone_country_id'] == 38 ) {

$check_flag = true;

} else {

$check_flag = false;

}

} else {

$check_flag = false;

}

$this->enabled = $check_flag;

// ***END CODE FROM EWW***

}

// class methods

function quote($method = '') {

global $order, $shipping_weight,$shipping_num_boxes;

 

$srcFSA = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 3);

$desFSA = substr(strtoupper($order->delivery['postcode']), 0, 3);

 

$srcFSA1stLetter = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 1);

$desFSA1stLetter = substr(strtoupper($order->delivery['postcode']), 0, 1);

 

$PkgWT = $shipping_weight;

 

// Begin Connect Method Patch

$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);

// End Connect Method Patch

 

 

if (strlen($ErrMsg) == 0) {

$this->quotes = array('id' => $this->code,

'module' => MODULE_SHIPPING_CANPAR_TEXT_TITLE,

'methods' => array(array('id' => $this->code,

'title' => MODULE_SHIPPING_CANPAR_TEXT_WAY,

'cost' => $ShippingCost)));

} else {

$this->quotes = array('module' => $this->title,

'error' => $ErrMsg);

}

 

if ($this->tax_class > 0) {

$this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);

}

 

if (tep_not_null($this->icon)) $this->quotes['icon'] = '<br>' . tep_image($this->icon, $this->title);

 

return $this->quotes;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_CANPAR_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

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 ('Enable CANPAR Shipping', 'MODULE_SHIPPING_CANPAR_STATUS', 'True', 'Do you want to offer CANPAR rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Mark Up', 'MODULE_SHIPPING_CANPAR_MARK_UP', '1', 'Use the following mark-up on the shipping list fees.', '6', '0', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_CANPAR_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");

}

 

function keys() {

return array('MODULE_SHIPPING_CANPAR_STATUS', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', 'MODULE_SHIPPING_CANPAR_MARK_UP', 'MODULE_SHIPPING_CANPAR_SORT_ORDER');

}

}

?>

 

It seems to be working ok. Please take a look at the code to make sure it is correct.

 

Thank You for taking the time to help me EWW. I appreciate it.

Link to comment
Share on other sites

  • 5 months later...

Hi Larryjam - I'm also trying to use the CanPar shipping module, but am having a different problem and thought you might have some insight? I have installed it, but the problem I have is when I go to checkout, I see the CanPar shipping method as the preferred shipping method, but there is no radio button beside it to select it, and can therefore not proceed through the checkout process. Any ideas?

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...