News:

Looking for documentation? Take a look on our wiki

Main Menu

Only show original and sales price if there is a discount?

Started by modernmagic, September 01, 2023, 08:37:54 AM

Previous topic - Next topic

modernmagic

J4.3.3
VM4.0.12

I cannot figure out how to only show the 2 prices when there is a discount.

See attached.

The product on the left has a discount, so we want to show the original price. 
The product on the right does NOT have a discount, so we only want to display the price once.


GJC Web Design

From memory unless some tax is applied the logic in components\com_virtuemart\sublayouts\prices.php for displaying the sales price is wrong

You need to adjust it there in the code via an over ride
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

modernmagic

Interesting, seems like a major flaw that would cause confusion and looks unprofessional.

Anyone else already fix this and can supply the revised code?

sirius

Hi,
I simply use
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
J3.10.12 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.12.10777

modernmagic

Quote from: sirius on September 04, 2023, 17:32:15 PM
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {

That line is already in prices.php as shown here:
//echo $currency->createPriceDiv ('salesPriceQu', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
echo $currency->createPriceDiv ('discountedPriceWithoutTaxTt', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX_TT', $product->prices);
} else {
echo $currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
echo $currency->createPriceDiv ('priceWithoutTaxTt', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX_TT', $product->prices);
}
echo $currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
echo $currency->createPriceDiv ('discountAmountTt', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT_TT', $product->prices);
echo $currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
echo $currency->createPriceDiv ('taxAmountTt', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT_TT', $product->prices);
$unitPriceDescription = vmText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', vmText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.strtoupper($product->product_unit)));
echo $currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
}


Did you edit anything else? 

sirius

ok
in the case of your "Trim - Textured Slatwall" the "Total without tax:" is use.
but in the "Old Paint White Brick Slatwall" this is the "Sales without tax:".
So those are not the same prices type called.
you must hide the "Sales without tax:" in all case. (if you do not need it at all for sure)
//echo $currency->createPriceDiv ('priceWithoutTaxTt', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX_TT', $product->prices);
And so you will only have two prices in case of a discount.
J3.10.12 | PHP 7.4.33 + APC + memcached + Opcode
VM Prod : 3.8.6 | VM Test : 4.0.12.10777