Jump to content

Show cart total price in blockuserinfo header


Recommended Posts

Hi,

I'm trying to modify the blockuserinfo.tpl to show not only the number of products in cart but also the order total like this (before having mouse over):

 

Cart: $1150 (3)

 

where:

 

$1150 - is the order total

(3) - number of products in cart

 

Thanks.

Link to comment
Share on other sites

use this variable:

{displayPrice price=$cart->getordertotal(false)}

in blockuserinfo.tpl file located in your modules / blockuserinfo / blockuserinfo.tpl file

remember that this file also may exists in themes/yourtheme/modules/blockuserinfo/blockuserinfo.tpl - if so - you have to apply changes there

Link to comment
Share on other sites

I'm testing 1.5.4.1. Trying to migrate from 1.4.8 and I'm trying to customize the default theme a little bit.. I tried to add

 

[i]{if !$PS_CATALOG_MODE}
	<li id="shopping_cart">
		<a href="{$link->getPageLink($order_process, true)}" title="{l s='View my shopping cart' mod='blockuserinfo'}" rel="nofollow">{l s='Shopping bag:' mod='blockuserinfo'}
		<strong>

{$cart->getOrderTotal(true)}

 </strong>
		<span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span>[/i]

 

but the total price doesn't update if I remove an item from cart.

 

I have tried your above code and it works but doesn't update price also like my first method.

 

Thanks.

Link to comment
Share on other sites

but the total price doesn't update if I remove an item from cart.

you've got right, it is necessary to edit javascript ajax functions... For now i don't know where exactly but i can check this

 

to add ( 2 ) use the:

 

( <span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span> )

Link to comment
Share on other sites

Ok this works with the '()'. Which javascript ajax functions file needs to be modified and how to update blockuserinfo cart summary when an item is added or removed from cart?

 

Thanks for your help

Link to comment
Share on other sites

I would but as I was saying above I have prestashop 1.5.4.1 on a local webserver. It's not live. I'm trying to customize the new 1.5.4.1 so I can move from 1.4.8. What files do you want me to share?

Link to comment
Share on other sites

I asked because sometimes after upgrade this method doesn't work. Anyway, you should try with this:

 

for the first, you have to change the blockuserinfo.tpl once again.

add the:

<span id="cart_blockuserinfo">{displayPrice price=$cart->getordertotal(false)}</span>

instead the old code for price (mentioned few posts above)

 

then go to the: modules/blockcart/ajax-cart.js, you've got there something like:

 

 $('.ajax_cart_tax_cost').text(jsonData.taxCost);
 $('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
 $('.ajax_block_cart_total').text(jsonData.total);

 

right after this code, put this:

 

$('#cart_blockuserinfo').text(jsonData.total);

  • Like 1
Link to comment
Share on other sites

  • 8 months later...
  • 1 month later...

I asked because sometimes after upgrade this method doesn't work. Anyway, you should try with this:

 

for the first, you have to change the blockuserinfo.tpl once again.

add the:

<span id="cart_blockuserinfo">{displayPrice price=$cart->getordertotal(false)}</span>
instead the old code for price (mentioned few posts above)

 

then go to the: modules/blockcart/ajax-cart.js, you've got there something like:

 

  $('.ajax_cart_tax_cost').text(jsonData.taxCost);
  $('.cart_block_wrapping_cost').text(jsonData.wrappingCost);
  $('.ajax_block_cart_total').text(jsonData.total);
right after this code, put this:

 

$('#cart_blockuserinfo').text(jsonData.total);

 

that solution did not update the total price in  my presta 1.5.6.1

Link to comment
Share on other sites

  • 2 months later...

use this variable:

{displayPrice price=$cart->getordertotal(false)}
in blockuserinfo.tpl file located in your modules / blockuserinfo / blockuserinfo.tpl file

remember that this file also may exists in themes/yourtheme/modules/blockuserinfo/blockuserinfo.tpl - if so - you have to apply changes there

 

 

you can also use {displayPrice price=$total_price}

I did it this way just because of the comma delimiter. How to update the js file in order the total on the custom cart header to be updated before visiting another page? Thanx in advance

Link to comment
Share on other sites

  • 1 year later...

use this variable:

{displayPrice price=$cart->getordertotal(false)}
in blockuserinfo.tpl file located in your modules / blockuserinfo / blockuserinfo.tpl file

remember that this file also may exists in themes/yourtheme/modules/blockuserinfo/blockuserinfo.tpl - if so - you have to apply changes there

 

this solution is not working for me.

i`m using astra theme and its blockuserinfo.tpl file is empty

 

please tell me where can i apply your code to display total expense to customer on top header 

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...

Hello

 

With herezatajna solution i have the price in the cart.

But i have a problem.

The registered customers in my shop shows products without VAT.

So in the cart header i have the total price without VAT.

Is it posible to have the real total price? I mean with VAT.

Link to comment
Share on other sites

×
×
  • Create New...