<?php 
class ShippingWeight extends Shipping {    
	function __construct(&$locator) { 
		$this->address  =& $locator->get('address');
		$this->cart     =& $locator->get('cart');
		$this->config   =& $locator->get('config');
		$this->currency =& $locator->get('currency');
		$this->database =& $locator->get('database');
		$this->language =& $locator->get('language');
		$this->session  =& $locator->get('session');
		$this->tax      =& $locator->get('tax');
				
		$this->language->load('extension/shipping/weight.php');
  	}
  	
  	function quote() {
		if ($this->config->get('weight_status')) {
      		if (!$this->config->get('weight_geo_zone_id')) {
        		$status = true;
      		} elseif ($this->database->getRows("select * from zone_to_geo_zone where geo_zone_id = '" . (int)$this->config->get('item_geo_zone_id') . "' and country_id = '" . (int)$this->address->getCountryId($this->session->get('shipping_address_id')) . "' and (zone_id = '" . (int)$this->address->getZoneId($this->session->get('shipping_address_id')) . "' or zone_id = '0')")) {
        		$status = true;
      		} else {
        		$status = false;
      		}
		} else {
			$status = false;
		}
		
		$method_data = array();
	
		if ($status) {
			$quote_data = array();
			
      		$quote_data['weight'] = array(
        		'id'    => 'weight_weight',
        		'title' => $this->language->get('text_weight_description'),

        		'cost'  => $this->config->get('weight_cost') * $this->cart->countProducts(),
        		'text'  => $this->currency->format($this->tax->calculate($this->config->get('weight_cost') * $this->cart->getWeight(), $this->config->get('weight_tax_class_id'), $this->config->get('config_tax')))
      		);

      		$method_data = array(
        		'id'           => 'weight',
        		'title'        => $this->language->get('text_weight_title'),
        		'quote'        => $quote_data,
        		'tax_class_id' => $this->config->get('weight_tax_class_id'),
			'sort_order'   => $this->config->get('weight_sort_order'),
        		'error'        => false
      		);
		}
	
		return $method_data;
  	}
}
?>