Pagina 1 di 2

Metodo spedizione in base al peso

Inviato: 28/10/2005, 23:22
da Spiderweb
Salve!
So che c'è un sistema per abilitare/disabilitare un metodo di spedizione in base al peso totale dell'ordine... ma non so qual'è :wink:
Spedendo oggetti piccoli e leggeri, in pratica vorrei fare così:

- se un cliente acquista pochi prodotti, come metodo disponibile appare solo posta raccomandata o un altro prodotto postale usabile con le buste imbottite;
- se acquista più prodotti allora si rende disponibile anche il servizio pacchi o corriere.

So che sarebbe assurdo però son sicuro che se abilito tutti i moduli mi arriva un ordine di un pezzo da 10gr con spedizione pacco celere1 :wink:

Qualcuno sa aiutarmi... Bass?
Grazie! :)

Inviato: 29/10/2005, 22:17
da Spiderweb
Sono l'unico ad avere questo problema?? :cry: :cry: :cry:
Sono 2 sere che giro sul sito ufficiale tra le contribution ma non trovo niente... eppure esiste perchè in un post precedente è stato scritto che è possibile far scartare un metodo di spedizione se il peso totale dlel'ordine è inferiore al minimo stabilito per quel metodo.

Inviato: 29/10/2005, 22:38
da Bass
Spiderweb ha scritto:Sono l'unico ad avere questo problema?? :cry: :cry: :cry:
Sono 2 sere che giro sul sito ufficiale tra le contribution ma non trovo niente...
Secondo me il tuo e' un non problema, lascia che appaia anche il pacco celere tanto e' il cliente che sceglie e se proprio vuole spendere di piu' lo fa :)

'iao

Sergio

Re: Metodo spedizione in base al peso

Inviato: 30/10/2005, 4:49
da marcus
Spiderweb ha scritto:Salve!
So che c'è un sistema per abilitare/disabilitare un metodo di spedizione in base al peso totale dell'ordine... ma non so qual'è :wink:
Spedendo oggetti piccoli e leggeri, in pratica vorrei fare così:

- se un cliente acquista pochi prodotti, come metodo disponibile appare solo posta raccomandata o un altro prodotto postale usabile con le buste imbottite;
- se acquista più prodotti allora si rende disponibile anche il servizio pacchi o corriere.

So che sarebbe assurdo però son sicuro che se abilito tutti i moduli mi arriva un ordine di un pezzo da 10gr con spedizione pacco celere1 :wink:

Qualcuno sa aiutarmi... Bass?
Grazie! :)
E' molto semplice estendere un modulo di spedizione in modo da aggiungere la funzionalità di 'Peso minimo richiesto' per l'abilitazione del modulo.

Qui sotto, come esempio, trovi il codice del modulo 'Posta Raccomandata', in grassetto le parti aggiunte.

