Prices is shown in child product even when set not to be showen

Started by CentauriDK, October 29, 2015, 11:07:36 AM

Previous topic - Next topic

CentauriDK

I have discovered a small bug in VirtueMart.
I had a customer who wanted at shop where onley registered users would be able to see the prices wich was verry easy done with Shopping Groups.
Under Configuration / Pricing disables all check marks except the first "Show Prices"
and then under Orders & Shoppers / Shopping Groups i made changes to the Default Shopping Groupe to show the needed prices
And also left the Guest Shopper Group empty so that they cant see prices.

Everything looks at first  right only users who is logget ind can see the prices but onley with single products.
But then a product have Child products so that the have to be chosen in the drop down menu then the price is shown together with the product name in the drop down menu for both users whu is logget ind and the ones who is not.
So some how their must be an small error ther.

I have made a temporarry solution on my site by editing
\components\com_virtuemart\sublayouts\customfield.php
Line 264
$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id']), 'text' => $child[$customfield->customfield_value].$priceStr);

And replaced it with
$user =&JFactory::getUser();
if ($user->id) {
$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id']), 'text' => $child[$customfield->customfield_value].$priceStr);
} else {
$options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id']), 'text' => $child[$customfield->customfield_value]);
}


Not the right way to do it but was the onley way i know how to do it.

So i hope thay could be hixed in an newer release.


jromano

Debian
VirtueMart 3.0.12
PHP 5.4.41

Your fix did not work for me since it indicated changes to the customfileld.php file to a line (264) does not match -- there is a close match (line 273) but when I applied your changes the child drodown only showed a number (specifically "2" for all the children) with a bunch of spaces

--------------

Child/variant selections for items that are in a sales-group (wholsale) but the user (guest actually) isn't in the wholesale sales-group -- can be seen with its price but it can be selected but the "Base" Price, description, etc. does not update - it keeps the info that first showed (parent), or the last successful child selection info; and then is the item that is added to cart if you can click add.

Milbo

We need to write the fix in the function, which calculates the price, imho in the /models/customfields.php function _getCustomPrice

the function, which considers the shoppergroups is createPriceDiv, So this check

if(!empty($this->_priceConfig[$name][0])   (currencydisplay.php line 313)

must somehow be done in _getCustomPrice
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/