News:

Support the VirtueMart project and become a member

Main Menu

How to hide the cart variants price in the option dropdown selector?

Started by joshuab, August 20, 2013, 19:17:42 PM

Previous topic - Next topic

joshuab

Does anyone know of a way to hide just the price on the option drop down for a custom field cart variant ( product-field-type-V )?

Ultimately this would be done so that the customer would only see the products updated price not the actual cost of the car variant. We want to give the impression that we are selling a complete product, not a base product with different upgrades. . .

I'm thinking it needs to be done through php. . . via css, I can see the 'span.product-field-display select option' but I don't know of a way to only hide part of the option description through css.

I've dug around the php files but I couldn't find anything relating to this specifically. So I'm either looking at the wrong files or I simply don't know what I'm actually looking for. . . Which the latter is probably the case since my php knowledge is very limited.

If anyone could point me in the right direction I'd be very grateful. . .

Joomla 2.5.14
VM 2.0.22a
PHP: 5.3.27

Joshua.

Maxim Pishnyak

Quote from: joshuab on August 20, 2013, 19:17:42 PM
I've dug around the php files but I couldn't find
Dug around forum search button and you could find it probably.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

joshuab

Maxim thanks for the tip. . . but that is always my first step to solving a problem with VM and I was unable to find anything that sounded like it related to my question already posted here on the VM forum. . .

If it's here somewhere and I'm just overlooking it then please inform me. . . a link or maybe better search terms would be gladly utilized.

joshuab

Okay I think I figured it out. With a bit more digging through more php files.

In the php file /administrator/components/com_virtuemart/models/customfields.php lines 971-983 looks like this:


static function _getCustomPrice($customPrice, $currency, $calculator) {

if ((float)$customPrice) {
$price = strip_tags ($currency->priceDisplay ($calculator->calculateCustomPriceWithTax ($customPrice)));
if ($customPrice >0) {
$price ="+".$price;
}
}
else {
$price = ($customPrice === '') ? '' :  JText::_ ('COM_VIRTUEMART_CART_PRICE_FREE');
}
return $price;
}


I just replaced this line:
  $price ="+".$price; 

with:
  $price = JText::_ ('COM_VIRTUEMART_CART_PRICE_HIDDEN'); 

And then ofcourse added a new 'Edit Override' in Joolma's Language Manager and it seems to be working.

If anyone sees any problems/ issues with this fix or know of a better solution please let me know. . . since this method will most likely have to be redone with each VM update.


duncan12

I had this same issue with VM 3.0.10 Here's how I solved it.

The file in question is components/com_virtuemart/sublayouts/customfield.php

Line 431 was:
                              $productCustom->text = $trValue.' '.$price;

I removed .$price, so it is now:
                              $productCustom->text = $trValue.' ';

I should mention that I don't know PHP at all, and this "seems" to work. Try at your own risk, and consider using an override if you'd like you change to stick around after VM upgrades.