shop.balmet.com

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

weight.php (2208B)


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