<?php
/*
modulo di spedizione tramite PostaRaccomandata
by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

visita osCommerceITalia, http://www.oscommerceitalia.com

derivato dal modulo:
$Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class postepostaraccomandata {
var $code, $title, $description, $enabled, $num_zones;

// class constructor
function postepostaraccomandata() {
$this->code = 'postepostaraccomandata';
$this->title = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TEXT_TITLE;
$this->description = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_STATUS == 'True') ? true : false);

// CUSTOMIZE THIS SETTING FOR THE NUMBER OF POSTEPOSTARACCOMANDATA NEEDED
$this->num_zones = 1;
}

// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes;

$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;

for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}

//Added to select default country if not in listing
if ($dest_zone == 0) {
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array("*", $country_zones)) {
$dest_zone = $i;
break;
}
}
}

if ($dest_zone == 0) {
$error = true;
$error_text = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_INVALID_ZONE;
} else {
$shipping = -1;
if ($shipping_weight >= MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_MIN_WEIGHT) {
$postepostaraccomandata_cost = constant('MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COST_' . $dest_zone);

$postepostaraccomandata_table = split("[:,]" , $postepostaraccomandata_cost);
$size = sizeof($postepostaraccomandata_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $postepostaraccomandata_table[$i]) {
$shipping = $postepostaraccomandata_table[$i+1];
$shipping_method = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TEXT_WAY;
break;
}
}
}

if ($shipping == -1) {
$shipping_cost = 0;
$error = true;
$error_text = MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_UNDEFINED_RATE;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_HANDLING_' . $dest_zone);
}
}

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TEXT_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'] = $error_text;

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_POSTEPOSTARACCOMANDATA_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 PostaRaccomandata Method', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_STATUS', 'True', 'Do you want to offer zone 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_POSTEPOSTARACCOMANDATA_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 ('Sort Order', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_SORT_ORDER', '0', 'Sort order of display.', '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 ('Min weight required', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_MIN_WEIGHT', '0', 'Disable the module if total weight is less then this value', '6', '0', now())");

for ($i = 1; $i <= $this->num_zones; $i++) {
$default_countries = '';
if ($i == 1) {
//europa (zona 1)
$default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
$shipping_table = '0.02:2.58,0.1:2.94,0.349:3.72,1:5.78,2:8.37';
}
if ($i == 2) {
//oceania (zona 3)
$default_countries = 'NZ,AU,HM,MP,FJ,PN,KI,TK,NR,VU,AS,NU,CC,PW,PF,WS,MH,TO,NC,WF,AQ,NF,CK,PG,GU,SB,FM,TV';
$shipping_table = '0.02:3.69,0.1:3.41,0.349:4.75,1:6.30,2:9.40';
}
if ($i == 3) {
//altri paesi (zona 2)
$default_countries = '*';
$shipping_table = '0.02:2.69,0.1:3.20,0.349:4.49,1:6.04,2:8.88';
}
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 ." Countries', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_STATUS', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_TAX_CLASS', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_SORT_ORDER', 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_MIN_WEIGHT');

for ($i=1; $i<=$this->num_zones; $i++) {
$keys[] = 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_POSTEPOSTARACCOMANDATA_HANDLING_' . $i;
}

return $keys;
}
}
?>

La tecnica è analoga per qualunque altro modulo di spedizione.

Marcus

Inviato: 30/10/2005, 16:55
da linda74
Ciao marcus

ho provato come hai detto, ma da qualche problema...

Allego il file incriminato :

Codice: Seleziona tutto

<?php
/*
  modulo di spedizione tramite Corriere Espresso
  by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

  visita osCommerceITalia, http://www.oscommerceitalia.com
  
  derivato dal modulo:
  $Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class corriere1 {
    var $code, $title, $description, $enabled, $num_zones;

// class constructor
    function corriere1() {
      $this->code = 'corriere1';
      $this->title = MODULE_SHIPPING_CORRIERE1_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_CORRIERE1_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_CORRIERE1_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_CORRIERE1_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_CORRIERE1_STATUS == 'True') ? true : false);

      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF CORRIERE1 NEEDED
      $this->num_zones = 3;
    }

// class methods
    function quote($method = '') {
      global $order, $shipping_weight, $shipping_num_boxes;

      $dest_country = $order->delivery['country']['iso_code_2'];
      $dest_zone = 0;
      $error = false;

      for ($i=1; $i<=$this->num_zones; $i++) {
        $countries_table = constant('MODULE_SHIPPING_CORRIERE1_COUNTRIES_' . $i);
        $country_zones = split("[,]", $countries_table);
        if (in_array($dest_country, $country_zones)) {
          $dest_zone = $i;
          break;
        }
      }

      if ($dest_zone == 0) {
        $error = true;
		$error_text = MODULE_SHIPPING_CORRIERE1_INVALID_ZONE;
      } else {
        $shipping = -1;
        $zones_cost = constant('MODULE_SHIPPING_CORRIERE1_COST_' . $dest_zone);

        $zones_table = split("[:,]" , $zones_cost);
        $size = sizeof($zones_table);
        for ($i=0; $i<$size; $i+=2) {
          if ($shipping_weight <= $zones_table[$i]) {
            $shipping = $zones_table[$i+1];
            $shipping_method = MODULE_SHIPPING_CORRIERE1_TEXT_WAY;
            break;
          }
        }

        if ($shipping == -1) {
          $shipping_cost = 0;
		  $error = true;
          $error_text = MODULE_SHIPPING_CORRIERE1_UNDEFINED_RATE;
        } else {
          $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_CORRIERE1_HANDLING_' . $dest_zone);
        }
      }

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_CORRIERE1_TEXT_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'] = $error_text;

      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_CORRIERE1_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 Zones Method', 'MODULE_SHIPPING_CORRIERE1_STATUS', 'True', 'Do you want to offer zone 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_CORRIERE1_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 ('Sort Order', 'MODULE_SHIPPING_CORRIERE1_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      for ($i = 1; $i <= $this->num_zones; $i++) {
        $default_countries = '';
		if ($i == 1) {
		  //italia
          $default_countries = 'IT';
          $shipping_table = '10:7,50:10';
        }
        if ($i == 2) {
		  //europa
		  $default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
          $shipping_table = '10:10,50:12';
        }
        if ($i == 3) {
		  //altri paesi
          $default_countries = '*';
          $shipping_table = '10:11,50:15';
        }
        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 ." Countries', 'MODULE_SHIPPING_CORRIERE1_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_CORRIERE1_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_CORRIERE1_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_CORRIERE1_STATUS', 'MODULE_SHIPPING_CORRIERE1_TAX_CLASS', 'MODULE_SHIPPING_CORRIERE1_SORT_ORDER');

      for ($i=1; $i<=$this->num_zones; $i++) {
        $keys[] = 'MODULE_SHIPPING_CORRIERE1_COUNTRIES_' . $i;
        $keys[] = 'MODULE_SHIPPING_CORRIERE1_COST_' . $i;
        $keys[] = 'MODULE_SHIPPING_CORRIERE1_HANDLING_' . $i;
      }

      return $keys;
    }
  }
?>
Dove devo modificare ?

Grazie dei consigli...

Ciao


Linda.

Inviato: 31/10/2005, 1:39
da marcus
linda74 ha scritto:Ciao marcus

ho provato come hai detto, ma da qualche problema...

.......................

Dove devo modificare ?

Grazie dei consigli...

Ciao


Linda.
Ecco il codice del modulo corriere modificato (in grassetto le parti aggiunte).

La procedura:

- disinstalla il modulo PRIMA di modificare il file
- modifica il file
- reinstalla il modulo

In configurazionedovrebbe comparire il nuovo campo 'Min weight required' dove inserire il peso minimo per abilitare il modulo corriere.
<?php
/*
modulo di spedizione tramite Corriere Espresso
by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

visita osCommerceITalia, http://www.oscommerceitalia.com

derivato dal modulo:
$Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class corriere1 {
var $code, $title, $description, $enabled, $num_zones;

// class constructor
function corriere1() {
$this->code = 'corriere1';
$this->title = MODULE_SHIPPING_CORRIERE1_TEXT_TITLE;
$this->description = MODULE_SHIPPING_CORRIERE1_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_CORRIERE1_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_CORRIERE1_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_CORRIERE1_STATUS == 'True') ? true : false);

// CUSTOMIZE THIS SETTING FOR THE NUMBER OF CORRIERE1 NEEDED
$this->num_zones = 3;
}

// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes;

$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;

for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_CORRIERE1_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}

if ($dest_zone == 0) {
$error = true;
$error_text = MODULE_SHIPPING_CORRIERE1_INVALID_ZONE;
} else {
$shipping = -1;

if ($shipping_weight >= MODULE_SHIPPING_CORRIERE1_MIN_WEIGHT) {

$zones_cost = constant('MODULE_SHIPPING_CORRIERE1_COST_' . $dest_zone);

$zones_table = split("[:,]" , $zones_cost);
$size = sizeof($zones_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $zones_table[$i]) {
$shipping = $zones_table[$i+1];
$shipping_method = MODULE_SHIPPING_CORRIERE1_TEXT_WAY;
break;
}
}

}

if ($shipping == -1) {
$shipping_cost = 0;
$error = true;
$error_text = MODULE_SHIPPING_CORRIERE1_UNDEFINED_RATE;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_CORRIERE1_HANDLING_' . $dest_zone);
}
}

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_CORRIERE1_TEXT_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'] = $error_text;

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_CORRIERE1_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 Zones Method', 'MODULE_SHIPPING_CORRIERE1_STATUS', 'True', 'Do you want to offer zone 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_CORRIERE1_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 ('Sort Order', 'MODULE_SHIPPING_CORRIERE1_SORT_ORDER', '0', 'Sort order of display.', '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 ('Min weight required', 'MODULE_SHIPPING_CORRIERE1_MIN_WEIGHT', '0', 'Disable the module if total weight is less then this value', '6', '0', now())");

for ($i = 1; $i <= $this->num_zones; $i++) {
$default_countries = '';
if ($i == 1) {
//italia
$default_countries = 'IT';
$shipping_table = '10:7,50:10';
}
if ($i == 2) {
//europa
$default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
$shipping_table = '10:10,50:12';
}
if ($i == 3) {
//altri paesi
$default_countries = '*';
$shipping_table = '10:11,50:15';
}
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 ." Countries', 'MODULE_SHIPPING_CORRIERE1_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_CORRIERE1_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_CORRIERE1_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_CORRIERE1_STATUS', 'MODULE_SHIPPING_CORRIERE1_TAX_CLASS', 'MODULE_SHIPPING_CORRIERE1_SORT_ORDER', 'MODULE_SHIPPING_CORRIERE1_MIN_WEIGHT');

for ($i=1; $i<=$this->num_zones; $i++) {
$keys[] = 'MODULE_SHIPPING_CORRIERE1_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_CORRIERE1_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_CORRIERE1_HANDLING_' . $i;
}

return $keys;
}
}
?>

Marcus

Inviato: 31/10/2005, 8:58
da valdo
Salve,
ho provato a modificare il file postepostaordinaria, sostituedo quello precedente dopo averlo disattivato prima della sostituzione, ma compare la segnalazione dell'errore alla linea 154
Allego il file con le aggiunte effettuate
<?php
/*
modulo di spedizione tramite PostaOrdinaria
by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

visita osCommerceITalia, http://www.oscommerceitalia.com

derivato dal modulo:
$Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class postepostaordinaria {
var $code, $title, $description, $enabled, $num_zones;

// class constructor
function postepostaordinaria() {
$this->code = 'postepostaordinaria';
$this->title = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_TITLE;
$this->description = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_DESCRIPTION;
$this->sort_order = MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER;
$this->icon = '';
$this->tax_class = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS == 'True') ? true : false);

// CUSTOMIZE THIS SETTING FOR THE NUMBER OF POSTEPOSTAORDINARIA NEEDED
$this->num_zones = 3;
}

// class methods
function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes;

$dest_country = $order->delivery['country']['iso_code_2'];
$dest_zone = 0;
$error = false;

for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array($dest_country, $country_zones)) {
$dest_zone = $i;
break;
}
}

//Added to select default country if not in listing
if ($dest_zone == 0) {
for ($i=1; $i<=$this->num_zones; $i++) {
$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
$country_zones = split("[,]", $countries_table);
if (in_array("*", $country_zones)) {
$dest_zone = $i;
break;
}
}
}

if ($dest_zone == 0) {
$error = true;
$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_INVALID_ZONE;
} else {
$shipping = -1;
if ($shipping_weight >= MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT) {
$postepostaordinaria_cost = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $dest_zone);

$postepostaordinaria_table = split("[:,]" , $postepostaordinaria_cost);
$size = sizeof($postepostaordinaria_table);
for ($i=0; $i<$size; $i+=2) {
if ($shipping_weight <= $postepostaordinaria_table[$i]) {
$shipping = $postepostaordinaria_table[$i+1];
$shipping_method = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_WAY;
break;
}
}

if ($shipping == -1) {
$shipping_cost = 0;
$error = true;
$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_UNDEFINED_RATE;
} else {
$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $dest_zone);
}
}

$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_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'] = $error_text;

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_POSTEPOSTAORDINARIA_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 PostaOrdinaria Method', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'True', 'Do you want to offer zone 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_POSTEPOSTAORDINARIA_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 ('Sort Order', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER', '0', 'Sort order of display.', '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 ('Min weight required', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT', '0', 'Disable the module if total weight is less then this value', '6', '0', now())");
for ($i = 1; $i <= $this->num_zones; $i++) {
$default_countries = '';
if ($i == 1) {
//europa (zona 1)
$default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
$shipping_table = '0.02:0.41,0.1:0.77,0.349:1.55,1:3.62,2:6.20';
}
if ($i == 2) {
//oceania (zona 3)
$default_countries = 'NZ,AU,HM,MP,FJ,PN,KI,TK,NR,VU,AS,NU,CC,PW,PF,WS,MH,TO,NC,WF,AQ,NF,CK,PG,GU,SB,FM,TV';
$shipping_table = '0.02:0.52,0.1:1.24,0.349:2.58,1:4.13,2:7.23';
}
if ($i == 3) {
//altri paesi (zona 2)
$default_countries = '*';
$shipping_table = '0.02:0.52,0.1:1.03,0.349:2.32,1:3.87,2:6.71';
}
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 ." Countries', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER');
'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT');
for ($i=1; $i<=$this->num_zones; $i++) {
$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i;
$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $i;
$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $i;
}

return $keys;
}
}
?>
Dove ho sbagliato?

Inviato: 31/10/2005, 10:15
da linda74
Ciao marcus

ho inserito il codice seguendo i tuoi consigli, ed inizialmente mi ha dato questo errore:

Codice: Seleziona tutto


Warning: Cannot modify header information - headers already sent by (output started at /home/eurostor/public_html/catalog/includes/modules/shipping/corriere1.php:156) in /home/eurostor/public_html/catalog/admin/includes/functions/general.php on line 18
Ma dopo aver cliccato sul tasto indietro, è andato.

Per fare la stessa cosa sul modulo PaccoCelere3 cosa devo cambiare ?

Scusa se sono invadente, ti allego il codice del file...

Codice: Seleziona tutto

<?php
/*
  modulo di spedizione tramite PaccoCelere3
  by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

  visita osCommerceITalia, http://www.oscommerceitalia.com
  
  derivato dal modulo:
  $Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class postepaccocelere3 {
    var $code, $title, $description, $enabled, $num_zones;

// class constructor
    function postepaccocelere3() {
      $this->code = 'postepaccocelere3';
      $this->title = MODULE_SHIPPING_POSTEPACCOCELERE3_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_POSTEPACCOCELERE3_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_POSTEPACCOCELERE3_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_POSTEPACCOCELERE3_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_POSTEPACCOCELERE3_STATUS == 'True') ? true : false);

      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF POSTEPACCOCELERE3 NEEDED
      $this->num_zones = 1;
    }

// class methods
    function quote($method = '') {
      global $order, $shipping_weight, $shipping_num_boxes;

      $dest_country = $order->delivery['country']['iso_code_2'];
      $dest_zone = 0;
      $error = false;

      for ($i=1; $i<=$this->num_zones; $i++) {
        $countries_table = constant('MODULE_SHIPPING_POSTEPACCOCELERE3_COUNTRIES_' . $i);
        $country_zones = split("[,]", $countries_table);
        if (in_array($dest_country, $country_zones)) {
          $dest_zone = $i;
          break;
        }
      }

	  //Added to select default country if not in listing
      if ($dest_zone == 0) {
        for ($i=1; $i<=$this->num_zones; $i++) {
          $countries_table = constant('MODULE_SHIPPING_POSTEPACCOCELERE3_COUNTRIES_' . $i);
          $country_zones = split("[,]", $countries_table);
          if (in_array("*", $country_zones)) {
            $dest_zone = $i;
            break;
          }
		}
      }

      if ($dest_zone == 0) {
        $error = true;
		$error_text = MODULE_SHIPPING_POSTEPACCOORDINARIO_INVALID_ZONE;
      } else {
        $shipping = -1;
        $postepaccocelere3_cost = constant('MODULE_SHIPPING_POSTEPACCOCELERE3_COST_' . $dest_zone);

        $postepaccocelere3_table = split("[:,]" , $postepaccocelere3_cost);
        $size = sizeof($postepaccocelere3_table);
        for ($i=0; $i<$size; $i+=2) {
          if ($shipping_weight <= $postepaccocelere3_table[$i]) {
            $shipping = $postepaccocelere3_table[$i+1];
            $shipping_method = MODULE_SHIPPING_POSTEPACCOCELERE3_TEXT_WAY;
            break;
          }
        }

        if ($shipping == -1) {
          $shipping_cost = 0;
		  $error = true;
          $error_text = MODULE_SHIPPING_POSTEPACCOCELERE3_UNDEFINED_RATE;
        } else {
          $shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POSTEPACCOCELERE3_HANDLING_' . $dest_zone);
        }
      }

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_POSTEPACCOCELERE3_TEXT_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'] = $error_text;

      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_POSTEPACCOCELERE3_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 PaccoCelere3 Method', 'MODULE_SHIPPING_POSTEPACCOCELERE3_STATUS', 'True', 'Do you want to offer zone 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_POSTEPACCOCELERE3_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 ('Sort Order', 'MODULE_SHIPPING_POSTEPACCOCELERE3_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
      for ($i = 1; $i <= $this->num_zones; $i++) {
		$default_countries = '';
		if ($i == 1) {
          $default_countries = 'IT';
          $shipping_table = '30:7';
        }
        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 ." Countries', 'MODULE_SHIPPING_POSTEPACCOCELERE3_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_POSTEPACCOCELERE3_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_POSTEPACCOCELERE3_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_POSTEPACCOCELERE3_STATUS', 'MODULE_SHIPPING_POSTEPACCOCELERE3_TAX_CLASS', 'MODULE_SHIPPING_POSTEPACCOCELERE3_SORT_ORDER');

      for ($i=1; $i<=$this->num_zones; $i++) {
        $keys[] = 'MODULE_SHIPPING_POSTEPACCOCELERE3_COUNTRIES_' . $i;
        $keys[] = 'MODULE_SHIPPING_POSTEPACCOCELERE3_COST_' . $i;
        $keys[] = 'MODULE_SHIPPING_POSTEPACCOCELERE3_HANDLING_' . $i;
      }

      return $keys;
    }
  }
?>
Grazie di tutto e Ciao.


Linda

Inviato: 01/11/2005, 4:10
da marcus
linda74 ha scritto:Ciao marcus

ho inserito il codice seguendo i tuoi consigli, ed inizialmente mi ha dato questo errore:

Codice: Seleziona tutto


Warning: Cannot modify header information - headers already sent by (output started at /home/eurostor/public_html/catalog/includes/modules/shipping/corriere1.php:156) in /home/eurostor/public_html/catalog/admin/includes/functions/general.php on line 18
Ma dopo aver cliccato sul tasto indietro, è andato.
Significa che dopo il tag di chiusura del PHP

Codice: Seleziona tutto

?>
alla fine del file è presente uno spazio o altre linee bianche, controlla altrimenti tutte le volte che disinstalli o reinstalli il modulo riceverai sempre il Warn.



linda74 ha scritto:
Per fare la stessa cosa sul modulo PaccoCelere3 cosa devo cambiare ?


Linda
Devi effettuare una modifica perfettamente analoga usando un altro nome per la chiave di configurazione ad es:

MODULE_SHIPPING_PACCOCELERE3_MIN_WEIGHT

Buon lavoro :wink:

Marcus

Inviato: 01/11/2005, 4:22
da marcus
valdo ha scritto:Salve,
ho provato a modificare il file postepostaordinaria, sostituedo quello precedente dopo averlo disattivato prima della sostituzione, ma compare la segnalazione dell'errore alla linea 154
Allego il file con le aggiunte effettuate

Qualche erroretto di sintassi :wink:

Ecco il file corretto (occhio a non inserire caratteri bianchi - spazi o linee vuote - dopo il tag di chiusura del php ?> in fondo al file):

Codice: Seleziona tutto

<?php
/*
modulo di spedizione tramite PostaOrdinaria
by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

visita osCommerceITalia, http://www.oscommerceitalia.com

derivato dal modulo:
$Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class postepostaordinaria {
	var $code, $title, $description, $enabled, $num_zones;

	// class constructor
	function postepostaordinaria() {
		$this->code = 'postepostaordinaria';
		$this->title = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_TITLE;
		$this->description = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER;
		$this->icon = '';
		$this->tax_class = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS;
		$this->enabled = ((MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS == 'True') ? true : false);

		// CUSTOMIZE THIS SETTING FOR THE NUMBER OF POSTEPOSTAORDINARIA NEEDED
		$this->num_zones = 3;
	}

	// class methods
	function quote($method = '') {
		global $order, $shipping_weight, $shipping_num_boxes;

		$dest_country = $order->delivery['country']['iso_code_2'];
		$dest_zone = 0;
		$error = false;

		for ($i=1; $i<=$this->num_zones; $i++) {
			$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
			$country_zones = split("[,]", $countries_table);
			if (in_array($dest_country, $country_zones)) {
				$dest_zone = $i;
				break;
			}
		}

		//Added to select default country if not in listing
		if ($dest_zone == 0) {
			for ($i=1; $i<=$this->num_zones; $i++) {
				$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
				$country_zones = split("[,]", $countries_table);
				if (in_array("*", $country_zones)) {
					$dest_zone = $i;
					break;
				}
			}
		}

		if ($dest_zone == 0) {
			$error = true;
			$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_INVALID_ZONE;
		} else {
			$shipping = -1;
			if ($shipping_weight >= MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT) {
				$postepostaordinaria_cost = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $dest_zone);

				$postepostaordinaria_table = split("[:,]" , $postepostaordinaria_cost);
				$size = sizeof($postepostaordinaria_table);
				for ($i=0; $i<$size; $i+=2) {
					if ($shipping_weight <= $postepostaordinaria_table[$i]) {
						$shipping = $postepostaordinaria_table[$i+1];
						$shipping_method = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_WAY;
						break;
					}
				}

				if ($shipping == -1) {
					$shipping_cost = 0;
					$error = true;
					$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_UNDEFINED_RATE;
				} else {
					$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $dest_zone);
				}
			}

			$this->quotes = array('id' => $this->code,
			'module' => MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_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'] = $error_text;

			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_POSTEPOSTAORDINARIA_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 PostaOrdinaria Method', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'True', 'Do you want to offer zone 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_POSTEPOSTAORDINARIA_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 ('Sort Order', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER', '0', 'Sort order of display.', '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 ('Min weight required', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT', '0', 'Disable the module if total weight is less then this value', '6', '0', now())");
		for ($i = 1; $i <= $this->num_zones; $i++) {
			$default_countries = '';
			if ($i == 1) {
				//europa (zona 1)
				$default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
				$shipping_table = '0.02:0.41,0.1:0.77,0.349:1.55,1:3.62,2:6.20';
			}
			if ($i == 2) {
				//oceania (zona 3)
				$default_countries = 'NZ,AU,HM,MP,FJ,PN,KI,TK,NR,VU,AS,NU,CC,PW,PF,WS,MH,TO,NC,WF,AQ,NF,CK,PG,GU,SB,FM,TV';
				$shipping_table = '0.02:0.52,0.1:1.24,0.349:2.58,1:4.13,2:7.23';
			}
			if ($i == 3) {
				//altri paesi (zona 2)
				$default_countries = '*';
				$shipping_table = '0.02:0.52,0.1:1.03,0.349:2.32,1:3.87,2:6.71';
			}
			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 ." Countries', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT');
		for ($i=1; $i<=$this->num_zones; $i++) {
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i;
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $i;
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $i;
		}

		return $keys;
	}
}
?>

Marcus

Inviato: 01/11/2005, 7:58
da valdo
Grazie Marcus,
ora il modulo postepostaordinaria che hai corretto funziona, però... compare con valore zero tra le opzioni nella scelta della spedizione anche quando non si è raggiunto il peso minimo prestabilito; in questo modo il cliente può scegliere questa opzione e rimanere bloccato nei passaggi successivi.
Cosa si può fare perchè questa opzione non compaia tra le scelte di spedizione sino al raggiungimento del peso minimo?

Inviato: 01/11/2005, 10:46
da linda74
Grazie Marcus,

penso di aver fatto un bel casino...

Non riesco più a disinstallare il modulo corriere.

In Admin compare solo più il pulsante "Installa", ed il pulsante "rimuovi" è scomparso.

Cosa devo fare ?

Grazie di tutto e Ciao.


Linda.

Inviato: 01/11/2005, 18:31
da linda74
Sono riuscita a risolvere il problema:

Ho ripristinato la tabella configuration del database e tutto è tornato a posto (modulo corriere).

Adesso proverò a modificare il modulo PaccoCelere3.

Ciao.


Linda

Inviato: 01/11/2005, 20:09
da marcus
valdo ha scritto:Grazie Marcus,
ora il modulo postepostaordinaria che hai corretto funziona, però... compare con valore zero tra le opzioni nella scelta della spedizione anche quando non si è raggiunto il peso minimo prestabilito
....
Si è dovuto ad un errore nella chiusura dell'if sul peso minimo messa nel posto sbagliato.

Ecco il file corretto:

Codice: Seleziona tutto

<?php
/*
modulo di spedizione tramite PostaOrdinaria
by hOZONE, hozone@tiscali.it, http://hozone.cjb.net

visita osCommerceITalia, http://www.oscommerceitalia.com

derivato dal modulo:
$Id: zones.php,v 1.20 2003/06/15 19:48:09 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

class postepostaordinaria {
	var $code, $title, $description, $enabled, $num_zones;

	// class constructor
	function postepostaordinaria() {
		$this->code = 'postepostaordinaria';
		$this->title = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_TITLE;
		$this->description = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER;
		$this->icon = '';
		$this->tax_class = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS;
		$this->enabled = ((MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS == 'True') ? true : false);

		// CUSTOMIZE THIS SETTING FOR THE NUMBER OF POSTEPOSTAORDINARIA NEEDED
		$this->num_zones = 3;
	}

	// class methods
	function quote($method = '') {
		global $order, $shipping_weight, $shipping_num_boxes;

		$dest_country = $order->delivery['country']['iso_code_2'];
		$dest_zone = 0;
		$error = false;

		for ($i=1; $i<=$this->num_zones; $i++) {
			$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
			$country_zones = split("[,]", $countries_table);
			if (in_array($dest_country, $country_zones)) {
				$dest_zone = $i;
				break;
			}
		}

		//Added to select default country if not in listing
		if ($dest_zone == 0) {
			for ($i=1; $i<=$this->num_zones; $i++) {
				$countries_table = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i);
				$country_zones = split("[,]", $countries_table);
				if (in_array("*", $country_zones)) {
					$dest_zone = $i;
					break;
				}
			}
		}

		if ($dest_zone == 0) {
			$error = true;
			$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_INVALID_ZONE;
		} else {
			$shipping = -1;
			if ($shipping_weight >= MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT) {
				$postepostaordinaria_cost = constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $dest_zone);

				$postepostaordinaria_table = split("[:,]" , $postepostaordinaria_cost);
				$size = sizeof($postepostaordinaria_table);
				for ($i=0; $i<$size; $i+=2) {
					if ($shipping_weight <= $postepostaordinaria_table[$i]) {
						$shipping = $postepostaordinaria_table[$i+1];
						$shipping_method = MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_WAY;
						break;
					}
				}
			}

			if ($shipping == -1) {
				$shipping_cost = 0;
				$error = true;
				$error_text = MODULE_SHIPPING_POSTEPOSTAORDINARIA_UNDEFINED_RATE;
			} else {
				$shipping_cost = ($shipping * $shipping_num_boxes) + constant('MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $dest_zone);
			}


			$this->quotes = array('id' => $this->code,
			'module' => MODULE_SHIPPING_POSTEPOSTAORDINARIA_TEXT_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'] = $error_text;

			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_POSTEPOSTAORDINARIA_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 PostaOrdinaria Method', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'True', 'Do you want to offer zone 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_POSTEPOSTAORDINARIA_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 ('Sort Order', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER', '0', 'Sort order of display.', '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 ('Min weight required', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT', '0', 'Disable the module if total weight is less then this value', '6', '0', now())");
		for ($i = 1; $i <= $this->num_zones; $i++) {
			$default_countries = '';
			if ($i == 1) {
				//europa (zona 1)
				$default_countries = 'FX,ES,GI,MC,BG,CH,HU,PL,CZ,VA,IT,AL,RU,FO,LT,AT,SI,GE,MT,BE,SJ,GR,NL,HR,UA,IS,PT,DK,YU,LV,AD,SM,FI,LU,AZ,GS,DE,MD,BA,SE,GL,NO,CY,GB,IE,RO,EE,LI,AM,SK,FR,MK,BY';
				$shipping_table = '0.02:0.41,0.1:0.77,0.349:1.55,1:3.62,2:6.20';
			}
			if ($i == 2) {
				//oceania (zona 3)
				$default_countries = 'NZ,AU,HM,MP,FJ,PN,KI,TK,NR,VU,AS,NU,CC,PW,PF,WS,MH,TO,NC,WF,AQ,NF,CK,PG,GU,SB,FM,TV';
				$shipping_table = '0.02:0.52,0.1:1.24,0.349:2.58,1:4.13,2:7.23';
			}
			if ($i == 3) {
				//altri paesi (zona 2)
				$default_countries = '*';
				$shipping_table = '0.02:0.52,0.1:1.03,0.349:2.32,1:3.87,2:6.71';
			}
			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 ." Countries', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_" . $i ."', '" . $default_countries . "', 'Comma separated list of two character ISO country codes that are part of Zone " . $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 ." Shipping Table', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_" . $i ."', '" . $shipping_table . "', 'Shipping rates to Zone " . $i . " destinations based on a group of maximum order weights. Example: 3:8.50,7:10.50,... Weights less than or equal to 3 would cost 8.50 for Zone " . $i . " destinations.', '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 ." Handling Fee', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_" . $i."', '0', '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('MODULE_SHIPPING_POSTEPOSTAORDINARIA_STATUS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_TAX_CLASS', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_SORT_ORDER', 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_MIN_WEIGHT');
		for ($i=1; $i<=$this->num_zones; $i++) {
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COUNTRIES_' . $i;
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_COST_' . $i;
			$keys[] = 'MODULE_SHIPPING_POSTEPOSTAORDINARIA_HANDLING_' . $i;
		}

		return $keys;
	}
}
?>
Marcus

Inviato: 02/11/2005, 0:12
da Spiderweb
Grazie a tutti x l'interessamento! :)
In questi giorni ero via perciò ho letto soltanto adesso i vari post e domani provo a fare le modifiche descritte.
Il fatto che sia un problema del cliente se si mette a scegliere un tipo di spedizione inadatto al prodotto e anche più costoso va bene... però per me sarebbe scomodo spedire, per esempio, un oggetto grande 3cm in una scatola 24,5cm x 17,8 x 4,5 (misura minima accettata da poste italiane per i pacchi).
A quel punto preferirei usare una busta imbottita... mi costa meno e non devo star a riempirla con materiale vario.
Grazie ancora a tutti! Ciao :)