Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: DHL Nachnahme Gebühren werden nicht berechnet

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    DHL Nachnahme Gebühren werden nicht berechnet
    am: 25. Februar 2013, 00:42:01
    Hallo,

    Habe eine abgespeckte DHL Modul bei dem ich die Nachnahme Gebühren angehängt bekomme. Bei allen anderen funktioniert es.

    Code: PHP  [Auswählen]
    <?php
    /* -----------------------------------------------------------------------------------------
       $Id: dhl.php 899 2005-04-29 02:40:57Z hhgag $  

       XT-Commerce - community made shopping
       http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte Forenregeln beachten! ))

       Copyright (c) 2003 XT-Commerce
       -----------------------------------------------------------------------------------------
       based on:
       (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
       (c) 2002-2003 osCommerce(dhl.php,v 1.36 2003/03/09 02:14:35); www.oscommerce.com
       (c) 2003      nextcommerce (dhl.php,v 1.12 2003/08/24); www.nextcommerce.org

       Released under the GNU General Public License
       -----------------------------------------------------------------------------------------
       Third Party contributions:
       German Post (Deutsche Post WorldNet)                 Autor:  Copyright (C) 2002 - 2003 TheMedia, Dipl.-Ing Thomas Plänkers | http://www.themedia.at & http://www.oscommerce.at

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/

       
       

     
      class dhl {
        var $code, $title, $description, $icon, $enabled, $num_dhl;


        function dhl() {
          global $order;

          $this->code = 'dhl';
          $this->title = MODULE_SHIPPING_DHL_TEXT_TITLE;
              $this->imgtitle = MODULE_SHIPPING_DHL_IMG_TITLE;
          $this->description = MODULE_SHIPPING_DHL_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_DHL_SORT_ORDER;
          $this->icon = DIR_WS_ICONS . 'shipping_dhl.gif';
          $this->tax_class = MODULE_SHIPPING_DHL_TAX_CLASS;
          $this->enabled = ((MODULE_SHIPPING_DHL_STATUS == 'True') ? true : false);

          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_DHL_ZONE > 0) ) {
            $check_flag = false;
            $check_query = xtc_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_DHL_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
            while ($check = xtc_db_fetch_array($check_query)) {
              if ($check['zone_id'] < 1) {
                $check_flag = true;
                break;
              } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
            }

            if ($check_flag == false) {
              $this->enabled = false;
            }
          }

    /**
     * CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
     */

          $this->num_dhl = 6;
        }

    /**
     * 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_dhl; $i++) {
            $countries_table = constant('MODULE_SHIPPING_DHL_COUNTRIES_' . $i);
            $country_zones = split("[,]", $countries_table);
            if (in_array($dest_country, $country_zones)) {
              $dest_zone = $i;
              break;
            }
          }

          if ($dest_zone == 0) {
            $error = true;
          } else {
            $shipping = -1;
            $dhl_cost = constant('MODULE_SHIPPING_DHL_COST_' . $i);

            $dhl_table = split("[:,]" , $dhl_cost);
            for ($i=0; $i<sizeof($dhl_table); $i+=2) {
              if ($shipping_weight <= $dhl_table[$i]) {
                $shipping = $dhl_table[$i+1];
                $shipping_method = MODULE_SHIPPING_DHL_TEXT_WAY . ' ' . $dest_country;
                break;
              }
            }

            if ($shipping == -1) {
              $shipping_cost = 0;
              $shipping_method = MODULE_SHIPPING_DHL_UNDEFINED_RATE;
            } else {
              $shipping_cost = ($shipping + MODULE_SHIPPING_DHL_HANDLING);
            }
          }

          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_DHL_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => $shipping_method,
                                                         'cost' => $shipping_cost * $shipping_num_boxes)));

          if ($this->tax_class > 0) {
            $this->quotes['tax'] = xtc_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
          }

          if (xtc_not_null($this->icon)) $this->quotes['icon'] = xtc_image($this->icon, $this->imgtitle);

          if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_DHL_INVALID_ZONE;

          return $this->quotes;
        }

        function check() {
          if (!isset($this->_check)) {
            $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_DHL_STATUS'");
            $this->_check = xtc_db_num_rows($check_query);
          }
          return $this->_check;
        }

          function install() {
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_SHIPPING_DHL_STATUS', 'True', '6', '0', 'xtc_cfg_select_option(array(\'True\', \'False\'), ', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_HANDLING', '0', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, use_function, set_function, date_added) values ('MODULE_SHIPPING_DHL_TAX_CLASS', '0', '6', '0', 'xtc_get_tax_class_title', 'xtc_cfg_pull_down_tax_classes(', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, use_function, set_function, date_added) values ('MODULE_SHIPPING_DHL_ZONE', '0', '6', '0', 'xtc_get_zone_class_title', 'xtc_cfg_pull_down_zone_classes(', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_SORT_ORDER', '0', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_ALLOWED', '', '6', '0', now())");
             
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_1', 'AT', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_1', '1:5.00,2:5.50,10:8.00', '6', '0', now())");
              xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_2', 'AD,DE,BE,CZ,DK,FO,FI,FR,GR,GL,IE,IT,LI,LU,MC,NL,PL,PT,SM,SK,SE,CH,VA,GB,SP', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_2', '1:10.00,2:12.00,5:18.00', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_3', 'AL,AM,AZ,BY,BA,BG,HR,CY,GE,GI,HU,IS,KZ,LT,MK,MT,MD,NO,SI,UA,TR,YU,RU,RO,LV,EE', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_3', '5:25.00,10:35.00,20:45.00', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_4', 'DZ,BH,CA,EG,IR,IQ,IL,JO,KW,LB,LY,OM,SA,SY,US,AE,YE,MA,QA,TN,PM', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_4', '5:29.00,10:39.00,20:59.00', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_5', 'AF,AS,AO,AI,AG,AR,AW,AU,BS,BD,BB,BZ,BJ,BM,BT,BO,BW,BR,IO,BN,BF,BI,KH,CM,CV,KY,CF,TD,CL,CN,CC,CO,KM,CG,CR,CI,CU,DM,DO,EC,SV,ER,ET,FK,FJ,GF,PF,GA,GM,GH,GD,GP,GT,GN,GW,GY,HT,HN,HK,IN,ID,JM,JP,KE,KI,KG,KP,KR,LA,LS', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_5', '5:35.00,10:50.00,20:80.00', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COUNTRIES_6', 'MO,MG,MW,MY,MV,ML,MQ,MR,MU,MX,MN,MS,MZ,MM,NA,NR,NP,AN,NC,NZ,NI,NE,NG,PK,PA,PG,PY,PE,PH,PN,RE,KN,LC,VC,SN,SC,SL,SO,LK,SR,SZ,ZA,SG,TG,TH,TZ,TT,TO,TM,TV,VN,WF,VE,UG,UZ,UY,ST,SH,SD,TW,GQ,LR,DJ,CG,RW,ZM,ZW', '6', '0', now())");
          xtc_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_key, configuration_value,  configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_DHL_COST_6', '5:35.00,10:50.00,20:80.00', '6', '0', now())");

        }

        function remove() {
          xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
        }

        function keys() {
          $keys = array('MODULE_SHIPPING_DHL_STATUS', 'MODULE_SHIPPING_DHL_HANDLING','MODULE_SHIPPING_DHL_ALLOWED', 'MODULE_SHIPPING_DHL_TAX_CLASS', 'MODULE_SHIPPING_DHL_ZONE', 'MODULE_SHIPPING_DHL_SORT_ORDER');

          for ($i = 1; $i <= $this->num_dhl; $i ++) {
            $keys[count($keys)] = 'MODULE_SHIPPING_DHL_COUNTRIES_' . $i;
            $keys[count($keys)] = 'MODULE_SHIPPING_DHL_COST_' . $i;
          }

          return $keys;
        }
      }
    ?>
     

    Unter cod.php habe ich diese Zeile eingefügt
    Code: PHP  [Auswählen]
    if ($_SESSION['shipping']['id'] == 'dhl_COST') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DHL);

    Habe ich vielleicht etwas ausgelassen das die Nachnahme kosten berechnet.

    lg
    karabey

    Linkback: https://www.modified-shop.org/forum/index.php?topic=24970.0
    rechtstexte für onlineshop

    web28

    • modified Team
    • Beiträge: 9.404
    Re: DHL Nachnahme Gebühren werden nicht berechnet
    Antwort #1 am: 25. Februar 2013, 11:33:02
    Versuche es statt mit dhl_COST mit dhl_dhl

    dann ist split seit PHP5.3 deprecated und sollte nicht mehr benutzt werden.

    Benutze dafür
    Code: PHP  [Auswählen]
    preg_split("/[:,]/", $dhl_cost)

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    Re: DHL Nachnahme Gebühren werden nicht berechnet
    Antwort #2 am: 25. Februar 2013, 22:10:26
    Super vielen Dank web28  :-B
    1 Antworten
    2028 Aufrufe
    25. November 2014, 18:01:45 von fishnet
    3 Antworten
    2310 Aufrufe
    28. Juli 2012, 11:38:00 von jannemann
    4 Antworten
    417 Aufrufe
    20. Oktober 2022, 14:20:25 von awund
    0 Antworten
    2271 Aufrufe
    09. Januar 2012, 15:17:45 von arsawede