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

Round discount price

Started by pm4698, July 12, 2014, 12:01:00 PM

Previous topic - Next topic

pm4698

Hello there,

I am trying to make decimals disappear from discount price with no success. I also tried round function with no success also. (when i try round function the discount value is set to zero).

Any ideas?

Thank you in advance

jenkinhill

Only the discount price? What VM version? Are you using template overrides?
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

pm4698

Yes only discount price.

I use joomla 2.5.x and VirtueMart 2.6.2.

I have modified administrator/components/com_virtuemart/helpers/calculationh.php in order to show discount as percentage and not value

I use template override and in there i use this code to display discount price:

$varsmine=$this->currency->createPriceDiv ('discountAmount', '', $product->prices);
$newcurr= str_replace(chr(0xE2).chr(0x82).chr(0xAC), '', $varsmine);
$newcurr2=str_replace(',00','%',$newcurr);?>
                    <div style="width:70px;">
<?php echo  $newcurr;
?>

                        </div>


As you can see I echo discount after i have replaced Euro sign (chr(0xE2).chr(0x82).chr(0xAC)) with blank. Then with $newcurr2 i try to remove the decimals and replace with % value. If i do this and i echo newcurr2 then nothing happens. I see the same thing as echoing $newcurr

GJC Web Design

works fine here

$newcurr='200,00';
print 'Debug Line '.__LINE__.' $newcurr <pre>'; print_r ($newcurr); print "</pre><br />\n";
$newcurr2=str_replace(',00','%',$newcurr);
print 'Debug Line '.__LINE__.' $newcurr2 <pre>'; print_r ($newcurr2); print "</pre><br />\n";


Debug Line 30 $newcurr

200,00


Debug Line 32 $newcurr2

200%

are you using a comma as a decimal  - I would assume within calculationh.php  a point is being used as that is normal

try


$newcurr2=str_replace('.00','%',$newcurr);
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

pm4698

I tried with . and not comma but still if i echo newcurr2 its the same as newcurr.

Actually, my discount values are not rounded. I have for example: 12,01 or 15,09 etc. So, maybe thats why str_replace doesn't work because i have no .00 at my string. So, how could i round up my discount price and then try again the str_string?