VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: geniutrixone on November 17, 2014, 04:09:14 AM

Title: How to add price on product details
Post by: geniutrixone on November 17, 2014, 04:09:14 AM
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]
Title: Re: How to add price on product details
Post by: 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
Title: Re: How to add price on product details
Post by: geniutrixone on November 17, 2014, 21:25:52 PM
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);
Title: Re: How to add price on product details
Post by: 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
Title: Re: How to add price on product details
Post by: 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.
Title: Re: How to add price on product details
Post by: idor on March 24, 2015, 17:54:55 PM
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!