I made a variation of the Zone Shipping module. It has a price for different group of states.
The modules quotes the according price just fine. But when the module is selected in the checkout_shipping.php page, instead of going to checkout_payment, you get back to checkout_shipping with the module pre-selected but no error message at all. So whatever I try, if this module is selected, you can't get past the shipping page and no error is shown anywhere (nor print in the page, nor log, nothing).
If you select any other module, you get to the payment step just fine.
I have no idea on how to solve this or where to look for errors. If the price is calculated right, why oscommerce doesn't take it and go to the next step?
Any ideas of what may be happening or at least where I can start trying to debug?
Thanks a lot
Latest News: (loading..)
Zone doesn't work but no error
Started by JuanIgnacio, Jul 06 2011, 15:07
1 reply to this topic
#1
Posted 06 July 2011, 15:07
#2
Posted 06 July 2011, 17:31
Update. Here's the module:
<?php
/*
$Id: Interstate.php
Hecho por Formato DiseƱo
For Use with:
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Released under the GNU General Public License
*/
class oca_express {
var $code, $title, $description, $enabled, $num_zones;
// class constructor
function oca_express() {
$this->code = 'oca_express';
$this->title = OCA_EXPRESS_TEXT_TITLE;
$this->description = OCA_EXPRESS_TEXT_DESCRIPTION;
$this->sort_order = OCA_EXPRESS_SORT_ORDER;
$this->icon = '';
$this->tax_class = OCA_EXPRESS_TAX_CLASS;
$this->enabled = ((OCA_EXPRESS_STATUS == 'True') ? true : false);
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
$this->num_zones = 2;
}
// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes;
// if delivery is to other country, skip module in cart
// if ($order->delivery['country']['iso_code_2'] != 'AR ') return;
//$dest_state = $order->delivery['estado'];
$dest_iz = tep_db_fetch_array(tep_db_query("select zone_code from zones where zone_id = '" . (int)$order->delivery['zone_id'] . "'"));
$dest_state = $dest_iz['zone_code'];
$dest_nam = tep_db_fetch_array(tep_db_query("select zone_name from zones where zone_id = '" . (int)$order->delivery['zone_id'] . "'"));
$dest_nombre = $dest_nam['zone_name'];
$dest_zone = 0;
$error = false;
for ($i=1; $i<=$this->num_zones; $i++) {
$state_table = constant('OCA_EXPRESS_STATES_' . $i);
$state_zones = split("[ ,]", $state_table);
if (in_array($dest_state, $state_zones)) {
$dest_zone = $i;
break;
}
}
if ($dest_zone == 0) {
$error = true;
} else {
$shipping = -1;
$OCA_EXPRESS_cost = constant('OCA_EXPRESS_COST_' . $dest_zone);
$OCA_EXPRESS_table = split("[:,]" , $OCA_EXPRESS_cost);
$size = sizeof($OCA_EXPRESS_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $OCA_EXPRESS_table[$i]) {
$shipping = $OCA_EXPRESS_table[$i+1];
$shipping_method = OCA_EXPRESS_TEXT_WAY . ' a '. $dest_nombre;
break;
}
}
if ($shipping == -1) {
$shipping_cost = 0;
$shipping_method = OCA_EXPRESS_UNDEFINED_RATE;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes);
}
}
$this->quotes = array('id' => $this->code,
'module' => OCA_EXPRESS_TEXT_SECTION_TITLE,
'methods' => array(array('id' => $this->code,
'title' => $shipping_method,
'cost' => $shipping_cost)));
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'] =
tep_image($this->icon, $this->title);
if ($error == true) $this->quotes['error'] = OCA_EXPRESS_INVALID_ZONE;
return $this->quotes;
}
function check() {
if (!isset($this->_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'OCA_EXPRESS_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 ( 'Habilitar Correo Argentino?', 'OCA_EXPRESS_STATUS', 'True', 'Habilitar Correo Argentino?', '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 ( 'Impuesto', 'OCA_EXPRESS_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 ( 'Orden de aparición', 'OCA_EXPRESS_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
for ($i = 1; $i <= $this->num_zones; $i++) {
$default_states = '';
$default_rates = '';
if ($i == 1) {
$default_states = 'CF, BA, ZC, ZR, ZP'; // Capital - Regional
$default_rates = '1:29, 5:35';
}
if ($i == 2) {
$default_states = 'SF, CB, ER, LP, CO, CA, CC, CH, FO, JU, LR, MZ, MI, NE, RN, SA, SJ, SL, SC, SE, TU, TF '; // Nacional
$default_rates = '1:41, 5:53';
}
if ($i == 3) { // Otros
$default_states = '';
$default_rates = '';
}
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Zona " . $i ." - Provincias', 'OCA_EXPRESS_STATES_" . $i ."', '" . $default_states . "', 'Lista de codigos ISO de las provincias en la zona separados por comas', '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 ('Zone " . $i ." - Rango de precios', 'OCA_EXPRESS_COST_" . $i ."', '" . $default_rates . "', 'Precios para la Zona " . $i . " en formato rangos. Ejemplo: 3:8.50,7:10.50, (...) Con peso menos o igual a 3 cuesta 8.50 para desinos en la Zona " . $i . ".', '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 ('Zone " . $i ." - Recargo fijo', 'OCA_EXPRESS_HANDLING_" . $i."', '0.00', 'Handling Fee for this shipping zone', '6', '0', now())");
}
}
function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
$keys = array('OCA_EXPRESS_STATUS', 'OCA_EXPRESS_TAX_CLASS', 'OCA_EXPRESS_SORT_ORDER');
for ($i=1; $i<=$this->num_zones; $i++) {
$keys[] = 'OCA_EXPRESS_STATES_' . $i;
$keys[] = 'OCA_EXPRESS_COST_' . $i;
$keys[] = 'OCA_EXPRESS_HANDLING_' . $i;
}
return $keys;
}
}
?>














