News:

Support the VirtueMart project and become a member

Main Menu

show original price, discounted price and discount percentage

Started by arie, January 10, 2012, 14:24:45 PM

Previous topic - Next topic

Genius WebDesign

Update..

After a quick reinstall and re-walkthrough of this thread I finally made it work as intended.

efi

Open your template file: default.php in your template folder /com_virtuemart/category/


There is no path like this one.
I am using joomla 1.5.26 and virtuemart 2.0.6

can you please help me?

rafitalx

Quote from: adrianpaun on April 12, 2012, 01:42:26 AM
I've finaly found a solution for productdetailed discount show with the baseprice, the new price (with discount) and the discount ammount.

First of all we need to activate in the virtuemart back-end in Configuration - > Pricing : Baseprice, Salesprice without tax, Final salesprice and Discount amount

What we will do is to create two pages for displaying the product detailet view, so first thing first:

1. Copy from component/com_virtuemart/views/productdetails/tmpl/default.php to  your template to make an override template for vm2: templates/your_template/html/com_virtuemart/productdetails/default.php

2. Edit this page

3. Find this code:


// Product Price

if ($this->show_prices and (empty($this->product->images[0]) or $this->product->images[0]->file_is_downloadable == 0)) {

    echo $this->loadTemplate('showprices');

}

?>


4. Replace it with this one wich  (you will find the full form in component/com_virtuemart/views/productdetails/tmpl/default_showprices.php if you need other strings)


// Product Price

if ($this->show_prices and (empty($this->product->images[0]) or $this->product->images[0]->file_is_downloadable == 0)) {

    ?>

//mod
//the standard line was <div class="product-price" id="productPrice<?php echo $this->product->virtuemart_product_id ?>">
//i've change the <?php echo $this->product->virtuemart_product_id ?> to class insead of id and create a unique id for this one calld productPriceDiscount (for css ussage)

<div class="product-price-detailed<?php echo $this->product->virtuemart_product_id ?>" id="productPriceDiscount">

//END mod

    <?php

    
if ($this->product->product_unit && VmConfig::get('price_show_packaging_pricelabel')) {

echo "<strong>" JText::_('COM_VIRTUEMART_CART_PRICE_PER_UNIT') . ' (' $this->product->product_unit "):</strong>";

    } else {

echo "<strong>" JText::_('COM_VIRTUEMART_CART_PRICE') . "</strong>";

    }

    if (empty(
$this->product->prices) and VmConfig::get('askprice'1)) {

?>


        <a class="ask-a-question bold" href="<?php echo $url ?>" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ASKPRICE'?></a>

    <?php

    
}

//mod
// i've put baseprice, salesprice and discountamount to be shown.

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

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

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

//END mod
    
?>


               

</div>

<?php }

?>




6. We need to modify the css file so we have to add:


