Pagina 1 di 2

Quesito per ordini superiori a € 100

Inviato: 24/06/2008, 16:23
da dr_ock
Ciao a tutti, vorrei mettere sul mio Oscommerce un periodo di promozione sulle spese di spedizione.. ovvero che se un utente supera i € 100 le spese di spedizione sono GRATUITE.
Soltanto c'è un piccolo problemino...

Come faccio a far pagare il contrassegno? Ovvero se un utente supera i 100 € come faccio a caricargli sull'importo totale il contributo aggiuntivo di € 7.00 per il contrassegno?
Nonostante abbia superato i 100 €?
Spero di essermi spiegato.
Ciao a tutti e buon lavoro.

Ruggero

Re: Quesito per ordini superiori a € 100

Inviato: 24/06/2008, 19:50
da marcus
dr_ock ha scritto:Ciao a tutti, vorrei mettere sul mio Oscommerce un periodo di promozione sulle spese di spedizione.. ovvero che se un utente supera i € 100 le spese di spedizione sono GRATUITE.
Soltanto c'è un piccolo problemino...

Come faccio a far pagare il contrassegno? Ovvero se un utente supera i 100 € come faccio a caricargli sull'importo totale il contributo aggiuntivo di € 7.00 per il contrassegno?
Nonostante abbia superato i 100 €?
Spero di essermi spiegato.
Ciao a tutti e buon lavoro.

Ruggero
Ciao Ruggero,

devi modificare il modulo ot_cod_fee.php aggiungendo una chiave per la spedizione gratuita.

Se non sai come fare posta tutto il file qui.

Saluti
Marcus

Inviato: 24/06/2008, 22:10
da dr_ock
Ad essere sincero non saprei dove mettere le mani...
Qui di seguito ti posto il codice :

Codice: Seleziona tutto

