Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Round Total to .50 during checkout

Round Total to .50 during checkout

Locked

Views: 1,295

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
1 Aug 2007, 8:39 PM
#1
breadfan avatar

breadfan

New Zenner

Join Date:
Jul 2007
Posts:
52
Plugin Contributions:
0

Round Total to .50 during checkout

Hi.

I need to round the Total price to .50. I will simply double the number, round it and then divide it by 2. It will give me the value I need. But I don't know where to place the code. I assume to put it to ot_total module, but I have no idea where and what. I am not very fluent in PHP and would like someone to write the line for me. I just need to modify the final total price so that instead of 1234.61 I'll get 1234.50.

Thank you in advance for any help.

1 Aug 2007, 9:39 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,659
Plugin Contributions:
0

Re: Round Total to .50 during checkout

Aren't your customers going to wonder what is going on with their total when it doesn't add up? ... not to mention the IRS

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

1 Aug 2007, 9:53 PM
#3
breadfan avatar

breadfan

New Zenner

Join Date:
Jul 2007
Posts:
52
Plugin Contributions:
0

Re: Round Total to .50 during checkout

No because it's not an American shop, but Slovak. Here, we have to round up total prices to .50. The government (or whoever it was) cancelled smaller coins ( .10, .20) because they cost more to produce than was their real value. We still use prices as 4.90 but in the end, the total is rounded to .50. It's perfectly normal here.

1 Aug 2007, 9:59 PM
#4
goodbuygail avatar

goodbuygail

New Zenner

Join Date:
Jul 2007
Posts:
77
Plugin Contributions:
0

Re: Round Total to .50 during checkout

Weird. Do you want people to be able to see the unrounded total until they go to checkout, or should the total displayed always be rounded.

1 Aug 2007, 10:13 PM
#5
breadfan avatar

breadfan

New Zenner

Join Date:
Jul 2007
Posts:
52
Plugin Contributions:
0

Re: Round Total to .50 during checkout

Weird is a very relative adjective. I want it to be rounded in the last step, just before the last confirmation "click". As I said, it is completly normal in Slovak Republic to have the Total Price rounded to .50 whereever you use coins and banks. And since our customers can choose to pay in cash, they must have the possibility of paying in .50 "units", because there are no smaller coins to pay with.
I am glad that people are interested in this thread, but asking why I need it is not going to solve my problem. Please don't take any offence, I just want to put this thread to the right direction.

1 Aug 2007, 10:24 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Round Total to .50 during checkout

What tax rate do you apply to your products?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Aug 2007, 10:37 PM
#7
breadfan avatar

breadfan

New Zenner

Join Date:
Jul 2007
Posts:
52
Plugin Contributions:
0

Re: Round Total to .50 during checkout

DrByte:

What tax rate do you apply to your products?
19% VAT.

1 Aug 2007, 10:53 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Round Total to .50 during checkout

breadfan:

I need to round the Total price to .50. I will simply double the number, round it and then divide it by 2. It will give me the value I need. But I don't know where to place the code. I assume to put it to ot_total module, but I have no idea where and what. ... I just need to modify the final total price so that instead of 1234.61 I'll get 1234.50.

breadfan:

I want it to be rounded in the last step, just before the last confirmation "click". As I said, it is completly normal in Slovak Republic to have the Total Price rounded to .50 whereever you use coins and banks. And since our customers can choose to pay in cash, they must have the possibility of paying in .50 "units", because there are no smaller coins to pay with.

I have no idea what other implications this will have elsewhere in the system, and whether any other calculations will be adversely affected, but this seems to work on a very simple checkout with a single taxable product without coupons or sales or discounts applied:

ot_total.php
change this:function process() { global $order, $currencies; $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']), 'value' => $order->info['total']); }to this, by adding 2 new lines, as shown:```
function process() {
global $order, $currencies;
[B] $val = $order->info['total'];
$order->info['total'] = (round($val * 2) / 2);[/B]

$this->output[] = array('title' => $this->title . ':',
'text' => $currencies->format($order->info['total'], true, $order->info['currency'], $order->info['currency_value']),
'value' => $order->info['total']);
}

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Aug 2007, 11:01 PM
#9
breadfan avatar

breadfan

New Zenner

Join Date:
Jul 2007
Posts:
52
Plugin Contributions:
0

Re: Round Total to .50 during checkout

Wow, thank you very much DrByte. I am going to try it tomorrow and will let you know about the results. But I'll back up the files and database before doing any modifications.
One more question: Do you think that the modified result will be also written to the database? I need it that way because the invoices are printed from admin interface.
Thank you once again :)