Author Topic: How to show original price, discounted price and discount amount - HACK  (Read 9758 times)

adrianpaun

  • Beginner
  • *
  • Posts: 32
I've just find the best solutions to show the original price, discounted price and the discount amount with no core file modifications so you can update virtuemart to feature updates without losing your modifications.

Here I go:

For the category layout please edit the default.php file:

1. Find the code:

Code: [Select]
//todo add config settings

if( $this->showBasePrice){

echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);

echo $this->currency->createPriceDiv('basePriceVariant','COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT',$product->prices);

}

echo $this->currency->createPriceDiv('variantModification','COM_VIRTUEMART_PRODUCT_VARIANT_MOD',$product->prices);

echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);

echo $this->currency->createPriceDiv('discountedPriceWithoutTax','COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE',$product->prices);

echo $this->currency->createPriceDiv('salesPriceWithDiscount','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT',$product->prices);

echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices);

echo $this->currency->createPriceDiv('priceWithoutTax','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX',$product->prices);

echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);

echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);

} ?>

2. Replace it with:

Code: [Select]
//todo add config settings

// MOD i've change the if( $this->showBasePrice) with if( $this->showPrice

if( $this->showPrice){

echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);

echo $this->currency->createPriceDiv('basePriceVariant','COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT',$product->prices);

}

                                                // MOD add a div id to style it in css with an line-through to old price

?>
                                               <div id="productPriceDiscountCategory">
                                               <?php

                                                
// MOD if discountAmount is bigger then 0 then it will show you the base price with the new div id with line-throught

if ($product->prices['discountAmount']>0) echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);
?>

                                                </div>
                                                <?php

echo $this->currency->createPriceDiv('variantModification','COM_VIRTUEMART_PRODUCT_VARIANT_MOD',$product->prices);

echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);

echo $this->currency->createPriceDiv('discountedPriceWithoutTax','COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE',$product->prices);

echo $this->currency->createPriceDiv('salesPriceWithDiscount','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT',$product->prices);

echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices);

echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);

echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);

?>


For the virtuemart first page (virtuemart/default_products.php make the same hack.

Enjoy.



[attachment cleanup by admin]

szeor

  • Beginner
  • *
  • Posts: 22
This code doesnt work, does nothing :)

adrianpaun

  • Beginner
  • *
  • Posts: 32
You can see the live demo right here: http://jucarii.peacock.ro/produse/jucarii-cu-radiocomanda/avion-radiocomanda-detalii it work perfectly to me.

adrianpaun

  • Beginner
  • *
  • Posts: 32
I'll explain again:

For the default virtuemart first page page:

1. Edit: your_template/html/virtuemart/default_product.php
2. Find this code:
Code: [Select]
<div class="product-price">
<?php
if (VmConfig::get 'show_prices' ) == '1') {
// if( $featProduct->product_unit && VmConfig::get('vm_price_show_packaging_pricelabel')) {
// echo "<strong>". JText::_('COM_VIRTUEMART_CART_PRICE_PER_UNIT').' ('.$featProduct->product_unit."):</strong>";
// } else echo "<strong>". JText::_('COM_VIRTUEMART_CART_PRICE'). ": </strong>";

if ($this->showBasePrice) {
echo $this->currency->createPriceDiv'basePrice''COM_VIRTUEMART_PRODUCT_BASEPRICE'$product->prices );
echo $this->currency->createPriceDiv'basePriceVariant''COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT'$product->prices );
}
echo $this->currency->createPriceDiv'variantModification''COM_VIRTUEMART_PRODUCT_VARIANT_MOD'$product->prices );
echo $this->currency->createPriceDiv'basePriceWithTax''COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX'$product->prices );
echo $this->currency->createPriceDiv'discountedPriceWithoutTax''COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE'$product->prices );
echo $this->currency->createPriceDiv'salesPrice''COM_VIRTUEMART_PRODUCT_SALESPRICE'$product->prices );
echo $this->currency->createPriceDiv'priceWithoutTax''COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX'$product->prices );
echo $this->currency->createPriceDiv'discountAmount''COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT'$product->prices );
echo $this->currency->createPriceDiv'taxAmount''COM_VIRTUEMART_PRODUCT_TAX_AMOUNT'$product->prices );
?>

</div>

3. Replace it with this one:
Code: [Select]
<div class="product-price">
<?php
if (VmConfig::get 'show_prices' ) == '1') {
// if( $featProduct->product_unit && VmConfig::get('vm_price_show_packaging_pricelabel')) {
// echo "<strong>". JText::_('COM_VIRTUEMART_CART_PRICE_PER_UNIT').' ('.$featProduct->product_unit."):</strong>";
// } else echo "<strong>". JText::_('COM_VIRTUEMART_CART_PRICE'). ": </strong>";

if( $this->showPrice){
echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);
echo $this->currency->createPriceDiv('basePriceVariant','COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT',$product->prices);
}
?>

                    <div id="productPriceDiscountFirstPage">
                    <?php

if ($product->prices['discountAmount']>0) echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);
?>

                    </div>
                    <?php
echo $this->currency->createPriceDiv('variantModification','COM_VIRTUEMART_PRODUCT_VARIANT_MOD',$product->prices);
echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);
echo $this->currency->createPriceDiv('discountedPriceWithoutTax','COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE',$product->prices);
echo $this->currency->createPriceDiv('salesPriceWithDiscount','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT',$product->prices);
echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices);
echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);
echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);
?>

</div>

4. Custom your css style for #productPriceDiscountFirstPage {} as you pleased.

Live example: http://andrei.peacock.ro/produse - i've removed the discountAmount because i didn't want to show it to my customer in default page.

szeor

  • Beginner
  • *
  • Posts: 22
i dont understand, your solution is wrong, because non promotional product price is double, i see the same price two...  :o
example:
http://andrei.peacock.ro/produse/produse-medicale/pedometre/pedometrul-jog-style-32012-04-25-16-42-03_-detalii

adrianpaun

  • Beginner
  • *
  • Posts: 32
This hack is for the virtuemart first page products, for detailed product it's other hack, i will post them today.

szeor

  • Beginner
  • *
  • Posts: 22
Thank you. Im waiting for this.

szeor

  • Beginner
  • *
  • Posts: 22
I delete everything, i installed new, fresh, 2.0.6 VM, and i use your code step by step, but nothing, doesnt work...
pls share your files...
thank you

james007007hun

  • Beginner
  • *
  • Posts: 3
please send file

thx

vagu71

  • Beginner
  • *
  • Posts: 6
Re: How to show original price, discounted price and discount amount - HACK
« Reply #9 on: October 17, 2012, 20:50:23 pm »
Hi Adrian,

It works good for the category page.

As a kind request, can you also post the steps for the product details page. Thanks in advance.

Look forward to your reply.

Varun

szeor

  • Beginner
  • *
  • Posts: 22
Re: How to show original price, discounted price and discount amount - HACK
« Reply #10 on: February 12, 2013, 12:21:39 pm »
So new version is 2.0.18, and developers failed... again :( Why? This thing is the default on the webshop, so i dont understand. Developers have seen the webshop?

szeor

  • Beginner
  • *
  • Posts: 22
Re: How to show original price, discounted price and discount amount - HACK
« Reply #11 on: February 15, 2013, 09:47:21 am »
My problem: this bug works only top ten products, featured products (maybe aio plugins?). Don't have (works good, i can see what I need) other page (categroy, product page, default vm). Idea? Thank you