 				, 3000
 
 		$(window).on 'productAddedToCart', =>
-			@getData().success (data) =>
-				@updateCart(data)
+			@updateData().success =>
+				@updateCart()
 				$(window).trigger "cartUpdated", [null, true]
 
-	getData: =>
+	updateData: =>
 		$.ajax({
 			url: @getOrderFormURL()
 			data: JSON.stringify(expectedOrderFormSections: ["items", "paymentData", "totalizers"])

			# console.log "Error Message: " + textStatus
			# console.log "HTTP Error: " + errorThrown

	updateCart: (data) =>
		data or= @cartData
		@updateValues data
		@updateItems data

	updateValues: (data) =>
		return unless data

		total = 0
		for subtotal in data.totalizers when subtotal.id is 'Items'
			total += subtotal.value

		$(".vtexsc-text", @context).text(@valueLabel(total))

	updateItems: (data) =>
		return unless data

		container = $(".minicartListContainer", @context).empty()
		for item, i in data.items
			current = @base.clone()

			current.find('.cartSkuImage a').attr('href', item.detailUrl)
			current.find('.cartSkuImage img').attr('alt', item.name).attr('src', item.imageUrl)
			current.find('.cartSkuName a').attr('href', item.detailUrl).text(item.name)
			current.find('.cartSkuName .availability').text(@availabilityMessage(item)).addClass("availability-#{@availabilityCode(item)}")
			current.find('.cartSkuPrice .bestPrice').text(@valueLabel(item.price))
			current.find('.cartSkuQuantity .cartSkuQttTxt').text(item.quantity)

			current.appendTo(container)

				# console.log "Error Message: " + textStatus
				# console.log "HTTP Error: " + errorThrown

	getValueLabel: (value) =>
		@options.valuePrefix + _.formatCurrency(value/100, @options) + @options.valueSufix

	getAvailabilityCode: (item) =>
		item.availability or "available"

	getAvailabilityMessage: (item) =>
		@options.availabilityMessages[@getAvailabilityCode(item)]


#
