Oggi è gio apr 18, 2024 11:54 pm

Benvenuto!

Lo stato dell'Arte come software Open Source gratuito E-commerce.
 

Zen Cart Italia

Design - Personalizzazione

Modulo Shipping "Region Tables"

Supporto concernente queste attività

Moderatori: Sandro Carniel aka webmaster, Paolo De Dionigi aka Spike00

Modulo Shipping "Region Tables"

Messaggioda gsessa » ven mag 18, 2007 8:30 am

Nella ricerca di un modulo di spedizione che mi consentisse di definire accuratamente le zone e ralativi modi di spedizione, mi sono imbattuto in questo modulo recentemente rilasciato.
Ecco il link alla discussione su www.zen-cart.com (http://www.zen-cart.com/forum/showthread.php?t=61929&highlight=regiontables)

Il modulo funziona molto bene e lavora sui PostalCodes (ovvero i CAP) anche se mi sarebbe piaciuto di più se avesse utilizzato le province, ma, forse, in questo caso non si sarebbe potuto utilizzare in tutto il mondo.

L'autore, come leggerete nella discussione, dichiara che il modulo funziona correttamente solo per Francia, Inghilterra, Spagna e Stati Uniti.

In realtà è molto facile personalizzarlo anche per l'Italia o per altre zone di vostro interesse.

Per fare ciò dovere modificare il file ../includes/modules/shipping/[b]regiontables.php[/b]
inserendo dopo riga 718 questo codice:
[quote]
// {{{ _regionMatchesRangeIT()

/**
* Check Italian postcode
*
* @param string $dest_postcode The postcode to be checked (Whitespace should already have
* been stripped).
* @param string $postcode_range A postcode or range of postcodes to check against.
* @return boolean|integer The boolean status of whether or not the postcode was
* matched or -1 if an error occurred (Customer's postcode is
* in incorrect format to be tested by this method).
*/
function _regionMatchesRange[b]IT[/b]($dest_postcode, $postcode_range)
{
// Check the postcode is in the correct format
// Spanish postcodes must be 5 digits in length
if (!ereg('^[0-9][0-9][0-9][0-9][0-9]', $dest_postcode)) {
// Postcode is not in the correct format
return -1;
}

// Has a range of postcodes been specified?
if (strpos($postcode_range, '-') !== false) {
// Check against the range of postcodes specified
// Format xxxxx-xxxxx where x = 0-9, with first two digits being significant
if (ereg('^([[:digit:]]+)[\-]([[:digit:]]+)', $postcode_range, $postcode_range_array)) {
$start_range = $postcode_range_array[1];
$end_range = $postcode_range_array[2];

if (substr($dest_postcode, 0, strlen($start_range)) >= $start_range
&& substr($dest_postcode, 0, strlen($end_range)) <= $end_range) {
// Postcode matches one of the codes covered by this range!
return true;
}
} else {
$this->quotes['error'] = sprintf(MODULE_REGION_TABLES_ERROR_POSTCODE_PARSE, $postcode_range);
}
} else {
// Check against a single postcode
if (substr($dest_postcode, 0, strlen($postcode_range)) == $postcode_range) {
// Have matched the postcode
return true;
}
}

return false;
}

// }}}
[/quote]

che altro non è che la funzione scritta per la Spagna che ha il nostro identico sistema. L'unica cosa che ho dovuto cambiare è il nome della funzione, come evidenziato in grassetto nel codice riportato.

Altre piccole personalizzazioni sono necessarie per descrivere il tipo di spedizione, ma nel file di lingua.

Le spiegazioni dell'autore son ben fatte anche se in Inglese.
Unico fastidioso problema, ma credo facilmente risolvibile ed appena ci riesco vi dirò, è che se il CAP è vuoto, non calcola assolutamente nulla.

Teniamo aperta questa discussione per seguire l'evolversi del modulo.

Ciao,
giorgio
gsessa
 
Messaggi: 16
Iscritto il: lun apr 30, 2007 4:58 pm

Torna a Design - Personalizzazione

cron

Login

Real Time Analytics