Ok as I said your help was valuable. It actually set me on the right track.
So the file that should be edited is indeed the one I mentioned in my previous post
- Code: Select all
/components/com_virtuemart/sublayouts/customfield.php
Best way to go is to create a template override so you could copy the original file to
- Code: Select all
/templates/[your template]/html/com_virtuemart/sublayouts/customfield.php
Then you may go to the line 310 (give or take a few lines depending on the virtuemart version you use) and look for the if clause that is:
- Code: Select all
if($customfield->wPrice){
There is the generation of the customfield's price inside the parenthesis. I changed the whole if clause and added a bunch of things:
- Code: Select all
if($customfield->wPrice){
//$product = $productModel->getProductSingle((int)$child['virtuemart_product_id'],false);
$productPrices = $calculator->getProductPrices ($productChild);
if($product->prices['discountedPriceWithoutTax'] != $productPrices['discountedPriceWithoutTax']){
$priceStr = ' (' . $currency->priceDisplay ($productPrices['discountedPriceWithoutTax']) . ')';//Normally here it's salesPrice (including VAT) but we need the price without VAT. However if there is a discount we should display that price. Instead of priceWithoutTax which would not work properly displaying the price without VAT, for discounted products I used discountedPriceWithoutTax which is equal to priceWithoutTax when there is no discount applied.
}
else{
$priceStr = ''; //I made this if clause so that if the child product price is different from the parent product, only then I will see a price in a parenthesis in the dropdpown. Just a bit of impressive code work on my part.
}
}
I've included all my original comments to make the code clearer.
So what I did was to add a second if clause to check whether the child product has a different price that the one that is being displayed. Only when there is a price difference should the dropdown display prices in parentheses.
I also used the DiscountedPriceWithoutVAT global variable, to make the comparisons and price display cause I needed to show wholesale prices. However you may use any price that is convenient to you.
Also this way you get the discounted prices displayed on products on sale.
Hope that was helpful.