News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to show original price, discounted price and discount amount - HACK

Started by adrianpaun, April 12, 2012, 04:12:50 AM

Previous topic - Next topic

adrianpaun

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]



adrianpaun

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.

szeor


adrianpaun

This hack is for the virtuemart first page products, for detailed product it's other hack, i will post them today.


szeor

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


vagu71

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

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

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