Es werden ausschließlich für die Funktion des Forums notwendige Cookies verwendet!

Unsere Datenschutzerklärung


Versandkosten nach Km
Ergebnis 1 bis 2 von 2

Thema: Versandkosten nach Km

  1. #1
    Neuer Benutzer
    Registriert seit
    15.01.2016
    Beiträge
    3
    Downloads
    3
    Uploads
    0

    Versandkosten nach Km

    Hallo,

    erstmals wollte ich sagen das ich neu bei Gambio bin vorher Modified
    Hatte damals ein Versandmodul programmiert bekommen Danke an Ihn.

    Es geht darum das ich meine Ware ausliefer und daher Versandkosten nach Km berechne.
    Es Funktioniert alles einwandfrei nur eins nicht undzwar das mein Modul sich nach 15 Km Enfernung sich nicht ausschaltet.
    Wie muss ich das schreiben damit er nicht angezegit wird wenn die Person weiter als 15 Km entfernung wohnt ?

    Hier die Datei:
    Code:
    <?php
    
    
      class zones {
        var $code, $title, $description, $enabled, $num_zones;
    
    /**
     * class constructor
     */
        function zones() {
          $this->code = 'zones';
          $this->title = MODULE_SHIPPING_ZONES_TEXT_TITLE;
          $this->description = MODULE_SHIPPING_ZONES_TEXT_DESCRIPTION;
          $this->sort_order = MODULE_SHIPPING_ZONES_SORT_ORDER;
          $this->icon = '';
          $this->tax_class = MODULE_SHIPPING_ZONES_TAX_CLASS;
          $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
    
    /**
     * CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
     * 
     * + CUSTOMIZE THE SETTING IN lang/LANGUAGE/modules/shipping/zones.php
     */
    
    //BOF - 29.07.2009 - Dokuman - up to 9 zones possible, no changes in langfile needed
          //$this->num_zones = 1;
          $this->num_zones = 9;
    //EOF - 29.07.2009 - Dokuman - up to 9 zones possible, no changes in langfile needed
        }
    
    /**
     * class methods
     */
        function quote($method = '') {
          global $order, $shipping_weight;
    
          $dest_country = $order->delivery['country']['iso_code_2'];
          $dest_zone = 0;
          $error = false;
    
          $sOrigin = 'Unterdorfstr.50, 53859 Niederkassel, DE';
    
    
          $sUrl = sprintf("http://maps.googleapis.com/maps/api/distancematrix/json?origins=%s&destinations=%s+%s+%s+%s&language=de-DE&sensor=false",
            urlencode($sOrigin),
            urlencode($order->delivery['street_address']),
            urlencode($order->delivery['postcode']),
            urlencode($order->delivery['city']), $order->delivery['country']['iso_code_2']);
          $oJSON = json_decode(file_get_contents($sUrl));
    
          if($oJSON->rows[0]->elements[0]->status!="OK") {
            $error = true;
          } else {
            $iDistance = ceil($oJSON->rows[0]->elements[0]->distance->value/1000);
          }
    
          if($iDistance<=50) {
            $iZoom = 12;
          } elseif($iDistance>50 && $iDistance<=100) {
            $iZoom = 10;
          } else {
            $iZoom = 6;
          }
          for ($i=1; $i<=$this->num_zones; $i++) {
            $countries_table = constant('MODULE_SHIPPING_ZONES_COUNTRIES_' . $i);
            $country_zones = explode(",", $countries_table); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
            if (in_array($dest_country, $country_zones)) {
              $dest_zone = $i;
              break;
            }
          }
    
          if ($dest_zone == 0) {
            $error = true;
          } else {
            $shipping = -1;
            $zones_cost = constant('MODULE_SHIPPING_ZONES_COST_' . $dest_zone);
    
            $zones_table = preg_split("/[:,]/" , $zones_cost); // Hetfield - 2009-08-18 - replaced deprecated function split with preg_split to be ready for PHP >= 5.3
            $size = sizeof($zones_table);
            for ($i=0; $i<$size; $i+=2) {
              if ($iDistance <= $zones_table[$i]) {
                $shipping = $zones_table[$i+1];
                $shipping_method = MODULE_SHIPPING_ZONES_TEXT_WAY . ' ' . $dest_country . ' (' . $iDistance." km)";
                $sUrlMap = sprintf("http://maps.googleapis.com/maps/api/staticmap?zoom=%d&size=600x200&maptype=roadmap&markers=color:blue%%7Clabel:Z%%7C%s+%s+%s+%s&markers=color:green%%7Clabel:S%%7C%s&sensor=false",
                  $iZoom,
                  urlencode($order->delivery['street_address']),
                  urlencode($order->delivery['postcode']),
                  urlencode($order->delivery['city']), $order->delivery['country']['iso_code_2'], urlencode($sOrigin));
                $shipping_method .= sprintf("<br/><img src='%s'/>", $sUrlMap);
                break;
              }
            }
    
            if ($shipping == -1) {
              $shipping_cost = 0;
              $shipping_method = MODULE_SHIPPING_ZONES_UNDEFINED_RATE;
    		  
            } else {
              $shipping_cost = ($shipping + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone));
            }
          }
    
          $this->quotes = array('id' => $this->code,
                                'module' => MODULE_SHIPPING_ZONES_TEXT_TITLE,
                                'methods' => array(array('id' => $this->code,
                                                         'title' => $shipping_method,
                                                         'cost' => $shipping_cost)));
    
          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->title);
    
          if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_ZONES_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_ZONES_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_ZONES_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_ZONES_ALLOWED', '', '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_ZONES_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, date_added) values ('MODULE_SHIPPING_ZONES_SORT_ORDER', '0', '6', '0', now())");
          for ($i = 1; $i <= $this->num_zones; $i++) {
            $default_countries = '';
            if ($i == 1) {
              $default_countries = 'US,CA';
            }
            xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_ZONES_COUNTRIES_" . $i ."', '" . $default_countries . "', '6', '0', now())");
            xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_SHIPPING_ZONES_COST_" . $i ."', '3:8.50,7:10.50,99:20.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_ZONES_HANDLING_" . $i."', '0', '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_ZONES_STATUS','MODULE_SHIPPING_ZONES_ALLOWED', 'MODULE_SHIPPING_ZONES_TAX_CLASS', 'MODULE_SHIPPING_ZONES_SORT_ORDER');
    
          for ($i=1; $i<=$this->num_zones; $i++) {
            $keys[] = 'MODULE_SHIPPING_ZONES_COUNTRIES_' . $i;
            $keys[] = 'MODULE_SHIPPING_ZONES_COST_' . $i;
            $keys[] = 'MODULE_SHIPPING_ZONES_HANDLING_' . $i;
          }
    
          return $keys;
        }
      }
    ?>

  2. #2
    Administrator Avatar von KlausK
    Registriert seit
    29.09.2010
    Beiträge
    3.325
    Blog-Einträge
    1
    Downloads
    360
    Uploads
    536

    AW: Versandkosten nach Km

    Nur um diesen Beitrag nicht ganz verwaisen zu lassen ....
    Ich bin zwar kein Programmierer. Aber ich denke nicht, dass in diesem Script die Entscheidung getroffen wird, welche Versandoption bei welcher Entfernung angezeigt wird.
    Außerdem wird dieses Script offenbar von andere Scripten aufgerufen, nur von welchen?
    Vielleicht solltest du dich nochmal an deinen Programmierer wenden.

Ähnliche Themen

  1. Versandkosten nicht nach Gewicht
    Von arztde im Forum Gambio GX Adminbereich
    Antworten: 3
    Letzter Beitrag: 14.05.2015, 18:32
  2. Versandkosten nach Preis/Gewicht Nach Master Update
    Von Tormentor im Forum Gambio GX Module
    Antworten: 7
    Letzter Beitrag: 11.11.2014, 15:06
  3. Versandkosten nach PLZ u. Gewicht
    Von Tagri im Forum Gambio GX Module
    Antworten: 3
    Letzter Beitrag: 26.08.2013, 10:24
  4. Zahlungsabwicklung - Versandkosten
    Von Alkor im Forum Gambio GX Module
    Antworten: 2
    Letzter Beitrag: 19.06.2012, 18:06

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •