/**
	 * Applies a coupon code
	 *
	 * @param   string	code	The code to apply
	 * @return   bool	True if the coupon is applied, false if it does not exist or cannot be applied
	 */
	function add_discount( $coupon_code ) {

		if ($the_coupon = jigoshop_coupons::get_coupon($coupon_code)) :

			// Check if applied
			if (jigoshop_cart::has_discount($coupon_code)) :
				jigoshop::add_error( __('Discount code already applied!', 'jigoshop') );
				return false;
			endif;

			// Check it can be used with cart
			if (!jigoshop_coupons::is_valid($coupon_code)) :
				jigoshop::add_error( __('Invalid coupon.', 'jigoshop') );
				return false;
			endif;

			// If its individual use then remove other coupons
			if ($the_coupon['individual_use']=='yes') :
				self::$applied_coupons = array();
			endif;

			foreach (self::$applied_coupons as $coupon) :
				$coupon = jigoshop_coupons::get_coupon($coupon);
				if ($coupon['individual_use']=='yes') :
					self::$applied_coupons = array();
				endif;
			endforeach;

			self::$applied_coupons[] = $coupon_code;
			self::set_session();
			jigoshop::add_message( __('Discount code applied successfully.', 'jigoshop') );
			return true;

		else :
			jigoshop::add_error( __('Coupon does not exist!', 'jigoshop') );
			return false;
		endif;
		return false;

	}