Jump to content

block cart popup with how much to free ship


ruisonika

Recommended Posts

Hello i wanna achive this:
in blockcart tpl i've created a div to show how much it takes to get free shippemnt carrier (it is free after 49,00 euros of total products).

<div class="paraportesgratis unvisible"> 
   <span class="faltam">It remains <span id="semportes"></span> to 
         <span style="text-transform:uppercase; color:#94c23c;">free shippemnt</span>
    </span> 
</div>

Where span id is semportes it will be the value of the math like in figure i've posted. 
I've added the like to bring total products to #semportes in ajax-cart.js

//update general cart informations everywhere in the page
	updateCartEverywhere : function(jsonData){
		$('.ajax_cart_total').text($.trim(jsonData.productTotal));

		if (typeof hasDeliveryAddress == 'undefined')
			hasDeliveryAddress = false;

		if (parseFloat(jsonData.shippingCostFloat) > 0)
			$('.ajax_cart_shipping_cost').text(jsonData.shippingCost).parent().find('.unvisible').show();
		else if ((hasDeliveryAddress || typeof(orderProcess) !== 'undefined' && orderProcess == 'order-opc') && typeof(freeShippingTranslation) != 'undefined')
			$('.ajax_cart_shipping_cost').html(freeShippingTranslation);
		else if ((typeof toBeDetermined !== 'undefined') && !hasDeliveryAddress)
			$('.ajax_cart_shipping_cost').html(toBeDetermined);

		if (!jsonData.shippingCostFloat && !jsonData.free_ship)
			$('.ajax_cart_shipping_cost').parent().find('.unvisible').hide();
		else if (hasDeliveryAddress && !jsonData.isVirtualCart)
			$('.ajax_cart_shipping_cost').parent().find('.unvisible').show();

		$('.ajax_cart_tax_cost').text(jsonData.taxCost);
		$('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
		$('.ajax_block_cart_total').text(jsonData.total);
		$('.ajax_block_products_total').text(jsonData.productTotal);
      //THIS LINE BELLOW////////
		$('#semportes').text(jsonData.productTotal);
      ////////////////////////
        $('.ajax_total_price_wt').text(jsonData.total_price_wt);

ANY HELP?

result.jpg

Link to comment
Share on other sites

  • 3 weeks later...

If this is PS 1.7 I guess blockcart modal html is received via AJAX response, so you can't change it via "updateCartEverywhere". You should do this calculation in blockcart module controller and pass result as a smarty variable and display it inside blockcart template.

Link to comment
Share on other sites

I solved this way, in my themes/my_theme/js/modules/blockcart/ajax-cart.js (around line 816) i've added:

var x = 49;//this is the value of my shipping cost
		var y = parseFloat($(".ajax_block_products_total").text().replace(',', '.'));
		var z = x-y;
		//console.log(z);
		if (z > 0){
		   $('#paraportesgratis').removeClass("unvisible");
		}else{
		   $('#paraportesgratis').addClass("unvisible"); 
		}
		$('#semportes').html(parseFloat(z).toFixed(2));
		

The only thing that i can't get it is the result is for example 31.43 and i wanna 31,43 (change dot in a comma)...
        

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...