News:

Support the VirtueMart project and become a member

Main Menu

How to add price on product details

Started by geniutrixone, November 17, 2014, 04:09:14 AM

Previous topic - Next topic

geniutrixone

Hello,

In my VM I have some products with discount and others products without discount. In the product details I need show the price with discount only when the product has a discount, otherwise I don't need show the price with discount.

VM has the option to show the price with discount and this option always show this price, if the product has not discount then the sales price is repeated as discount price.

I'm attaching 2 images, the first one show the product detail with discount and the second one show the product detail without discount.

I did reviewing the php code of VM but I did not found where I have to modify. I hope you can help me.

Regards.

[attachment cleanup by admin]

GJC Web Design

you have to make the changes directly in your template over rides - as you found the price displays are global settings
Have a look on here how to do template over rides and then just use some logic to only show a discount if there is a discount
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

geniutrixone

#2
Quote from: GJC Web Design on November 17, 2014, 12:56:43 PM
you have to make the changes directly in your template over rides - as you found the price displays are global settings
Have a look on here how to do template over rides and then just use some logic to only show a discount if there is a discount

But where exactly I have to make the changes? I tried modifiying components\com_virtuemart\views\productdetails\tmpl\default_showprices.php.

This is the correct file to modify or I'm wrong?

Thank you for your help.

p.s.: next is the code that I think I have to modify. (VM 2.6.6)
Quote
if ($this->product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and isset($this->product->images[0]) and !$this->product->images[0]->file_is_downloadable) {
      ?>
      <a class="ask-a-question bold" href="<?php echo $this->askquestion_url ?>" rel="nofollow" ><?php echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE') ?></a>
      <?php
   } else {
   if ($this->showBasePrice) {
      echo $this->currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $this->product->prices);
      if (round($this->product->prices['basePrice'],$this->currency->_priceConfig['basePriceVariant'][1]) != $this->product->prices['basePriceVariant']) {
         echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $this->product->prices);
      }

   }
   echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $this->product->prices);
   if (round($this->product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {
      echo '<span class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices) . "</span>";
   }
   if (round($this->product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $this->product->prices['salesPrice']) {
      echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices);
   }
       
        echo $this->currency->createPriceDiv('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_DISCOUNT', $this->product->prices);
        echo JText::_('COM_VIRTUEMART_PRODUCT_SALESPRICE_FINAL');
        echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices);
   if ($this->product->prices['discountedPriceWithoutTax'] != $this->product->prices['priceWithoutTax']) {
      echo $this->currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices);
   } else {
      echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices);
   }
   echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);
   echo $this->currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $this->product->prices);
   $unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', JText::_('COM_VIRTUEMART_UNIT_SYMBOL_'.$this->product->product_unit));
   echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $this->product->prices);

jenkinhill

You are already using template overrides so the file will most likely be [yourJoomlatemplate]/html/com_virtuemart/productdetails/default_showprices.php
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

geniutrixone

Quote from: jenkinhill on November 17, 2014, 21:53:36 PM
You are already using template overrides so the file will most likely be [yourJoomlatemplate]/html/com_virtuemart/productdetails/default_showprices.php

Thank you very much for your help jenkinhill, I did what I needed.

Best regards.

idor

Quote from: geniutrixone on November 18, 2014, 04:15:04 AM
Quote from: jenkinhill on November 17, 2014, 21:53:36 PM
You are already using template overrides so the file will most likely be [yourJoomlatemplate]/html/com_virtuemart/productdetails/default_showprices.php

Thank you very much for your help jenkinhill, I did what I needed.

Best regards.

Hello,

I have the same problem, could you please tell us the solution you found?
I would preciate If you could send here the code you included in the mentioned archive ([yourJoomlatemplate]/html/com_virtuemart/productdetails/default_showprices.php).

Thank you in advance!