 			num = value / 100
 		parseFloat(num).toFixed(2).replace('.', ',').toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1.')
 
-	getCartData: ->
-		self = this
+	getCartData: =>
+		$(@options.$template).addClass 'amount-items-in-cart-loading'
 
-		$(self.options.$template).addClass 'amount-items-in-cart-loading'
-
-		promise = $.ajax {
+		$.ajax({
 			url: '/api/checkout/pub/orderForm/'
 			data: JSON.stringify {"expectedOrderFormSections": ["items", "paymentData", "totalizers"]}
 			dataType: 'json'
 			contentType: 'application/json; charset=utf-8'
 			type: 'POST'
-		}
-
-		promise.done (data) ->
-			$(self.options.$template).removeClass 'amount-items-in-cart-loading'
-
-		promise.success (data) ->
-			self.setCartData data
-
-		promise.fail (jqXHR, textStatus, errorThrown) ->
+		})
+		.done (data) =>
+			$(@options.$template).removeClass 'amount-items-in-cart-loading'
+		.success (data) =>
+			@setCartData data
+		.fail (jqXHR, textStatus, errorThrown) =>
 			# console.log 'Error Message: ' + textStatus;
 			# console.log 'HTTP Error: ' + errorThrown;
 
-		promise
-
-	setCartData: (data) ->
-		self = this
-
+	setCartData: (data) =>
 		amountProducts = data.items.length
 		amountItems = 0;
 		amountItems += item.quantity for item in data.items

		total = 0
		for subtotal in data.totalizers
			total += subtotal.value if subtotal.id is 'Items'
		totalCart = self.formatCurrency(total)

		self.selectors.amountProducts.html amountProducts
		self.selectors.amountItems.html amountItems
		self.selectors.totalCart.html totalCart

#
# Plugin
#
$.fn.vtexMinicart = (options) ->
	return this if @hasClass("plugin_vtexTotalizers")
	@addClass("plugin_vtexTotalizers")
	new vtexTotalizers(this, options)
	return this

$.fn.vtexMinicart.defaults = {}

		</div>
		"""

		$(@element).after @options.$template

		@selectors = {
			amountProducts: $('.amount-products-em', @options.$template)
			amountItems: $('.amount-items-em', @options.$template)
			totalCart: $('.total-cart-em', @options.$template)
		}

		@getCartData()

		$(window).on 'cartUpdated', (event, cartData) =>
			if (cartData)
				@setCartData(cartData)
			else
				@getCartData()

		$('.amount-items-in-cart, .show-minicart-on-hover').on 'mouseover', ->
			$(window).trigger 'miniCartMouseOver'

		$('.amount-items-in-cart, .show-minicart-on-hover').on 'mouseout', ->
			$(window).trigger 'miniCartMouseOut'

	formatCurrency: (value) ->