<?php
/*
  $Id: ot_cod_fee.php,v 1.00 2002/11/30 17:02:00 harley_vb Exp $

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

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/
/********************************************************************
*	Copyright (C) 2002 TheMedia, Dipl.-Ing Thomas Pl"nkers. 
*       http://www.themedia.at & http://www.oscommerce.at
*
*                    All rights reserved. 
*
* This program is free software licensed under the GNU General Public License (GPL).
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*    USA
*
*********************************************************************/

  class ot_cod_fee {
    var $title, $output;

    function ot_cod_fee() {
      $this->code = 'ot_cod_fee';
      $this->title = MODULE_ORDER_TOTAL_COD_TITLE;
      $this->description = MODULE_ORDER_TOTAL_COD_DESCRIPTION;
      $this->enabled = ((MODULE_ORDER_TOTAL_COD_STATUS == 'true') ? true : false);
      $this->sort_order = MODULE_ORDER_TOTAL_COD_SORT_ORDER;

      $this->output = array();
    }

    function process() {
      global $order, $currencies, $cod_cost, $cod_country, $shipping;

      if (MODULE_ORDER_TOTAL_COD_STATUS == 'true') {
        $tax = tep_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS);

        //Will become true, if cod can be processed.
        $cod_country = false;

        //check if payment method is cod. If yes, check if cod is possible.
        if ($GLOBALS['payment'] == 'cod') {
          //process installed shipping modules
          if (substr_count($shipping['id'], 'flat') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
          if (substr_count($shipping['id'], 'item') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
          if (substr_count($shipping['id'], 'table') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
          if (substr_count($shipping['id'], 'ups') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_UPS);
          if (substr_count($shipping['id'], 'usps') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_USPS);
          if (substr_count($shipping['id'], 'fedex') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FEDEX);
          if (substr_count($shipping['id'], 'zones') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
          if (substr_count($shipping['id'], 'ap') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_AP);
          if (substr_count($shipping['id'], 'dp') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_DP);
          if (substr_count($shipping['id'], 'corriere1') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1);
          if (substr_count($shipping['id'], 'postepaccocelere1') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1);
          if (substr_count($shipping['id'], 'postepaccocelere3') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3);
          if (substr_count($shipping['id'], 'postepaccoordinario') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO);
          if (substr_count($shipping['id'], 'postepostaordinaria') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA);
          if (substr_count($shipping['id'], 'postepostaprioritaria') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA);
          if (substr_count($shipping['id'], 'postepostaraccomandata') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA);
	  //satt inn av Pompel
	  if (substr_count($shipping['id'], 'servicepakke') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE);
	  
            for ($i = 0; $i < count($cod_zones); $i++) {
              if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                  $cod_cost = $cod_zones[$i + 1];
                  $cod_country = true;
                  //print('match' . $i . ': ' . $cod_cost);
                  break;
                } elseif ($cod_zones[$i] == '00') {
                  $cod_cost = $cod_zones[$i + 1];
                  $cod_country = true;
                  //print('match' . $i . ': ' . $cod_cost);
                  break;
                } else {
                  //print('no match');
                }
              $i++;
            }
          } else {
            //COD selected, but no shipping module which offers COD
          }

        if ($cod_country) {
            $cod_tax_description = tep_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
            $order->info['tax'] += tep_calculate_tax($cod_cost, $tax);
            $order->info['tax_groups']["{$cod_tax_description}"] += tep_calculate_tax($cod_cost, $tax);
            $order->info['total'] += $cod_cost + tep_calculate_tax($cod_cost, $tax);
            $this->output[] = array('title' => $this->title . ':',
                                    'text' => $currencies->format($cod_cost, true,  $order->info['currency'], $order->info['currency_value']),
                                    'value' => $cod_cost);

        } else {
//Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
// as well as countries who do not have cod
//          $this->output[] = array('title' => $this->title . ':',
//                                  'text' => 'No COD for this module.',
//                                  'value' => '');
        }
      }
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COD_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }

      return $this->_check;
    }
//lagt tilk servicepakke her!!!!
    function keys() {
      return array('MODULE_ORDER_TOTAL_COD_STATUS', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA','MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'MODULE_ORDER_TOTAL_COD_TAX_CLASS');
    }

    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 ('Display COD', 'MODULE_ORDER_TOTAL_COD_STATUS', 'true', 'Do you want this module to display?', '6', '1','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, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'AT:3.00,DE:3.58,00:9.99', 'FLAT: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'AT:3.00,DE:3.58,00:9.99', 'ITEM: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '4', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'AT:3.00,DE:3.58,00:9.99', 'TABLE: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '5', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for UPS', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'CA:4.50,US:3.00,00:9.99', 'UPS: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '6', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for USPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'CA:4.50,US:3.00,00:9.99', 'USPS: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '7', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'CA:4.50,US:3.00,00:9.99', 'ZONES: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '8', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Austrian Post', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'AT:3.63,00:9.99', 'Austrian Post: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '9', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for German Post', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'DE:3.58,00:9.99', 'German Post: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '10', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for CORRIERE1', 'MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1', 'IT:7.00,00:9.99', 'CORRIERE1: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '11', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOCELERE1', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1', 'IT:7.50,00:9.99', 'POSTEPACCOCELERE1: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '12', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOCELERE3', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3', 'IT:7.50,00:9.99', 'POSTEPACCOCELERE3: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '13', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOORDINARIO', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO', 'IT:7.50,00:9.99', 'POSTEPACCOORDINARIO: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '14', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTAORDINARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA', 'IT:7.50,00:9.99', 'POSTEPOSTAORDINARIA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '15', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTAPRIORITARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA', 'IT:7.50,00:9.99', 'POSTEPOSTAPRIORITARIA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '16', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTARACCOMANDATA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA', 'IT:7.50,00:9.99', 'POSTEPOSTARACCOMANADATA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '17', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Servicepakke', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'NO:69', 'Servicepakke: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '18', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FedEx', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'US:3.00', 'FedEx: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '19', 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_ORDER_TOTAL_COD_TAX_CLASS', '0', 'Use the following tax class on the COD fee.', '6', '11', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
    }
    

    function remove() {
      $keys = '';
      $keys_array = $this->keys();
      $keys_size = sizeof($keys_array);
      for ($i=0; $i<$keys_size; $i++) {
        $keys .= "'" . $keys_array[$i] . "',";
      }
      $keys = substr($keys, 0, -1);

      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
    }
  }
?>
Marcus...ti faranno Santo!!! Spero il più tardi possibile ovviamente!! :D
Grazie mille

Ruggero

PS: Ricordati quella contributions per il pagamento con Carta...
Cazzarola anche oggi mi hanno chiamato!! :D
Poi ovviamente dimmi il compenso...

Inviato: 24/06/2008, 22:29
da Spiderweb
Ciao,
io non ho questo problema nel senso che i supplemento del pagamento in contrassegno è una cosa a se che è presente nella pagina dei pagamenti, non c'entra niente con le spedizioni (che siano gratuite o no).

Io ho settato dal pannello admin le spese di spedizione gratutite per un importo superiore a 150 €, poi con la contribution ot_cod_fee ho impostato un supplemento per il contrassegno... come penso abbia fatto te, no?

Se un cliente mi fa un ordine di € 200,00 le spese si spedizione le salta perchè sono gratutite ma se dopo lui sceglie come pagamento il contrassegno il supplemento compare normalmente nel totale dell'ordine.

Immagine

Inviato: 25/06/2008, 1:12
da marcus
Con riferimento al modulo di Ruggero, ecco il file modificato. Le aggiunte sono marcate da /*FREE SHIP COD FEE ADD * /.

Procedura:

- disinstalla il modulo ot_cod_fee
- backuppa il file
- aggiorna il file
- reinstalla il modulo

Dovrebbe comparire una nuova casella che ti consente di settare il supplemento per la spedizione gratuita.

Codice: Seleziona tutto

<?php
/*
$Id: ot_cod_fee.php,v 1.00 2002/11/30 17:02:00 harley_vb Exp $

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

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
*/
/********************************************************************
*   Copyright (C) 2002 TheMedia, Dipl.-Ing Thomas Pl"nkers.
*       http://www.themedia.at & http://www.oscommerce.at
*
*                    All rights reserved.
*
* This program is free software licensed under the GNU General Public License (GPL).
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*    USA
*
*********************************************************************/

class ot_cod_fee {
	var $title, $output;

	function ot_cod_fee() {
		$this->code = 'ot_cod_fee';
		$this->title = MODULE_ORDER_TOTAL_COD_TITLE;
		$this->description = MODULE_ORDER_TOTAL_COD_DESCRIPTION;
		$this->enabled = ((MODULE_ORDER_TOTAL_COD_STATUS == 'true') ? true : false);
		$this->sort_order = MODULE_ORDER_TOTAL_COD_SORT_ORDER;

		$this->output = array();
	}

	function process() {
		global $order, $currencies, $cod_cost, $cod_country, $shipping;

		if (MODULE_ORDER_TOTAL_COD_STATUS == 'true') {
			$tax = tep_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS);

			//Will become true, if cod can be processed.
			$cod_country = false;

			//check if payment method is cod. If yes, check if cod is possible.
			if ($GLOBALS['payment'] == 'cod') {
				//process installed shipping modules
				if (substr_count($shipping['id'], 'flat') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
				if (substr_count($shipping['id'], 'item') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
				if (substr_count($shipping['id'], 'table') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_TABLE);

				/*FREE SHIP COD FEE ADD */
				if (substr_count($shipping['id'], 'free_free') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FREESHIP);
				/*FREE SHIP COD FEE ADD */

				if (substr_count($shipping['id'], 'ups') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_UPS);
				if (substr_count($shipping['id'], 'usps') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_USPS);
				if (substr_count($shipping['id'], 'fedex') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FEDEX);
				if (substr_count($shipping['id'], 'zones') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
				if (substr_count($shipping['id'], 'ap') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_AP);
				if (substr_count($shipping['id'], 'dp') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_DP);
				if (substr_count($shipping['id'], 'corriere1') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1);
				if (substr_count($shipping['id'], 'postepaccocelere1') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1);
				if (substr_count($shipping['id'], 'postepaccocelere3') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3);
				if (substr_count($shipping['id'], 'postepaccoordinario') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO);
				if (substr_count($shipping['id'], 'postepostaordinaria') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA);
				if (substr_count($shipping['id'], 'postepostaprioritaria') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA);
				if (substr_count($shipping['id'], 'postepostaraccomandata') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA);
				//satt inn av Pompel
				if (substr_count($shipping['id'], 'servicepakke') !=0) $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE);

				for ($i = 0; $i < count($cod_zones); $i++) {
					if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
						$cod_cost = $cod_zones[$i + 1];
						$cod_country = true;
						//print('match' . $i . ': ' . $cod_cost);
						break;
					} elseif ($cod_zones[$i] == '00') {
						$cod_cost = $cod_zones[$i + 1];
						$cod_country = true;
						//print('match' . $i . ': ' . $cod_cost);
						break;
					} else {
						//print('no match');
					}
					$i++;
				}
			} else {
				//COD selected, but no shipping module which offers COD
			}

			if ($cod_country) {
				$cod_tax_description = tep_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
				$order->info['tax'] += tep_calculate_tax($cod_cost, $tax);
				$order->info['tax_groups']["{$cod_tax_description}"] += tep_calculate_tax($cod_cost, $tax);
				$order->info['total'] += $cod_cost + tep_calculate_tax($cod_cost, $tax);
				$this->output[] = array('title' => $this->title . ':',
				'text' => $currencies->format($cod_cost, true,  $order->info['currency'], $order->info['currency_value']),
				'value' => $cod_cost);

			} else {
				//Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
				// as well as countries who do not have cod
				//          $this->output[] = array('title' => $this->title . ':',
				//                                  'text' => 'No COD for this module.',
				//                                  'value' => '');
			}
		}
	}

	function check() {
		if (!isset($this->_check)) {
			$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COD_STATUS'");
			$this->_check = tep_db_num_rows($check_query);
		}

		return $this->_check;
	}
	//lagt tilk servicepakke her!!!!



	function keys() {
		return array('MODULE_ORDER_TOTAL_COD_STATUS', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', /*FREE SHIP COD FEE ADD */'MODULE_ORDER_TOTAL_COD_FEE_FREESHIP'/*FREE SHIP COD FEE ADD */, 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3','MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA','MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'MODULE_ORDER_TOTAL_COD_TAX_CLASS');
	}


	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 ('Display COD', 'MODULE_ORDER_TOTAL_COD_STATUS', 'true', 'Do you want this module to display?', '6', '1','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, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'AT:3.00,DE:3.58,00:9.99', 'FLAT: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'AT:3.00,DE:3.58,00:9.99', 'ITEM: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '4', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'AT:3.00,DE:3.58,00:9.99', 'TABLE: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '5', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for UPS', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'CA:4.50,US:3.00,00:9.99', 'UPS: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '6', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for USPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'CA:4.50,US:3.00,00:9.99', 'USPS: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '7', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'CA:4.50,US:3.00,00:9.99', 'ZONES: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '8', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Austrian Post', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'AT:3.63,00:9.99', 'Austrian Post: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '9', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for German Post', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'DE:3.58,00:9.99', 'German Post: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '10', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for CORRIERE1', 'MODULE_ORDER_TOTAL_COD_FEE_CORRIERE1', 'IT:7.00,00:9.99', 'CORRIERE1: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '11', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOCELERE1', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE1', 'IT:7.50,00:9.99', 'POSTEPACCOCELERE1: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '12', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOCELERE3', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOCELERE3', 'IT:7.50,00:9.99', 'POSTEPACCOCELERE3: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '13', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPACCOORDINARIO', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPACCOORDINARIO', 'IT:7.50,00:9.99', 'POSTEPACCOORDINARIO: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '14', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTAORDINARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAORDINARIA', 'IT:7.50,00:9.99', 'POSTEPOSTAORDINARIA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '15', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTAPRIORITARIA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTAPRIORITARIA', 'IT:7.50,00:9.99', 'POSTEPOSTAPRIORITARIA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '16', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for POSTEPOSTARACCOMANDATA', 'MODULE_ORDER_TOTAL_COD_FEE_POSTEPOSTARACCOMANDATA', 'IT:7.50,00:9.99', 'POSTEPOSTARACCOMANADATA: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '17', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Servicepakke', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'NO:69', 'Servicepakke: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '18', now())");
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FedEx', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'US:3.00', 'FedEx: <Country code>:<COD price>, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '19', 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_ORDER_TOTAL_COD_TAX_CLASS', '0', 'Use the following tax class on the COD fee.', '6', '11', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");

		/*FREE SHIP COD FEE ADD */
		tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FREE SHIP', 'MODULE_ORDER_TOTAL_COD_FEE_FREESHIP', 'IT:7.00,00:9.99', 'COD Fee for FREE SHIPPING', '6', '3', now())");
		/*FREE SHIP COD FEE ADD */
	}


	function remove() {
		$keys = '';
		$keys_array = $this->keys();
		$keys_size = sizeof($keys_array);
		for ($i=0; $i<$keys_size; $i++) {
			$keys .= "'" . $keys_array[$i] . "',";
		}
		$keys = substr($keys, 0, -1);

		tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
	}
}
?>
Saluti
Marcus

Inviato: 28/06/2008, 10:11
da dr_ock
RISOLTOOO!!!!
SEI UN GRANDE!!!
GRAZIE GRAZIE MILLE

Inviato: 10/09/2008, 23:25
da tekshark
Spiderweb ha scritto:Ciao,
io non ho questo problema nel senso che i supplemento del pagamento in contrassegno è una cosa a se che è presente nella pagina dei pagamenti, non c'entra niente con le spedizioni (che siano gratuite o no).

Io ho settato dal pannello admin le spese di spedizione gratutite per un importo superiore a 150 €, poi con la contribution ot_cod_fee ho impostato un supplemento per il contrassegno... come penso abbia fatto te, no?

Se un cliente mi fa un ordine di € 200,00 le spese si spedizione le salta perchè sono gratutite ma se dopo lui sceglie come pagamento il contrassegno il supplemento compare normalmente nel totale dell'ordine.

Immagine
Ciao, con questa contribtion posso anche settare le spese di contrassegno come una percentuale del totale??? o posso essere solo una spesa fissa?

Inviato: 11/09/2008, 19:38
da Spiderweb
Ho provato mettendo la percentuale ma sembra non funzioni...

Io ho impostato una cifra fissa.

Re: Quesito per ordini superiori a € 100

Inviato: 07/10/2008, 9:07
da wiko85
buondì gente!
ma il modulo ot_cod_fee a cosa serve e dove potrei trovarlo?
dovrei fare in modo che gli ordini superiori a € 100,00 abbiano il trasporto gratuito, può andar bene questa contrib? grazie

Re: Quesito per ordini superiori a € 100

Inviato: 07/10/2008, 9:32
da marcus
wiko85 ha scritto:buondì gente!
ma il modulo ot_cod_fee a cosa serve e dove potrei trovarlo?
dovrei fare in modo che gli ordini superiori a € 100,00 abbiano il trasporto gratuito, può andar bene questa contrib? grazie
Il modulo ot_cod_fee serve per definire un supplemento per il pagamento alla consegna (contrassegno).

Per le spedizioni gratuite sopra i 100 Euro vai in moduli-> totale ordine -> spedizione e setta:

Allow Free Shipping
true

Free Shipping For Orders Over
€100,00

Saluti
Marcus

Re: Quesito per ordini superiori a € 100

Inviato: 07/10/2008, 10:09
da wiko85
grazie 1000 Marcus... come faremmo senza di te? :mrgreen: :mrgreen: :mrgreen:

Re: Quesito per ordini superiori a € 100

Inviato: 09/10/2008, 11:51
da wiko85
ops... dev'esserci qualche problema nel free shipping...
ho impostato € 100,00 come limite per la spedizione a pagamento ma la contrib calcola questo valore ivato su prezzi già ivati
mi spiego meglio... sul sito io visualizzo i prezzi iva inclusa e per avere le spedizioni gratuite la contrib mi calcola l'iva nuovamente al 20% sui prodotti già ivati
se aggiungo al carrello dei prodotti per un valore di € 90,00 ivati, il sistema considera quelle 90 euro iva esclusa e dando € 108,00 con il 20%, mi dà la spedizione gratuita
com'è possibile? bisogna settare qualcos'altro? :?

Re: Quesito per ordini superiori a € 100

Inviato: 10/10/2008, 15:11
da wiko85
...nessuno? :(

Re: Quesito per ordini superiori a € 100

Inviato: 11/10/2008, 13:28
da wiko85
marcus... :?

Re: Quesito per ordini superiori a € 100

Inviato: 15/12/2008, 20:12
da teo.marshall
ciao a tutti, sono nuovo del forum e ho provato a seguire le istruzioni che ci sono nella pagina in quanto non riesco ad aggiungere un costo fisso se viene effettuato un pagamento al contrassegno, ma purtroppo ho un problema di fondo in quanto non riesco ad intallare il modulo ot_cod_fee.php; clicco su "installa" ma non installa effettivamente il modulo.
dove sbaglio?
il modulo l'ho preso da http://www.oscommerce.com/community/con ... ot_cod_fee.
spero che possiate aiutarmi perchè sono completamente bloccato..
grazie
ciao