Author Topic: show original price, discounted price and discount percentage  (Read 90558 times)

zczfwz

  • Beginner
  • *
  • Posts: 6
Re: show original price, discounted price and discount percentage
« Reply #75 on: May 27, 2014, 01:41:32 am »
In virtuemart 2.0 We can display discount percentage in two simple steps,

Step 1:
Open,administrator/components/com_virtuemart/helpers/calculationh.php,

Around line 352,you can find this line $prices['discountAmount'] = $this->roundInternal($basePriceWithTax - $salesPrice);

Replace with,$prices['discountAmount'] = $this->roundInternal(($basePriceWithTax - $prices['salesPrice']) * 100 / $basePriceWithTax);

here i am doing simple % calculation so the percentage of product will be shown like this for ex,$20.00

Step2:

In product detailed page or category pages,

To display default discount this code is used, $this->currency->createPriceDiv('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices);

Assign the variable for this code like,

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

to remove the currency symbol and decinal points use string replace like below,

$cuur1= str_replace('$(your currency symbol)','',$vars);
echo $cuur2= str_replace('.00','%',$cuur1);

Now the amount will be dsipalyed as percentage.

Hi karuppiah,

Thanks for you solution for adding discount percentage, I've tried and it works for non-children products, but I found it doesn't work with Child products (I used generic child variant).
I can see after loading the child product details page, the "%" shows in first couple of seconds but gets overwrite by "$" symbol eventually.
I guess there is some code elsewhere that load the "$" symbol again for child products.
Do you know where it is?

Thanks

szeor

  • Beginner
  • *
  • Posts: 22
Re: show original price, discounted price and discount percentage
« Reply #76 on: May 27, 2014, 15:17:09 pm »
hi, i m new to Joomla & Virtue Mart, i installed 1.5 Joomla & Virtuemart version 2.0.0

1) i want  the same, show original price, discounted price and discount percentage but its showing only Sales price & Discount in my website

2) Also i want to change the font color as below:
a) original price--i want font with strike with line-through
b) discounted price --- red & bold font
c) discount---------green font

do i need to change any CSS for this,

thanks, please help

firefox, firebug, right click, css path?

pm4698

  • Jr. Member
  • **
  • Posts: 156
Re: show original price, discounted price and discount percentage
« Reply #77 on: July 12, 2014, 11:26:14 am »
Hello there.

I used this method too and its not working 100%.

At the replace of currency symbol topic, if you have euro, try this:

$newcurr= str_replace(chr(0xE2).chr(0x82).chr(0xAC), '', $vars);

because otherwise Euro character is not recognized

So, if i echo $newcurr, then i can see my percentage, without % symbol and with decimals.
If i use the next line:

$newcurr2=str_replace(',00','%',$newcurr);?>

and echo $newcurr2 variable then my decimals are still there. I also tried round function with no success. Any idea of how to make decimals disappear?

Thank you in advance

wlaagewaard

  • Beginner
  • *
  • Posts: 17
Re: show original price, discounted price and discount percentage
« Reply #78 on: October 17, 2014, 13:03:34 pm »
my price is still zero in reply to the post of inopia

OriyanJ

  • Jr. Member
  • **
  • Posts: 83
  • A beginner
Re: show original price, discounted price and discount percentage
« Reply #79 on: February 02, 2016, 08:43:01 am »
Whenever I change quantity, crossed price disappears. Any thoughts?
VirtueMart 3.2.2

xenofon360

  • Beginner
  • *
  • Posts: 6
  • A beginner
Re: show original price, discounted price and discount percentage
« Reply #80 on: March 08, 2016, 12:32:41 pm »
Hi there guys,

I found this whole conversation here very  interesting and i've tested / combined almost all of the methods here in my VM e-shop but i still got a problem.
The problem is that i am using Joomla 3 with virtuemart 3 too and some of the coding lines in php files don't exist anymore, maybe they've been replaced or repealed.

I want my shop showing the price of the product like this : old price (deleted with a line)
                                                                                            base price
                                                                                            money saved

Also i want that to take action to the categories page and into the product page for each product.

If there is someone who can explain step by step the procedure for that i would be grateful !