shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

citylink.php (1950B)


      1 <?php
      2 class ModelExtensionShippingCitylink extends Model {
      3 	function getQuote($address) {
      4 		$this->load->language('extension/shipping/citylink');
      5 
      6 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('shipping_citylink_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
      7 
      8 		if (!$this->config->get('shipping_citylink_geo_zone_id')) {
      9 			$status = true;
     10 		} elseif ($query->num_rows) {
     11 			$status = true;
     12 		} else {
     13 			$status = false;
     14 		}
     15 
     16 		$method_data = array();
     17 
     18 		if ($status) {
     19 			$cost = 0;
     20 			$weight = $this->cart->getWeight();
     21 
     22 			$rates = explode(',', $this->config->get('shipping_citylink_rate'));
     23 
     24 			foreach ($rates as $rate) {
     25 				$data = explode(':', $rate);
     26 
     27 				if ($data[0] >= $weight) {
     28 					if (isset($data[1])) {
     29 						$cost = $data[1];
     30 					}
     31 
     32 					break;
     33 				}
     34 			}
     35 
     36 			$quote_data = array();
     37 
     38 			if ((float)$cost) {
     39 				$quote_data['citylink'] = array(
     40 					'code'         => 'citylink.citylink',
     41 					'title'        => $this->language->get('text_title') . '  (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')',
     42 					'cost'         => $cost,
     43 					'tax_class_id' => $this->config->get('shipping_citylink_tax_class_id'),
     44 					'text'         => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_citylink_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
     45 				);
     46 
     47 				$method_data = array(
     48 					'code'       => 'citylink',
     49 					'title'      => $this->language->get('text_title'),
     50 					'quote'      => $quote_data,
     51 					'sort_order' => $this->config->get('shipping_citylink_sort_order'),
     52 					'error'      => false
     53 				);
     54 			}
     55 		}
     56 
     57 		return $method_data;
     58 	}
     59 }