News:

Looking for documentation? Take a look on our wiki

Main Menu

Trying to locate JS that updates cart module prices

Started by Genius WebDesign, October 29, 2014, 21:31:23 PM

Previous topic - Next topic

Genius WebDesign

Hi,

My client has a shop that is primarily for business customers, so he wants to show all prices "without tax", also in the cart module.
Out of the box there are no option to set the the cart module to show prices without tax, so I guess I need to locate the JS responsible for updating the cart prices.

Can anyone tell me which JS file I need to look into for this?

AH

I am using VM2.9 - but this should be VERY similar for 2.6 versions as well

You can show prices without tax

But you have to do a template override to: \modules\mod_virtuemart_cart\tmpl\default.php

<div class="subtotal_with_tax" style="float: right;"><?php echo $product['subtotal_with_tax'] ?></div>
becomes
<div class="subtotal_with_tax" style="float: right;"><?php echo $product['subtotal'] ?></div>


This leaves you with the issue that there is no Cart total variable that excludes tax for the minicart

In components/com_virtuemart/helpers/cart.php

function prepareAjaxData

$data->billTotal = $currencyDisplay->priceDisplay( $this->cartPrices['billTotal'] );
        //Quorvia Provide ex-tax prices to minicart
        $data->billTotal_tax_amount = $currencyDisplay->priceDisplay( $this->cartPrices['taxAmount'] );
        $data->billTotal_net = $currencyDisplay->priceDisplay( $this->cartPrices['priceWithoutTax'] );
        $data->billTotal_discounted_net = $currencyDisplay->priceDisplay( $this->cartPrices['discountedPriceWithoutTax'] );
        //end

You can then change the \modules\mod_virtuemart_cart\tmpl\default.php
<?php echo $data->billTotal; ?>

To
<?php echo $data->billTotal_net; ?>

Hope this puts you on the right track

NOTE

The components/com_virtuemart/helpers/cart.php

Will get overwritten every time you upgrade VM

Regards
A

Joomla 4.4.5
php 8.1

Genius WebDesign

Thanks for the reply.

I dug a little deeper into the module PHP file and found out that the mini cart prices are generated from a plugin:
/plugins/system/vm2_cart/vm2_cart.php

In someone out there needs this in the future, here are the modifications I made in order to change the default prices to "Without Tax"

Locate this code:
$data->products[$i]['prices'] = $currency->priceDisplay( $this->_cart->pricesUnformatted[$priceKey]['salesPrice']);

And change it to:
if ($this->_cart->pricesUnformatted[$priceKey]['subtotal_tax_amount'] > 0) {
$data->products[$i]['prices'] = $currency->priceDisplay( $this->_cart->pricesUnformatted[$priceKey]['salesPrice'] - ($this->_cart->pricesUnformatted[$priceKey]['subtotal_tax_amount'] / $product->quantity)  );
      } else {
      $data->products[$i]['prices'] = $currency->priceDisplay( $this->_cart->pricesUnformatted[$priceKey]['salesPrice']);
      }


And locate this code:
$data->billTotal = $currency->priceDisplay( $this->_cart->pricesUnformatted['billTotal'] );

And change it to:
if($this->_cart->pricesUnformatted['billTaxAmount'] > 0) {
$data->billTotal = $currency->priceDisplay( $this->_cart->pricesUnformatted['billTotal'] - $this->_cart->pricesUnformatted['billTaxAmount'] );
} else {
$data->billTotal = $currency->priceDisplay( $this->_cart->pricesUnformatted['billTotal'] );
}




GJC Web Design

Please note: there is no such plugin in a standard VM install - this plugin your talking about comes from some 3rd party extension (probably a OPC) or the template your using
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

as GJC said - my changes were for the core VM module

vm2_cart.php is a third party module
Regards
A

Joomla 4.4.5
php 8.1