VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: adrianpaun on April 12, 2012, 04:12:50 AM

Title: How to show original price, discounted price and discount amount - HACK
Post by: adrianpaun on April 12, 2012, 04:12:50 AM
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:


//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:


//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]
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor on April 22, 2012, 12:38:16 PM
This code doesnt work, does nothing :)
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: adrianpaun on April 25, 2012, 16:43:05 PM
You can see the live demo right here: http://jucarii.peacock.ro/produse/jucarii-cu-radiocomanda/avion-radiocomanda-detalii it work perfectly to me.
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: adrianpaun on April 25, 2012, 18:02:50 PM
I'll explain again:

For the default virtuemart first page page:

1. Edit: your_template/html/virtuemart/default_product.php
2. Find this code:
<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:
<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.
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor on May 01, 2012, 19:40:36 PM
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 (http://andrei.peacock.ro/produse/produse-medicale/pedometre/pedometrul-jog-style-32012-04-25-16-42-03_-detalii)
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: adrianpaun on May 02, 2012, 19:00:46 PM
This hack is for the virtuemart first page products, for detailed product it's other hack, i will post them today.
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor on May 02, 2012, 21:14:30 PM
Thank you. Im waiting for this.
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor on May 04, 2012, 19:31:05 PM
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
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: james007007hun on May 18, 2012, 00:50:10 AM
please send file

thx
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: vagu71 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
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor 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?
Title: Re: How to show original price, discounted price and discount amount - HACK
Post by: szeor 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