News:

Support the VirtueMart project and become a member

Main Menu

An improvement to the customfieldsCart array

Started by balai, March 09, 2012, 14:31:49 PM

Previous topic - Next topic

balai

Hi

The generation of the customfieldsCart array that holds all the data about the custom fields which are Cart Attributes is really great.
The developer can use that array in the layouts, to modify completely how the custom fields are displayed.

Although there is a small  obstacle to that.
The custom_price element of the array has the initial price as set in the backend, without getting into consideration taxes, currencies etc.

I think that this can be solved easily.
In the file:administrator\components\com_virtuemart\models\customfields.php

We have to set the price calculation in the function getProductCustomsFieldCart that generates that array
so after every if ((float)$productCustom->custom_price ) we have to set a code like
$productCustom->custom_price=$currency->priceDisplay($calculator->calculateCustomPriceWithTax($productCustom->custom_price));





kona333

So what would I put in VM2 to do this? That version below just generated errors so I'm assuming it's pre-VM2.

Basically so that when you enter a price into the custom field in the backend, this includes tax and doesn't add it on the frontend, which is a massive pain trying to work out net prices when all you have is the incl tax.

Currently VM2 has:

               if ((float)$productCustom->custom_price) {
                  $price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($productCustom->custom_price)));
               }