shop.balmet.com

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

parcelforce_48.php (2870B)


      1 <?php
      2 class ModelExtensionShippingParcelforce48 extends Model {
      3 	function getQuote($address) {
      4 		$this->load->language('extension/shipping/parcelforce_48');
      5 
      6 		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('shipping_parcelforce_48_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_parcelforce_48_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 			$sub_total = $this->cart->getSubTotal();
     22 
     23 			$rates = explode(',', $this->config->get('shipping_parcelforce_48_rate'));
     24 
     25 			foreach ($rates as $rate) {
     26 				$data = explode(':', $rate);
     27 
     28 				if ($data[0] >= $weight) {
     29 					if (isset($data[1])) {
     30 						$cost = $data[1];
     31 					}
     32 
     33 					break;
     34 				}
     35 			}
     36 
     37 			$rates = explode(',', $this->config->get('shipping_parcelforce_48_insurance'));
     38 
     39 			foreach ($rates as $rate) {
     40 				$data = explode(':', $rate);
     41 
     42 				if ($data[0] >= $sub_total) {
     43 					if (isset($data[1])) {
     44 						$insurance = $data[1];
     45 					}
     46 
     47 					break;
     48 				}
     49 			}
     50 
     51 			$quote_data = array();
     52 
     53 			if ((float)$cost) {
     54 				$text = $this->language->get('text_description');
     55 
     56 				if ($this->config->get('shipping_parcelforce_48_display_weight')) {
     57 					$text .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('config_weight_class_id')) . ')';
     58 				}
     59 
     60 				if ($this->config->get('shipping_parcelforce_48_display_insurance') && (float)$insurance) {
     61 					$text .= ' (' . $this->language->get('text_insurance') . ' ' . $this->currency->format($insurance, $this->session->data['currency']) . ')';
     62 				}
     63 
     64 				if ($this->config->get('shipping_parcelforce_48_display_time')) {
     65 					$text .= ' (' . $this->language->get('text_time') . ')';
     66 				}
     67 
     68 				$quote_data['parcelforce_48'] = array(
     69 					'code'         => 'parcelforce_48.parcelforce_48',
     70 					'title'        => $text,
     71 					'cost'         => $cost,
     72 					'tax_class_id' => $this->config->get('shipping_parcelforce_48_tax_class_id'),
     73 					'text'         => $this->currency->format($this->tax->calculate($cost, $this->config->get('shipping_parcelforce_48_tax_class_id'), $this->config->get('config_tax')), $this->session->data['currency'])
     74 				);
     75 
     76 				$method_data = array(
     77 					'code'       => 'parcelforce_48',
     78 					'title'      => $this->language->get('text_title'),
     79 					'quote'      => $quote_data,
     80 					'sort_order' => $this->config->get('shipping_parcelforce_48_sort_order'),
     81 					'error'      => false
     82 				);
     83 			}
     84 		}
     85 
     86 		return $method_data;
     87 	}
     88 }