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

szeor

  • Beginner
  • *
  • Posts: 22
Re: show original price, discounted price and discount percentage
« Reply #60 on: February 15, 2013, 09:38:32 am »
hi AbsoluteVM, doesn't work, but ty. 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

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: show original price, discounted price and discount percentage
« Reply #61 on: February 15, 2013, 15:49:07 pm »
Did you use it on a category page or a product page?

On a product page, $this->product is correct.. On other pages, just use $product->..

Alberto87

  • Beginner
  • *
  • Posts: 28
Re: show original price, discounted price and discount percentage
« Reply #62 on: March 25, 2013, 14:05:25 pm »
Hello,

I write here, I have open a topic but nobody reply to my question, I hope you can help me.

In my e-commerce i need to display in category view the % of discount from the original price, if i apply a discount from the product page there aren't problem, all work perfect, in category view  i see 3 fields :

1- sell price with discount
2- Original price
3- percent of discount.

but if I create a rule or tax with a discount  of 15% for a category, change only the sell price and I don't see the discount % or other fields,  :-\ ... have you any clue to view the Original price and percent of discount ?

Viertumart 2.0.2 and Joomla 2.5.8

my default.php in category folder

Code: [Select]
<?php

if ($this->show_prices == '1') {

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

echo "<strong>"JText::_('COM_VIRTUEMART_CART_PRICE_PER_UNIT').' ('.$product->product_unit."):</strong>";
echo $this->currency->createPriceDiv('discountedPriceWithoutTax','COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE',$product->prices);

}



//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('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);

                      
if (!strstr($this->currency->createPriceDiv'discountAmount',''$product->prices ), 'none')){ echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);
 

if (
$this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices))
{
$discount=$this->currency->formatNumber($product->prices['discountAmount']);
$pricewithtax $this->currency->formatNumber($product->prices['basePriceWithTax']);
$total =($discount 100) / $pricewithtax;

                                 echo 
"Save: " .number_format$total2) ."%";

}
 
}


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


?>

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Re: show original price, discounted price and discount percentage
« Reply #63 on: May 16, 2013, 11:43:57 am »
Or.. even simpler method

Code: [Select]
if ($product->prices['DATax']['2']['2'] == "-%") {

$discount = round($product->prices['DATax']['2']['1']);
echo '<div class="PricediscountAmount"><span class="PricediscountAmount">'.$discount."%".'</span></div>';
}
else {
echo $this->currency->createPriceDiv ('discountAmount', '', $product->prices);
}

$product->prices['DATax']['2']['2']  returns discount type
$product->prices['DATax']['2']['1']  discount amount

Works on VM 2.0.20b

johnknit

  • Beginner
  • *
  • Posts: 8
Re: show original price, discounted price and discount percentage
« Reply #64 on: May 29, 2013, 15:46:34 pm »
I am looking for a way to display all quantitie prices on the productdetails page.
We have different prices for different quantities.

I tried several things on the default_showprices.php
but nothing worked.

How can that be done

nerfmarius

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 14
Re: show original price, discounted price and discount percentage
« Reply #65 on: May 30, 2013, 08:58:37 am »
Try printing out all product prices print_r($product->prices); and see if you have all those prices there. Then echo only what you need.

karuppiah

  • Beginner
  • *
  • Posts: 38
Re: show original price, discounted price and discount percentage
« Reply #66 on: July 30, 2013, 12:30:44 pm »
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.
karuppiah

karuppiah

  • Beginner
  • *
  • Posts: 38
Re: show original price, discounted price and discount percentage
« Reply #67 on: July 30, 2013, 12:37:40 pm »
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.
karuppiah

Marttyn

  • Jr. Member
  • **
  • Posts: 110
Re: show original price, discounted price and discount percentage
« Reply #68 on: August 16, 2013, 10:33:12 am »
I have 2 customers: retail and wholesale.
As discount for wholesale is not always the same i had to make 2 prices for each product, one for retail, and other for wholesale.
Now i would like the wholesalers to see retailers price crossed and their price bellow, so they see the the benefit of being wholesaler.
How can i call the retail price when the client is loged in as wholesale?
Im guessing that is achieved in currencydisplay.php, and i should be doing an extra querry to the DB with the retail shopper group. But seems quite intrepid such a modification!
Any advise?

zakgr

  • Beginner
  • *
  • Posts: 8
Re: show original price, discounted price and discount percentage
« Reply #69 on: August 19, 2013, 18:22:31 pm »
EDIT by Mod Maxim (reason -  Copyright Violation)

Isn't 'Yag' prefix of Yagendoo?

