<?php
class CalculateCoupon extends Calculate {
	function __construct(&$locator) {		
		$this->cart     =& $locator->get('cart');
		$this->coupon   =& $locator->get('coupon');
		$this->config   =& $locator->get('config');
		$this->currency =& $locator->get('currency');
		$this->language =& $locator->get('language');
		$this->session  =& $locator->get('session');
		$this->shipping =& $locator->get('shipping');
		$this->tax      =& $locator->get('tax');
	    $this->customer  =& $locator->get('customer');
        $this->database  =& $locator->get('database');
	    $this->request   =& $locator->get('request');
		$this->language->load('extension/calculate/coupon.php');
  	}

	function calculate() {
		$total_data = array();
		if (($this->config->get('coupon_status')) && ($this->coupon->getId())) {	
		
		    $coupon_discount= $this->coupon->getDiscount();	
			$total=$this->cart->getSubtotal();
			$subtotal=$this->cart->getTotal();
        	if ($coupon_discount < $total) {
      			$total_data[] = array(
        			'title' => 'Coupon['.'<label style="color:red;">'.$this->coupon->getCode().'</label>]:',
	    			'text'  => '-' . $this->currency->format($coupon_discount),
        			'value' => $coupon_discount
      			);				
				if ($total==$subtotal)
				{
//					$this->cart->decreaseTotal($this->coupon->getDiscount());
				}
				
			}			
		
			
    	}
		
    	return $total_data;
	}
	
	function getSortOrder() {
		return 3;
	}
}
?>
