--- ecommerce/contrib/shipcalc/shipcalc.module.orig 2005-11-23 10:30:57.000000000 -0900
+++ ecommerce/contrib/shipcalc/shipcalc.module 2006-05-16 14:37:43.000000000 -0800
@@ -1,509 +1,376 @@
weight, 5, 10, t('The weight of the product (in %unit)', array('%unit'=> (variable_get('shipcalc_units', 'LBS')) ? t('pounds') : t('kilograms'))));
- $fields = form_group(t('Shipping Info'), $group);
- return $fields;
- case 'per_product_validate':
- if (!is_numeric($edit->product_weight)) {
- form_set_error('product_weight', t('Product weight needs to be numeric only.'));
- }
- break;
- case 'per_product_insert':
- case 'per_product_update':
- shipcalc_product_save($edit);
- break;
- case 'per_product_load':
- return db_fetch_array(db_query('SELECT * FROM {ec_product_shipinfo} WHERE nid = %d', $edit->nid));
- case 'method select':
- return array('shipcalc'=>t('Shipping costs are recieved directly from carrier (UPS) during checkout.'));
- case 'form':
- return shipcalc_ship_settings();
- case 'validate':
- if ($edit['shipcalc_state'] == 1 && !$edit['shipcalc_province']) {
- form_set_error('', t('You need to enter either a state or province.'));
- }
- if (!$edit['shipcalc_postcode']) {
- form_set_error('shipcalc_postcode', t('Postal Code is required.'));
- }
- if (!is_numeric($edit['shipcalc_maxboxweight'])) {
- form_set_error('shipcalc_maxboxweight', t('Please enter a numerical value for Maximum Weight Per Box'));
- }
- break;
- case 'save':
- if ($edit['shipcalc_state'] != 1) {
- $edit['shipcalc_province'] = $edit['shipcalc_state'];
- }
- $variables = array(
- 'shipcalc_street',
- 'shipcalc_city',
- 'shipcalc_province',
- 'shipcalc_postcode',
- 'shipcalc_country',
- 'shipcalc_curency',
- 'shipcalc_units',
- 'shipcalc_maxboxweight',
- 'shipcalc_upslogin',
- 'shipcalc_upspass',
- 'shipcalc_upsxmlkey'
+ if ($may_cache) {
+ $items[] = array(
+ 'path' => 'admin/store/settings/shipcalc',
+ 'title' => t('shipcalc'),
+ 'callback' => 'shipcalc_partners_form',
+ 'access' => user_access('administer store')
);
- foreach($variables as $variable) {
- variable_set($variable, $edit[$variable]);
+
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $items[] = array(
+ 'path' => 'admin/store/settings/shipcalc/'. $partner->name,
+ 'title' => t($partner->name),
+ 'callback' => 'shipcalc_partners_form',
+ 'access' => user_access('administer store')
+ );
}
- break;
- case 'calculate':
- // this is called at the beginning of the checkout... and only includes the items...
- // we need more info, so we'll do our calculation in the checkoutapi
- // this is where we'll include and calculate the shipping info...
}
+
+ return $items;
}
+/*** ecommerce hooks ***/
+
/**
- * Settings
- * These fields get displayed on the shipping settings page when shipcalc
- * is chosen as the shipping type
- *
- */
+ * Invoke _shipping_methods hooks from shipping partner .inc files.
+ *
+ * @return
+ * An array of shipping methods.
+ */
+function shipcalc_shipping_methods() {
+ $methods = array();
-function shipcalc_ship_settings() {
- $edit = $_POST['edit'];
- $group .= form_textfield(t('Street Address'), 'shipcalc_street', $edit['shipcalc_street'] ? $edit['shipcalc_street'] : variable_get('shipcalc_street', ''), 50, 90, '', NULL, TRUE);
- $group .= form_textfield(t('City'), 'shipcalc_city', $edit['shipcalc_city'] ? $edit['shipcalc_city'] : variable_get('shipcalc_city', ''), 50, 100, '', NULL, TRUE);
- $options = address_build_states();
- // if it's not a state, then put it into the province field
- if (array_key_exists(variable_get('shipcalc_province', ''), $options)) {
- $state = variable_get('shipcalc_province', '');
- }
- else {
- $province = variable_get('shipcalc_province', '');
- $state = 1;
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $shipping_methods = $partner->name .'_shipping_methods';
+ if (function_exists($shipping_methods)) {
+ $methods = array_merge($methods, $shipping_methods($form));
+ }
}
- $group .= form_select(t('State'), 'shipcalc_state', $edit['shipcalc_state'] ? $edit['shipcalc_state'] : $state, $options, t('For addresses within the US.'));
- $group .= form_textfield(t('Province'), 'shipcalc_province', $edit['shipcalc_province'] ? $edit['shipcalc_province'] : $province, 20, 80, t('For addresses outsite U.S. Use 2 letter abbreviation if possible.'));
- $group .= form_textfield(t('Zip/Postal Code'), 'shipcalc_postcode', $edit['shipcalc_postcode'] ? $edit['shipcalc_postcode'] : variable_get('shipcalc_postcode', ''), 30, 40, '', array(), TRUE);
- $options = address_build_countries();
- $group .= form_select(t('Country'), 'shipcalc_country', $edit['shipcalc_country'] ? $edit['shipcalc_country'] : variable_get('shipcalc_country', 'us'), $options, '', 0, FALSE, TRUE);
- $fields .= form_group(t('Address of sender'), $group);
- $fields .= form_select(t('Currency Units'), 'shipcalc_currency', $edit['shipcalc_currency'] ? $edit['shipcalc_currency'] : variable_get('shipcalc_curency', 'USD'), shipcalc_currency_select(), t('This should match the price formatting set on the payment settings page.', array('%url' => url('admin/settings/payment'))));
- $fields .= form_select(t('Weight Units'), 'shipcalc_units', $edit['shipcalc_units'] ? $edit['shipcalc_units'] : variable_get('shipcalc_units', 'LBS'), array('LBS' => t('pounds'), 'KGS' => t('kilograms')));
-
- // maximum weight per box
- $fields .= form_textfield(t('Maximum Weight Per Box'), 'shipcalc_maxboxweight', $edit['shipcalc_maxboxweight'] ? $edit['shipcalc_maxboxweight'] : variable_get('shipcalc_maxboxweight', 20), 4, 8, t('This value is used to estimate the number of boxes (packages) that will need to be used to ship an order. Any idividual items that are over this weight will be assumed to be shipped in their own box. While items under this weight will be added together in the same box until this box exceeds this weight. Further items will be added to the next box.'));
-
- $fields .= form_textfield(t('International Fallback'), 'shipcalc_fallback', $edit['shipcalc_fallback'] ? $edit['shipcalc_fallback'] : variable_get('shipcalc_fallback', '5'), 10, 15, t('Occassionally shippers will not be able to return information for international addresses. If that happens, we will charge the following amount per unit (pounds, or kgs) of shipping weight'));
-
- $group = '
'.t('UPS requires that you register in order to use their web services. Be sure that your registration address matches the one above. Enter your UPS login and password below.', array('%thisurl' => url('admin/store/settings/shipping', NULL, NULL, TRUE))).'
'.t('Once you have registered with UPS, you will need to establish a UPS shipping account, a developer account, and finally an XML Access Key -- good luck!', array('%thisurl' => url('admin/store/settings/shipping', NULL, NULL, TRUE))).'
');
- // weight units
- return $fields;
+
+ return $methods;
}
-function shipcalc_product_save($node) {
- if ($node->per_product_shipping) {
- db_query('DELETE FROM {ec_product_shipinfo} WHERE nid = %d', $node->nid);
- db_query('INSERT INTO {ec_product_shipinfo} (nid, weight) VALUES (%d, %f)', $node->nid, $node->product_weight);
+/**
+ * Invoke _product_form hooks from shipping partner .inc files.
+ *
+ * This hook is called by shipping_form_alter() to allow shipping modules
+ * to add shipping-specific fields to node forms.
+ *
+ * @param &$form
+ * The form array.
+ * @param $methods
+ * The subset of this module's shipping methods that are currently assigned
+ * to the product type being edited. These are currently ignored by shipcalc.
+ */
+function shipcalc_shipping_product_form(&$form, $methods) {
+
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $get_form = $partner->name .'_product_form';
+ if (function_exists($get_form)) {
+ $get_form($form);
+ }
}
}
/**
- * Implementation of ecommerce shippingapi
- *
- */
-
+ * Use checkoutapi to actually calculate shipping costs.
+ */
function shipcalc_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) {
switch ($op) {
case 'form':
- $args = func_get_args();
- if ($txn == 'shipcalc') {
- // if we're just being 'pinged' don't do much... just say "here!"
- return TRUE;
- }
- else {
- $shippable = FALSE;
- foreach($txn->items as $item){
- if ($item->shippable){
- $shippable = TRUE;
- break;
- }
- }
- //if ($shippable) {
-
- // Need to check in with Matt
- // and find out how to increment screen
- // without displaying form
-
- //if (!$txn->shippable){
- // if it's not shippable, go to the next screen
- //$txn->screen++;
- // more here...
-
- //}
- //else {
- drupal_set_title(t('Choose Shipping Method'));
- // send off the transaction object and get back a list of options and prices
- // format the array as a table with radio buttons to select rate...
- $opsarray = shipcalc_get_options($txn);
- list($firstkey) = array_keys($opsarray);
-
- // was there an error?
- if ($firstkey == 'xx' && $opsarray[$firstkey]['total_cost'] != 0){
- $output .= t('
PLEASE NOTE: We were unable to get an accurate shipping rate for your shipping address. This amount is an estimate and may be subject to change.
');
- }
-
- // we should probably be themeing this...
- foreach((array)$opsarray as $key => $valarray) {
- // output the radio button, selected if it's the first entry...
- $rows[$key]['button'] = form_radio('', 'ship][type', $key, $key == $firstkey);
- $rows[$key]['info'] = "
-
$valarray[service_type]
-
".payment_format($valarray[total_cost])."";
- $rows[$key]['info'] .= form_hidden('ship]['.$key.'][service_type', $valarray['service_type']);
- $rows[$key]['info'] .= form_hidden('ship]['.$key.'][total_cost', $valarray['total_cost']);
- }
- $header = array('', '');
- $output .= theme('table', $header, $rows);
- $output .= form_submit(t('Continue'));
- return $output;
- //}
- }
+ if ($txn == 'shipcalc') {
+ return TRUE;
+ }
+ return shipcalc_checkout_form($txn);
case 'validate':
- if (!$txn->ship['type']) {
- form_set_error('ship][type', t('Please select a shipping method.'));
+ if (!$txn->shipping_methods) {
+ form_set_error('', t('Please select a shipping method.'));
}
break;
case 'save':
- // clean up $txn->ship
- $type = $txn->ship['type'];
- $service_type = $txn->ship[$type]['service_type'];
- $total_cost = (float)$txn->ship[$type]['total_cost'];
- unset($txn->ship);
- $txn->ship['type'] = $type;
- $txn->ship['service_type'] = $service_type;
- $txn->ship['total_cost'] = $total_cost;
-
- //go to the next screen
+ // TODO: update txn with shipping costs.
$txn->screen++;
break;
case 'review':
- // if intl_ship is turned on...
- if (variable_get('intl_ship_enable', 0)) {
- //add cost to shipping and gross values
- $txn->gross += $txn->ship['total_cost'];
- $txn->shipping_cost += $txn->ship['total_cost'];
-
- $box['subject'] = t('Shipping');
- $box['content'] = t('
Your order will be shipped via %method for %price.
PLEASE NOTE: We were unable to get an accurate shipping rate for your shipping address. This amount is an estimate and may be subject to change.
');
- }
- }
- return $box;
+ // TODO: display selected shipping option on review page.
}
}
/**
- * Implementation of hook_ec_transactionapi().
+ * Implementation of hook_nodeapi().
*/
-function shipcalc_ec_transactionapi(&$txn, $op, $a3 = NULL, $a4 = NULL) {
+function shipcalc_nodeapi(&$node, $op, $teaser) {
switch ($op) {
case 'load':
- $txn->ship = db_fetch_object(db_query("SELECT * FROM {ec_shipcalc} WHERE txnid = %d", $txn->txnid));
+ $fields = shipcalc_product_form_fields();
+ foreach ($fields as $field) {
+ $node->$field = db_result(db_query("SELECT value FROM {ec_shipcalc_product} WHERE vid = %d AND nid = %d AND field = '%s'", $node->vid, $node->nid, $field));
+ }
break;
- case 'insert':
case 'update':
- shipcalc_save($txn);
+ $fields = shipcalc_product_form_fields();
+ foreach ($fields as $field) {
+ db_query("DELETE FROM {ec_shipcalc_product} WHERE vid = %d AND nid = %d", $node->vid, $node->nid);
+ }
+ // Fall through and insert the updated node data back into the table.
+ case 'insert':
+ $fields = shipcalc_product_form_fields();
+ foreach ($fields as $field) {
+ if ($node->$field) {
+ db_query("INSERT INTO {ec_shipcalc_product} (vid, nid, field, value) VALUES (%d, %d, '%s', '%s')", $node->vid, $node->nid, $field, $node->$field);
+ }
+ }
break;
case 'delete':
- return db_query('DELETE FROM {ec_shipcalc} WHERE txnid = %d', $txn->txnid);
+ db_query("DELETE FROM {ec_shipcalc_product} WHERE nid = %d", $node->nid);
+ break;
+ case 'delete revision':
+ db_query("DELETE FROM {ec_shipcalc_product} WHERE nid = %d AND vid = %d", $node->nid, $node->vid);
+ break;
+ }
+}
+
+/*** helper functions ***/
+
+/**
+ * Return an array of fields defined by each shipping partner.
+ */
+function shipcalc_product_form_fields() {
+ static $fields = array();
+ if ($fields == array()) {
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $get_form = $partner->name .'_product_form';
+ if (function_exists($get_form)) {
+ $get_form($fields);
+ }
+ }
+ $fields = array_keys($fields['shipping_data']);
}
+ return $fields;
}
-function shipcalc_save($txn) {
- if (is_array($txn->ship)) {
- if ($txn->txnid > 0 && db_result(db_query('SELECT COUNT(txnid) FROM {ec_shipcalc} WHERE txnid = %d', $txn->txnid))) {
- db_query("UPDATE {ec_shipcalc} SET type = '%s', service_type = '%s', total_cost = %f WHERE txnid = %d", $txn->ship['type'], $txn->ship['service_type'], $txn->ship['total_cost'], $txn->txnid);
+/**
+ * Allow individual configuration of each shipping partner.
+ */
+function shipcalc_partners_form() {
+ $edit = $_POST['edit'];
+
+ $form = array();
+ $partners = _shipcalc_partners();
+
+ $form['shipcalc_partners'] = array(
+ '#type' => 'hidden',
+ '#value' => sizeof($partners)
+ );
+
+ $partner = arg(4);
+ if (isset($partner) && file_exists($partners[$partner]->filename)) {
+ $settings = $partners[$partner]->name .'_settings_form';
+ if (function_exists($settings)) {
+ $settings($form);
}
- else {
- db_query("INSERT INTO {ec_shipcalc} (txnid, type, service_type, total_cost) VALUES (%d, '%s', '%s', %f)", $txn->txnid, $txn->ship['type'], $txn->ship['service_type'], $txn->ship['total_cost']);
+
+ $form['shipping_partner'] = array(
+ '#type' => 'hidden',
+ '#value' => $partner
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save %partner settings', array('%partner' => $partner))
+ );
+
+ return drupal_get_form('shipcalc_partners_form', $form);
+ }
+ else {
+ $header = array(t('Shipping partner'), t('Operations'));
+ $rows = array();
+ foreach ($partners as $partner) {
+ $rows[] = array($partner->name, l(t('configure'), 'admin/store/settings/shipcalc/'. $partner->name));
}
+ return theme('table', $header, $rows);
+ }
+}
+
+/**
+ * Invoke _settings_form_validate in shipping partner .inc files.
+ *
+ * @param &$form
+ */
+function shipcalc_partners_form_validate(&$form) {
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $settings_form_validate = $partner->name .'_settings_form_validate';
+ if (function_exists($settings_form_validate)) {
+ $settings_form_validate($form);
+ }
+ }
+}
+
+/**
+ * Invoke _settings_form_submit in shipping partner .inc files.
+ *
+ * @param &$form
+ * Unused. We get form info from the $form_values global.
+ */
+function shipcalc_partners_form_submit(&$form) {
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $settings_form_submit = $partner->name .'_settings_form_submit';
+ if (function_exists($settings_form_submit)) {
+ $settings_form_submit($form);
+ }
+ }
+}
+
+/**
+ * These form fields are displayed at administer >> store >> shipping when
+ * "shipping costs are received directly from the shipping partner during
+ * checkout" is selected as the shipping method.
+ */
+function shipcalc_shipping_form($edit) {
+ $form = array();
+
+ if (!$edit['province']) {
+ $edit['province'] = $edit['state'];
}
+
+ $form['sender'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Address of sender'));
+ $form['sender']['shipcalc_street'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Street address'));
+ $form['sender']['shipcalc_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City'));
+ $form['sender']['shipcalc_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#default_value' => $edit['shipcalc_state'],
+ '#options' => address_build_states(),
+ '#description' => t('Specify a state if the address is within the United States.'));
+ $form['sender']['shipcalc_province'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Province / Region'),
+ '#default_value' => $edit['shipcalc_province'],
+ '#size' => 30,
+ '#maxlength' => 64);
+ $form['sender']['shipcalc_zip'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Zipcode / Postal code'),
+ '#default_value' => $edit['shipcalc_zip'],
+ '#size' => 20,
+ '#maxlength' => 20);
+ $form['sender']['shipcalc_country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#default_value' => ($edit['country'] ? $edit['country'] : variable_get('ec_country', '')),
+ '#options' => store_build_countries(),
+ '#attributes' => array('onChange' => 'provORstate(this.options[this.selectedIndex].value)'));
+
+ return $form;
}
-function shipcalc_get_options($txn) {
- require_once('ups.class.php');
+/**
+ * Build the shipcalc checkout form which lists all available shipping options.
+ */
+function shipcalc_checkout_form($txn) {
+ drupal_set_title(t('Choose shipping method'));
- // Create an opject of type ups
- $MyUPS=new ups();
+ $form = array();
+ $partners = _shipcalc_partners();
+ foreach ($partners as $partner) {
+ $rates = $partner->name .'_get_rates_form';
+ if (function_exists($rates)) {
+ $form = array_merge($form, $rates($txn));
+ }
+ }
- // set shipper info
- $MyUPS->SetShipper(variable_get('shipcalc_city', ''), strtoupper(variable_get('shipcalc_province', '')), variable_get('shipcalc_postcode', ''), strtoupper(variable_get('shipcalc_country', '')));
+ $form[] = array(
+ '#type' => 'submit',
+ '#default_value' => t('Continue')
+ );
- $MyUPS->AccessLicenseNumber = variable_get('shipcalc_upsxmlkey', '');
- $MyUPS->UserId = variable_get('shipcalc_upslogin', '');
- $MyUPS->Password = variable_get('shipcalc_upspass', '');
-
- // get ship-to address
- $address = address_get_address($txn->shipping_address);
-
- // Set the Ship To address.
- $MyUPS->SetShipTo($address->city, $address->state, $address->zip, strtoupper($address->country), 1);
-
- // get weight and box count
- $maxboxweight = variable_get('shipcalc_maxboxweight', 20);
- $units = variable_get('shipcalc_units', 20);
- $currency = variable_get('shipcalc_curency', 'USD');
-
- $x = 0;
- $boxweight = 0;
- $totalweight = 0;
- foreach((array)$txn->items as $item) {
- if (product_is_shippable($item->nid)) {
- // deal with multiple quantities of the same item
- for ($i = 0; $i < $item->qty; $i++) {
- // should we start a new box?
- if ($boxweight != 0 && (($boxweight + $item->weight) > $maxboxweight)) {
- // add it as a package
- $pkg = $MyUPS->AddPackage('00','Package '.++$x, $boxweight, $boxvalue, $units, $currency);
- // start a new box
- $boxweight = 0;
- $boxvalue = 0;
+ return $form;
+}
+
+/**
+ * Returns an array of shipcalc partners.
+ */
+function _shipcalc_partners() {
+ // Locate the subdirectory holding partner include files.
+ $partner_dir = _find_dir('modules', '^partners$');
+ // Locate all partner include files.
+ $files = file_scan_directory("$partner_dir", '\.inc$');
+
+ $partners = array();
+ foreach ($files as $partner) {
+ include_once($partner->filename);
+ $partners[$partner->name] = $partner;
+ }
+
+ return $partners;
+}
+
+/**
+ * Minimal replacement for file_scan_directory() to find first matching
+ * directory.
+ */
+function _find_dir($parent, $mask, $nomask = array('.', '..', 'CVS')) {
+ if (is_dir($parent) && $handle = opendir($parent)) {
+ while ($file = readdir($handle)) {
+ if (!in_array($file, $nomask)) {
+ if (is_dir("$parent/$file")) {
+ if (ereg($mask, $file)) {
+ return "$parent/$file";
+ }
+ else {
+ if ($match = _find_dir("$parent/$file", $mask, $nomask)) {
+ return $match;
+ }
+ }
}
- $boxweight += $item->weight;
- $totalweight += $item->weight;
- $boxvalue += $item->price;
}
}
}
- // sweep up any remaining items...
- $pkg = $MyUPS->AddPackage('00','Package '.++$x, $boxweight, $boxvalue, $units, $currency);
-
- // okay, let's do it!
- $options = $MyUPS->ModeRateShopArray();
+}
- //if there was a problem, use fallback
- if (!is_array($options)) {
- $options = array('xx' => array('service' => 'xx', 'service_type' => t('Undefined Shipping'), 'total_cost' => $totalweight * variable_get('shipcalc_fallback', 5)));
- }
-
- // Lost and confused?
- // Uncomment this next line:
- // $MyUPS->Debug();
- return $options;
-}
-
-function shipcalc_currency_select() {
-// ISO 4217 currency codes gleened from http://en.wikipedia.org/wiki/ISO_4217
- return array(
- "AED" => "AED United Arab Emirates dirham",
- "AFN" => "AFN Afghan afghani",
- "ALL" => "ALL Albanian lek",
- "AMD" => "AMD Armenian dram",
- "ANG" => "ANG Netherlands Antillian guilder",
- "AOA" => "AOA Angolan kwanza",
- "ARS" => "ARS Argentine peso",
- "AUD" => "AUD Australian dollar",
- "AWG" => "AWG Aruban guilder",
- "AZM" => "AZM Azerbaijani manat",
- "BAM" => "BAM Bosnia-Herzegovina convertible mark",
- "BBD" => "BBD Barbadian dollar",
- "BDT" => "BDT Bangladeshi taka",
- "BGN" => "BGN Bulgarian lev (since 1999-07-05)",
- "BHD" => "BHD Bahraini dinar",
- "BIF" => "BIF Burundi franc",
- "BMD" => "BMD Bermuda dollar",
- "BND" => "BND Brunei dollar",
- "BOB" => "BOB Bolivian boliviano",
- "BOV" => "BOV Bolivian Mvdol (Funds code)",
- "BRL" => "BRL Brazilian real",
- "BSD" => "BSD Bahamian dollar",
- "BTN" => "BTN Bhutan ngultrum",
- "BWP" => "BWP Botswana pula",
- "BYR" => "BYR Belarusian ruble",
- "BZD" => "BZD Belize dollar",
- "CAD" => "CAD Canadian dollar",
- "CDF" => "CDF Congolese franc",
- "CHF" => "CHF Swiss franc",
- "CLP" => "CLP Chilean peso",
- "CNY" => "CNY Yuan renminbi (PR China)",
- "COP" => "COP Colombian peso",
- "COU" => "COU Colombian unidad de valor real",
- "CRC" => "CRC Costa Rican col—n",
- "CSD" => "CSD Serbian dinar",
- "CUC" => "CUC Cuban convertible peso",
- "CUP" => "CUP Cuban peso",
- "CVE" => "CVE Cape Verde escudo",
- "CYP" => "CYP Cyprus pound",
- "CZK" => "CZK Czech koruna",
- "DJF" => "DJF Djibouti franc",
- "DKK" => "DKK Danish krone",
- "DOP" => "DOP Dominican peso",
- "DZD" => "DZD Algerian dinar",
- "EEK" => "EEK Estonian kroon",
- "EGP" => "EGP Egyptian pound",
- "ERN" => "ERN Eritrea nakfa",
- "ETB" => "ETB Ethiopian birr",
- "EUR" => "EUR European Union euro",
- "FJD" => "FJD Fijian dollar",
- "FKP" => "FKP Falkland Islands pound",
- "GBP" => "GBP Great British Pound",
- "GEL" => "GEL Georgian lari",
- "GHC" => "GHC Ghana cedi",
- "GIP" => "GIP Gibraltar pound",
- "GMD" => "GMD Gambian dalasi",
- "GNF" => "GNF Guinea franc",
- "GTQ" => "GTQ Guatemalan quetzal",
- "GYD" => "GYD Guyanese dollar",
- "HKD" => "HKD Hong Kong dollar",
- "HNL" => "HNL Honduran lempira",
- "HRK" => "HRK Croatian kuna",
- "HTG" => "HTG Haitian gourde",
- "HUF" => "HUF Hungarian forint",
- "IDR" => "IDR Indonesian rupiah",
- "ILS" => "ILS New Israeli shekel",
- "INR" => "INR Indian rupee",
- "IQD" => "IQD Iraqi dinar",
- "IRR" => "IRR Iranian Rial",
- "ISK" => "ISK Icelandic kr—na",
- "JMD" => "JMD Jamaican dollar",
- "JOD" => "JOD Jordanian dinar",
- "JPY" => "JPY Japanese yen",
- "KES" => "KES Kenyan shilling",
- "KGS" => "KGS Kyrgyzstan som",
- "KHR" => "KHR Cambodian riel",
- "KMF" => "KMF Comorian franc",
- "KPW" => "KPW North Korean won",
- "KRW" => "KRW South Korean won",
- "KWD" => "KWD Kuwaiti dinar",
- "KYD" => "KYD Cayman Islands dollar",
- "KZT" => "KZT Kazakhstan tenge",
- "LAK" => "LAK Lao kip",
- "LBP" => "LBP Lebanese pound",
- "LKR" => "LKR Sri Lankan rupee",
- "LRD" => "LRD Liberian dollar",
- "LSL" => "LSL Lesotho loti",
- "LTL" => "LTL Lithuanian litas",
- "LVL" => "LVL Latvian lat",
- "LYD" => "LYD Libyan dinar",
- "MAD" => "MAD Moroccan dirham",
- "MDL" => "MDL Moldovan leu",
- "MGA" => "MGA Malagasy ariary",
- "MKD" => "MKD Macedonian denar",
- "MMK" => "MMK Myanmar kyat",
- "MNT" => "MNT Mongolian tugrik",
- "MOP" => "MOP Macau pataca",
- "MRO" => "MRO Mauritanian ouguiya",
- "MTL" => "MTL Maltese lira",
- "MUR" => "MUR Mauritius rupee",
- "MVR" => "MVR Maldives rufiyaa",
- "MWK" => "MWK Malawi kwacha",
- "MXN" => "MXN Mexican peso",
- "MYR" => "MYR Malaysian ringgit",
- "MZM" => "MZM Mozambique metical",
- "NAD" => "NAD Namibian dollar",
- "NGN" => "NGN Nigerian naira",
- "NIO" => "NIO Nicaraguan c—rdoba",
- "NOK" => "NOK Norwegian krone",
- "NPR" => "NPR Nepalese rupee",
- "NZD" => "NZD New Zealand dollar",
- "OMR" => "OMR Omani rial",
- "PAB" => "PAB Panamanian balboa",
- "PEN" => "PEN Peruvian nuevo sol",
- "PGK" => "PGK Papua New Guinea kina",
- "PHP" => "PHP Philippine peso",
- "PKR" => "PKR Pakistani rupee",
- "PLN" => "PLN Polish zoty",
- "PYG" => "PYG Paraguayan guaran’",
- "QAR" => "QAR Qatari rial",
- "RON" => "RON Romanian leu",
- "RUB" => "RUB Russian ruble",
- "RWF" => "RWF Rwandan franc",
- "SAR" => "SAR Saudi Arabian riyal",
- "SBD" => "SBD Solomon Islands dollar",
- "SCR" => "SCR Seychelles rupee",
- "SDD" => "SDD Sudanese dinar",
- "SEK" => "SEK Swedish krona",
- "SGD" => "SGD Singapore dollar",
- "SHP" => "SHP Saint Helena pound",
- "SIT" => "SIT Slovene tolar",
- "SKK" => "SKK Slovak koruna",
- "SLL" => "SLL Sierra Leonean leone",
- "SOS" => "SOS Somali shilling",
- "SRD" => "SRD Suriname dollar",
- "STD" => "STD S‹o TomŽ and Pr’ncipe dobra",
- "SYP" => "SYP Syrian pound",
- "SZL" => "SZL Swaziland lilangeni",
- "THB" => "THB Thai baht",
- "TJS" => "TJS Tajikistani somoni",
- "TMM" => "TMM Turkmen manat",
- "TND" => "TND Tunisian dinar",
- "TOP" => "TOP Tongan Pa'anga",
- "TRY" => "TRY New Turkish lira",
- "TTD" => "TTD Trinidad and Tobago dollar",
- "TWD" => "TWD New Taiwan dollar",
- "TZS" => "TZS Tanzanian shilling",
- "UAH" => "UAH Ukrainian hryvnia",
- "UGX" => "UGX Ugandan shilling",
- "USD" => "USD United States dollar",
- "UYU" => "UYU Uruguayan peso",
- "UZS" => "UZS Uzbekistani som",
- "VEB" => "VEB Venezuelan bol’var",
- "VND" => "VND Viet Nam dong",
- "VUV" => "VUV Vanuatu vatu",
- "WST" => "WST Samoa Tala",
- "XAF" => "XAF CFA franc BEAC",
- "XAG" => "XAG Silver ounce",
- "XAU" => "XAU Gold ounce",
- "XCD" => "XCD East Caribbean dollar",
- "XOF" => "XOF CFA franc BCEAO",
- "XPD" => "XPD Palladium ounce",
- "XPF" => "XPF CFP franc",
- "XPT" => "XPT Platinum ounce",
- "XXX" => "XXX No currency",
- "YER" => "YER Yemeni rial",
- "ZAR" => "ZAR South African rand",
- "ZMK" => "ZMK Zambian kwacha",
- "ZWD" => "ZWD Zimbabwe dollar");
+/**
+ * A simple xml parsing function.
+ *
+ * @param $xml A text string that contains the xml to be parsed.
+ * @param $open_tag The opening xml tag to search for.
+ * @return string The string between $open_tag and its close tag.
+ */
+function _parse_xml($xml, $open_tag) {
+ $close_tag = ''. substr($open_tag, 1, strlen($open_tag));
+ $pos1 = strpos($xml, $open_tag);
+ $pos2 = strpos($xml, $close_tag);
+ return substr($xml, $pos1 + strlen($open_tag), $pos2 - ($pos1 + strlen($open_tag)));
}
-?>
\ No newline at end of file
+?>
--- ecommerce/contrib/shipcalc/shipcalc.mysql.orig 2005-11-15 02:14:34.000000000 -0900
+++ ecommerce/contrib/shipcalc/shipcalc.mysql 2006-05-16 14:38:15.000000000 -0800
@@ -1,26 +1,14 @@
--- --------------------------------------------------------
--
--- Table structure for table `ec_shipcalc`
+-- Table structure for table `ec_shipcalc_product`
--
-CREATE TABLE ec_shipcalc (
- txnid int(10) unsigned NOT NULL default '0',
- `type` varchar(10) NOT NULL default '0',
- service_type varchar(128) NOT NULL default '',
- total_cost decimal(10,2) unsigned NOT NULL default '0.00',
- PRIMARY KEY (txnid)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
---
--- Table structure for table `ec_product_shipinfo`
---
-
-CREATE TABLE ec_product_shipinfo (
- nid int(10) NOT NULL default '0',
- weight float NOT NULL default '0',
- width float NOT NULL default '0',
- height float NOT NULL default '0',
- depth float NOT NULL default '0',
+CREATE TABLE ec_shipcalc_product (
+ vid int(10) UNSIGNED NOT NULL DEFAULT '0',
+ nid int(10) UNSIGNED NOT NULL DEFAULT '0',
+ field varchar(255) NOT NULL DEFAULT '',
+ value varchar(255) NOT NULL DEFAULT '',
+ UNIQUE KEY field (field),
+ KEY vid (vid),
KEY nid (nid)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
\ No newline at end of file
+) TYPE=MyISAM;
--- ecommerce/contrib/shipcalc/ups.class.php.orig 2005-11-06 07:44:04.000000000 -0900
+++ ecommerce/contrib/shipcalc/ups.class.php 1969-12-31 14:00:00.000000000 -1000
@@ -1,1180 +0,0 @@
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Modified by Jeff Robbins for Drupal ecommerce package...
-// robbins /at\ jjeff /d0t\ com
-//
-// AaronUPS Version 0.1: (PHP/cURL-XML)
-// aaronups@shadowguarddev.com
-//
-// UPS Rate and Rate Shopping Script.
-//
-// This code is released without any warranty, even the implied warranty of
-// fitness for a particular purpose. So, USE AT YOUR OWN RISK.
-//
-// To use it, you MUST compile PHP with cURL (http://curl.haxx.se) support,
-// and cURL must be compiled with SSL support.
-//
-// I will try to answer any questions you have when using it, addressed to
-// aaronups@shadowguarddev.com.
-//
-//
-// To use these tools, you have to register at UPS. When I did it, it was here:
-//
-// https://www.ups.com/servlet/registration?loc=en_US_EC&returnto=http://www.ec.ups.com/ecommerce/gettools/gtools_intro.html
-//
-// If this doesn't seem to work, just go to UPS.com and start looking for online tools,
-// and how to register for your developers key and get an XML key, etc..
-//
-//
-// Based on the SurePay script by rachael@kreisler.org, version .07
-// Find it at http://www.kreisler.org/surepay/index.php
-//
-////////////////////////////////////////////////////////////////////////////////
-
-###########################################################################################
-## Sample Code (simple) using this script
-###########################################################################################
-#
-# This script should be pretty self explainitory
-#
-/*
-
- // include the UPS Script.
- require_once('aaronups.php');
-
-
- // Create an opject of type ups
- $MyUPS=new ups();
-
- // set shipper info
- $MyUPS->SetShipper('Springfield','MO','65807','US');
-
- // uncomment this if you ship from somewhere other than the address you
- // registered your key to.
- //$MyUPS->SetShipFrom('Springfield','MO','65807','US');
-
- // Set the Ship To address. This will probably be gleaned from the user
- $MyUPS->SetShipTo('Cassville','MO','65625','US',1);
-
- // Add a package. Note that I saved the package number for use in the following functions
- $pkg=$MyUPS->AddPackage('02','First Package',33);
- $MyUPS->SetPackageValue($pkg,87.53); // Adding an insured value
- $MyUPS->SetPackageSize($pkg,108,2,2); // Adding a size to the box
-
- // adding another package (with an insured value)
- $pkg=$MyUPS->AddPackage('02','Second Package',113,25.50);
-
- // Get the list of rates for my current settings.
- $selopt=$MyUPS->ModeRateShop();
-
- // I debuged here to see that everything was happy =)
-// $MyUPS->Debug();
-
-
- // her I'm getting the cost of service '03' (ground). usually this would be on the next page
- // after the user selected something from the options of ModeRateShop
- $MyRate=$MyUPS->ModeGetRate('03');
-
-
-// used my values I got back.
-echo <<<__FOO__
-
-
-
-
-
-Cost is $MyRate.
-__FOO__;
-
-?>
-*/
-#
-#
-###########################################################################################
-
-#######################################################################################################################
-## Function List
-#######################################################################################################################
-#
-# Constructors - Look here for some default arrays, also, if UPS adds new service options you need to change one of them
-# ups()
-#
-# These functions probably won't be used by most people. You will want to set the variables staticly for most cases
-# SetPostURL($url)
-# SetAccountInfo($ALN,$UID,$Pass)
-# SetPickupType($Code)
-# SetCustomerContext($context)
-# SetShipper($city,$state,$zip,$country)
-# SetShipFrom($city,$state,$zip,$country)
-#
-# Set the ship to address (isres is to set wether or not you are shipping to a residential area)
-# SetShipTo($city,$state,$zip,$country,$isres=0)
-#
-# Modes of operation
-# ModeRateShop() // use to get a list of rates for services. Returns 0 on fail, or the same as GetRateListShort()
-# ModeGetRate($ServiceCode) // returns the price for the selected rate. Usually you want to use the above function to find the method
-#
-# Rate List Functions
-# GetRateListShort() // returns a list of
-__RETVAL__;
- }
- }
- else
- {
- $retval=0;
- }
-
- return $retval;
- }
-
-
- function GetRateListArray()
- {
- // turn the details into