Read attentively that sticked thread about Commercial templates in current forum section!

Marttyn

  • Jr. Member
  • **
  • Posts: 110
Re: show original price, discounted price and discount percentage
« Reply #70 on: August 19, 2013, 20:39:37 pm »
I have 2 customers: retail and wholesale.
As discount for wholesale is not always the same i had to make 2 prices for each product, one for retail, and other for wholesale.
Now i would like the wholesalers to see retailers price crossed and their price bellow, so they see the the benefit of being wholesaler.
How can i call the retail price when the client is loged in as wholesale?
Im guessing that is achieved in currencydisplay.php, and i should be doing an extra querry to the DB with the retail shopper group. But seems quite intrepid such a modification!
Any advise?

Ive found the solution for this, and ive wrote a post explaining how to get it done  8)
https://forum.virtuemart.net/index.php?topic=118057

burnego

  • Beginner
  • *
  • Posts: 4
Re: show original price, discounted price and discount percentage
« Reply #71 on: December 09, 2013, 13:12:28 pm »
Easier method:
just add
Code: [Select]
<?php echo $this->product->prices['salesPrice'?>in your template where you want the price to be shown and style it the way you want

veradantas

  • Beginner
  • *
  • Posts: 1
  • Skype Name: veradantas
Re: show original price, discounted price and discount percentage
« Reply #72 on: January 11, 2014, 11:35:05 am »
Thats exacly what i've done!

But you need a little bit Corehack! So backup your file!

Open: currencydisplay.php in administrator/components/com_virtuemart/helpers/

Search for the line:  vmdebug('createPriceDiv $name '.$name.' '.$product_price[$name]);

Copy and paste the following code after the line above

Code: [Select]
// ==
// START MODIFICATION
// ==

// Checks if there is a discount.
if ($name == "discountAmount" && $vis == "none")
{
// If discount is empty (discountAmount) (display: none) it gives you an empty string instead of <div>
return "";
}

// If you have an discount and want to show the Price with Tax
if ($name == "basePriceWithTax")
{
// Checks if there is a discount.
if(!empty($product_price['discountAmount']))
{
 // Discount exist: Show Price with Tax and with an extended CSS class
 $css = "red";
 return '<div class="Price'.$name.'" style="display : '.$vis.';" >'.$descr.'<span class="Price'.$name.' '.$css.'" >'.$product_price[$name].'</span></div>';
}
}

// ==
// END MODIFICATION
// ==

Next step:

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

Search for the line: echo $this->currency->createPriceDiv ( 'basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices );

Replace it with the following code: So the Price with Tax (old price) only show up if there is a discount.

Code: [Select]
if ($this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices)) {
    echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices); }

Thats all. Maybe you need to change the order of your pricelist in your template to show it as you want.

Hope that was helpful!



Hello!

thank you for this post, helped me a lot.
But I wonder if you could help me on anoder question.
After placing the code you provided the value of basePriceWithTax is presented with many decimal places, how can I make the value appear rounded.

Best Regards

Vera Dantas

admiss

  • Beginner
  • *
  • Posts: 35
  • VirtueMart Version: 2.0.26 d
Re: show original price, discounted price and discount percentage
« Reply #73 on: February 18, 2014, 15:45:58 pm »
This VM discount-ing is awful.
In admin Config - Pricing, I have thicked
Baseprice
Baseprice with Tax, but without discounts
Final salesprice
Discount amount

On product page
Cost price:2
Base price: 2 (App.no rule - I don't want to show TAXes, VATs)
Final price: 1.6 (Rule: Discount 20% - which is Price modifier before tax, -%)
Overwrite final: YES (and it is not shown)
And instead of %, you can see amount.

I've attached the result - this is how it should look??
I'm not an expert in coding,  I wouldn' t like to touch php files
Everyone writes different solution. Should I try every suggestion?
I am really sangry!  >:(

[attachment cleanup by admin]

lewwi

  • Beginner
  • *
  • Posts: 1
Re: show original price, discounted price and discount percentage
« Reply #74 on: May 22, 2014, 13:03:46 pm »
It was help to us to create the what we want. Thank you.
I would like to give you some additional option, if somebody wanted to show the formatted price replace that row:
 
Code: [Select]
return '<div class="Price'.$name.'" style="display : '.$vis.';" >'.$descr.'<span class="Price'.$name.' '.$css.'" >'.$product_price[$name].'</span></div>';
to that

Code: [Select]
return '<div class="Price'.$name.'" style="display : '.$vis.';" >'.$descr.'<span class="Price'.$name.' '.$css.'" >'.$priceFormatted.'</span></div>';
Lew