.PricediscountAmount{color:#FF0000;}
#productPriceDiscount { font-size:48px; letter-spacing:-2px; line-height:42px;border: 1px solid #E9E8E8;border-radius: 12px 12px 12px 12px; text-align:center; padding:10px 0; font-weight:700; color:#0066FF; }
#productPriceDiscount .PricebasePrice {text-decoration:line-through;color:#666;}


7. After we did this we will save this page with the name default_discount.php

8. now edit again the new page default_discount.php:

Find


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

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

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


Replace it with:


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


9. Save this page under default.php

10. Go to Virtuemart Back-End -> Products -> Select a product you want to make a discount -> select on Product Details Page -> default_discount and then put your discount in product Pricing - Override and check the box.

This should be it and you cand update you're Virtuemart without losing youre modifications.



Hi .. is great code but do not act the custom field.
help me please

dream3w

Hi,

I've tried to make modifications as explain in these post but no good issue.

Is it possible to have some help to make that?

Im on J2.5.4 and VM2.0.6 (template Allrounder J1.6)

Greetings

Stephan
http://bike.dream3w.com

J1.7 - VM2.0 - JCE

dream3w

When I try to put code into currencydisplay.php, I've these result:

Notice: Undefined variable: vis in /homez.141/..../currencydisplay.php on line 366

What's wrong?
http://bike.dream3w.com

J1.7 - VM2.0 - JCE

MNCZ

I've also wanted to do the same thing.  I've followed tobisagt's instructions and it works.  However I have some problems with the formatting.

What I get is this:

Price:10
Sales price:       Discount: $1.00
$9.00

What I would like to see is this:

Price:$10.00
Sales price: $9.00      
Discount: $1.00

Can anyone help me please?

mushino

Prices in default_products.php and other are showed as string. I have try to convert them as float or integer number but it seem impossible.
How we can extract prices as number?
In this case we can calculate discount percentage and show it.
Any idea?

Genius WebDesign

QuotePrices in default_products.php and other are showed as string. I have try to convert them as float or integer number but it seem impossible.
How we can extract prices as number?
In this case we can calculate discount percentage and show it.
Any idea?

Read this:  http://forum.virtuemart.net/index.php?topic=103195.msg346799#msg346799

and this:  http://forum.virtuemart.net/index.php?topic=104194.msg346625#msg346625

giupi

Hello,

can someone kindly make a summing up on how to get original price (barred), new price and discount (% or even only the amount off)?

In this post are several suggestions, but for every there something I can't get:

1) In the first reply of tobisagt I did not find in default.php in template folder /com_virtuemart/category/ the line: echo $this->currency->createPriceDiv ( 'basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices ); it seems that it's nowhere...

2) adrianpaun proposed a way, but at his point number 6 I did not understand what css to modify, and at his point 7 (save this page with the name default_discount.php) I did not understand which page to save... seems the css...????

3) all questions and answers are overlapping so you don't understand who's answering who...

Since I searched over the seven seas ;-) both this forum and italian forum for a solution, without getting any success, I would be very grateful to whoever could make a summing up (and possibily definitive) for getting the solution :-D

I would be also buy a kind of module/plugin if available...

Thank you in advance.

Genius WebDesign

@giupi

If you want to you can do it the easy way by just echo' ing the price-values and making your own if-statements.
Read these posts, they pretty much cover all you need to make it the way you want;

http://forum.virtuemart.net/index.php?topic=103195.msg346799#msg346799

http://forum.virtuemart.net/index.php?topic=104194.msg346625#msg346625


giupi

Hello fabelmilk,

thank you for your answer... that's very kind of you, but I still didn't understand  :-[

In this post http://forum.virtuemart.net/index.php?topic=104194.msg346625 I don't understand what you have to do (practically) to get the result...

In the other post http://forum.virtuemart.net/index.php?topic=103195.msg346799#msg346799 in which position of default.php file do you have to put the code? Again: in the first part of the post you say that with this solution you still get an error, and in the second part (I suppose) you explain how to get rid of it by applying a code... but where ????

Sorry to bother you, but I'm very confused and lost in the tens of posts apparently one different from the other... do you mind to make a step by step summing up as you should explain to a child? :-D

Thank you...

vigier

Thnx adrianpaun for your code! I used some of it, and now my pages look a lot more attractive :)

Kind regards, Vigier

Genius WebDesign

Hi giupi,

Sorry for replying this late..
If you like you can send me an email with all of your info, then I can customize everything for you the way you want it to be.

You can contact me on webmaster@traeogbyg.dk

Genius WebDesign

Also you can see an example of how I have designed the product details page on one of my projects, here:

(This site is in "coming soon" phase, so you need to follow these two links)

1. http://www.traeogbyg.dk?adgang=1     - (copy/paste the entire link in your browser)
and
2. http://www.traeogbyg.dk/index.php/produkter/hytter-og-redsskabsskure/garager-carporte/jabo-dobbeltgarage-422-details