VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on March 09, 2012, 14:31:49 PM

Title: An improvement to the customfieldsCart array
Post by: balai on March 09, 2012, 14:31:49 PM
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));




Title: Re: An improvement to the customfieldsCart array
Post by: kona333 on August 22, 2012, 08:14:10 AM
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)));
               }