Hello,
how can i display prices without tax in vm cart module?
thanks
You need to do a lot of changes to get this to work
I suggest you might want to look at a third party cart module in the first instance.
thank you for answare.
If i whould like to do it myself, which files i have to analize?
Create an override of the cart template display
templates/YOURTEMPLATE/html/mod_virtuemart_cart/default.php
Then adjust the JS to get the cart total price to update correctly
/modules/mod_virtuemart_cart/assets/js/update_cart.js
Note that the JS will get overwritten every time you update!!!
Thank you AH for your help,
I think I'm on the right track. I'm editing the file plugins/system/vm2_cart/vm2_cart.php
at row 104 i'm adding this code:
$data->products[$i]['pricesWithoutTax'] = $currency->priceDisplay($product->allPrices[$product->selectedPrice]['priceWithoutTax']);
and in my default.php i print this code:
<?php echo $product["pricesWithoutTax"]; ?>
and it works! but Ajax doesn't work....i need to press F5 to see the right result.
I think I have to add the new variable even in some other files.
The file is not update_cart.js because i try to rename it but Ajax it works the same
plugins/system/vm2_cart/vm2_cart.php
this is a 3rd party extension over riding the VM core files.. why not ask the developer..
As GJC noted - you are using a third party extension and my hints are pointless
Talk to the developers
can you tell me in which file the variable $cart is created?
helpers/cart.php but do u really want to go down this route?
if your tax is standard i.e. always say 20% what about a simple -20% calc in the module display
I thought about it too. but unfortunately, the VAT rate is not always the same.
I feel I am on the right way, because in Ajax get, my new variable is present (i check with firebug).
This is Ajax call:
http://localhost/telshopnew/index.php?option=com_virtuemart&nosef=1&view=cart&task=viewJS&format=json&lang=it&_=1462276233894
{"products":[{"product_cart_id":0,"product_name":"<a href=\"\/telshopnew\/index.php\/home\/ricambi-per-cellulari-e-tablet
\/fla11065s-detail.html\" >FLA1106E<\/a><\/br>Codice : FLA11065S","product_attributes":"<div
class=\"vm-customfield-mod\"><\/div>","product_sku":" FLA11065S","prices":"\u20ac. 4,92"
,"pricesWithoutTax":"\u20ac. 4,04","subtotal":8.0712,"subtotal_tax_amount":1.77566,"subtotal_discount"
:0,"subtotal_with_tax":9.84686,"quantity":"2 x ","image":"<img src=\"http:\/\/localhost\/telshopnew
\/images\/stories\/virtuemart\/product\/resized\/fla11065s.jpg\" \/>"}],"totalProduct":2,"billTotal"
:"<div class=\"total2\"><span>Totale:<\/span><strong>\u20ac. 9,85<\/strong><\/div>","taxTotal":"<div
class=\"total3\"><span>Tasse:<\/span><strong>\u20ac. 1,78<\/strong><\/div>","discTotal":"<div class
=\"total4\"><span>Sconto:<\/span><strong>\u20ac. 0,00<\/strong><\/div>","cart_empty_text":"il tuo carrello
\u00e8 vuoto!","cart_recent_text":"Prodotti nel carrello","cart_remove":"Elimina","dataValidated":false
,"totalProductTxt":"<span class=\"cart_num\"><span class=\"art-text\">Carrello<\/span><a href=\"#cart-toggle
\"><i class=\"fa fa-shopping-cart\"><\/i>2 Prodotti<\/a><\/span>","cart_show":"\r\n\t\t\t<form id=\"cart_post
\" action=\"\/telshopnew\/index.php\/checkout.html\" method=\"post\">\r\n\t\t\t<button type=\"submit
\" name=\"bascket\" value=\"true\" class=\"button reset\">vai al carrello<span> <\/span><\/button
>\r\n\t\t\t<\/form>\r\n\t\t\t<a class=\"button\" href=\"\/telshopnew\/index.php\/checkout.html\">Checkout
<\/a>"}
You can see "pricesWithoutTax":"\u20ac. 4,04" but I can not figure out what is the script that reads this data
either can we because its not a standard module
but somewhere there will be a json_decode($somevar) that turns it back into a php object
I found a solution even if it is not the best but it works.
in plugin file vm2_cart.php
original code:
$data->products[$i]['prices'] = $currency->priceDisplay($product->allPrices[$product->selectedPrice]['salesPrice']);
My code:
$data->products[$i]['prices'] = $currency->priceDisplay($product->allPrices[$product->selectedPrice]['priceWithoutTax']);
Now i need to know if shoppergroup display final price with tax or without tax like this:
if ($product->prices['priceWithoutTax']>0) {
$data->products[$i]['prices'] = $currency->priceDisplay($product->allPrices[$product->selectedPrice]['priceWithoutTax']);
} else {
$data->products[$i]['prices'] = $currency->priceDisplay($product->allPrices[$product->selectedPrice]['salesPrice']);
}
i get this condition "$product->prices['priceWithoutTax']>0" from product list file, but it does not work.
How can i do it?
thanks