change price with tax to price without tax in My Cart

GK User
Tue Apr 09, 2013 9:05 pm
Hi again,
I have managed to change the price that is in red in eSport template to a price without tax (see my explainations). But this time I do not know how to change that in Mycart.
Can I have some help ?
I think it is in this place : /templates/gk_esport/html/mod_virtuemart_cart/default.php
But I really do not know what to touch (this time).
Thanks for your help.
User avatar
Expert Boarder

teitbite
Wed Apr 10, 2013 1:00 am
Hi

I do not know either :) Please send me an access to ftp and give me an url to the page with an example product and tell me which price is showing and which should be showing.
User avatar
Moderator

GK User
Wed Apr 10, 2013 11:38 am
Again an image much better than tons of words !!!
This is the price with tax (default on the template) I want pricewithout tax instead (128,01 €) for each product added but also for the total price in the cart.
Click on the image to see more.

I sent you teitbite the ftp informations by mail
Thanks for helping.

mycart.jpg
User avatar
Expert Boarder

GK User
Thu Apr 11, 2013 4:43 pm
I discovered yesterday that the total price at the bottom of My Cart is the total price that is with tax (+ shipment if logged in).
First I wanted to have this price without tax, but no need to change it. It is good like it is.
But it would be great if I could have in front of the total price in this cart something like : Total price including tax (in english), Prix total TTC (in french and other possible languages).
User avatar
Expert Boarder

teitbite
Thu Apr 11, 2013 6:34 pm
Hi

I've tracked the file responsible to a virtuemart core file. I really shouldn't be looking into not our products on this forum, but please send me an ftp so I'll try separate this part into our template and override.
User avatar
Moderator

GK User
Thu Apr 11, 2013 8:44 pm
I sent you a mail.
User avatar
Expert Boarder

teitbite
Fri Apr 12, 2013 1:11 am
Hi

Sorry, but I cannot figure out where the access is ;/ We've exchanged so many mails that I'm simply lost and cannot see access in there. Can You please send it one more time and an url to the site. So I'll have everything in one place and will not search for it again.
User avatar
Moderator

GK User
Fri Apr 12, 2013 7:01 am
I have just sent you another mail with a link to this topic
User avatar
Expert Boarder

teitbite
Sat Apr 13, 2013 9:57 am
Hi

Finally done. It required a lot of changes to make it show without tax, so I cannot publish it all here, but I'm attaching a file which needs to be replaced in /html/mod_virtuemart_cart/ folder .
User avatar
Moderator

GK User
Sat Apr 13, 2013 12:09 pm
Hi teitbite !
Thanks for your try.
Unfortunately, it does not work correctly, because the price that is shown is not the real "price without tax".
I had the same problem myself by dividing the "price with tax" by 1+ the tax amount (=1.196) and applied the round function in order to get the right price : 128,00.
here was my code line 88 :
Code: Select all
<div class="gkPrice num<?php echo $iteration%3; ?>"><?php echo str_replace(' ', '', round ($product['prices']/1.196,2)); ?></div>

original code being :
Code: Select all
<div class="gkPrice num<?php echo $iteration%3; ?>"><?php echo str_replace(' ', '', $product['prices']); ?></div>

But strangely it does not give the right result. In my case I have 127.93 instead of 123.00.
In your case we get 127.91 instead of 123.00.
I really do not understand the reason.

As I wrote in a previous post, no need to modify the global total price in MyCart, I just want to be writen in front of this price something like "Total price including tax" (in english), "Prix total TTC" (in french) and have the ability for other translations.

Any idea ?
User avatar
Expert Boarder

teitbite
Sat Apr 13, 2013 1:54 pm
Hi

Module has 2 values for price included:

1. Price with tax
2. Tax amount

What I did to present the price was: price_with_tax minus tax, so if this is not correct, than I believe the tax amount was not counted properly by VM.

I've added the text, but I do not have an access to language file to manage translations. Please add one to each language version for: "COM_VIRTUEMART_PRICE_WITH_TAX"
User avatar
Moderator

GK User
Sun Apr 14, 2013 4:23 pm
Thanks Teitbite, you made it (nearly).
The only bug is the price without tax miscalculation. I really wonder why we get a bad result.
And I am really sure it is a bug.
The VAT applied is 19.6%
The price without tax entered in virtuemart is 123.00 €
In virtuemart the price with tax is calculated and gives 153.088 € wich is rounded to 153.09.
These figures are correct, sure !

Is there another solution to show the price without tax ? Because it is impossible for me to leave that like it is.
Hope you can help (again).
User avatar
Expert Boarder

GK User
Sun Apr 14, 2013 4:56 pm
I tried to isolate the line that should give the price without tax.
I noticed that if 'prices' is alone, its result is 153.00 euros instead of 153.09 euros.
I changed this line :
Code: Select all
<?php $price = round( (float)str_replace(' ', '', $product['prices']-$product['subtotal_tax_amount']), 2 ); ?>

by this one :
Code: Select all
<?php $price = (float)str_replace(' ', '', $product['prices']); ?>

and the result given is wrong.
I do not know how 'prices' is calculated, but it is a wrong result (a rounded figure).
I hope this can help you.

hoh ! I forgot. there should be a comma (,) for the price withou tax, not a dot (.)
User avatar
Expert Boarder

teitbite
Mon Apr 15, 2013 11:13 am
Hi

Than I believe the error must be in VM Cart module. All I can do is to manipulate with numbers which are provided there. So if it's not correct than problem must be in VM itself. Please check if there is no information about this in VM forum.

To have a dot instead of comma, please the final value put into this function:

Code: Select all
str_replace(',', '.', $product['prices'])
User avatar
Moderator

GK User
Sun May 26, 2013 1:58 pm
Hi all,
For people looking to have a price without vat (tax) the my cart here is the correction I finally did. It was quite easy, but there are so many ways to do thing !:

look for this line (line 88 in default.php) :
Code: Select all
<div class="gkPrice num<?php echo $iteration%3; ?>"><?php echo str_replace(' ', '', $product['prices']); ?></div>

replace by :
Code: Select all
<div class="gkPrice num<?php echo $iteration%3; ?>"><?php echo number_format (round (str_replace(' ', '', $product['subtotal']),2),2); ?><?php echo $price; ?>€</div>

The problem with subtotal is that it is a brute price without tax like this : 128,0243246 for example.
I wanted to have a price like this one : 128,02 €
Here I have added the solution to have a rounded price with 2 digits with round(price,number of digits) and if you have a product with a price like 56,00, it would display only 56. As I wanted to have the price like this 56,00 I added the number_format (price,number of digits to appear afer comma). Just look through google to find information about round and number_format php command.
I also added <?php echo $price; ?>€ in order to get the € sign visible after the price without tax.

I hope that this can help anybody who was looking for that hack.
User avatar
Expert Boarder

teitbite
Tue May 28, 2013 7:16 am
Hi

Yes, that's exactly how should it be done. Thanks for sharing this explanation with others.
User avatar
Moderator


cron