Struggling with some php code.

Hello, I’m no expert with php, but i like to think i can read it okay, just not always fix it!!

I am having some trouble with my website, the issue is when numbers are calculatated on the checkout form it comes up with hundreds of decimals!! I’m sure there must be an easy fix, but cant work it out.

Any help would be very much appriciated! Thanks in advance. Jamie.

The script i am using is php, but uses the yii framework. The code i think needs changing is:

[php] public function columns()
return array(
array(‘header’ => $this->t(‘Description’), ‘name’ => ‘description’),
array(‘header’ => $this->t(‘Quantity’),
‘value’ => ‘$data[“quantity”]!==null
? wm()->get(“payment.cart”)->quantityField($data)
: NULL’,
‘type’ => ‘raw’),
array(‘header’ => $this->t(‘Price’), ‘value’ => '$data[“price”]
? m(“payment”)->param(“cSymbol”)
. “<span class=‘price’>”.app()-

: NULL’,
‘type’ => ‘raw’),
array(‘header’ => $this->t(‘Total’),
‘value’ => 'm(“payment”)->param(“cSymbol”) . "<span class=

. app()->numberFormatter->formatDecimal(isset($data

‘type’ => ‘raw’),

public function dataProvider()
	$credit = wm()->get('payment.helper')->credit();
		$this->put('payment',0,$this->t('Use my {site} credit: {credit}',
			array('{site}'=>app()->name,'{credit}' => m('payment')-

0.25, -1);

	$data = array_values($this->_cart);
	$total = 0;
	foreach($data as $d)
		$total+= $d['price']*$d['quantity'];
	$data[] = array(
		'id' => 'total',
		'module' => 'payment',
		'description' => $this->t('My Price'),
		'quantity' => NULL,
		'price' => NULL,
		'total' => $total,
	return new CArrayDataProvider($data);

maybe this would work:
$data[] = array(
‘id’ => ‘total’,
‘module’ => ‘payment’,
‘description’ => $this->t(‘My Price’),
‘quantity’ => NULL,
‘price’ => NULL,
‘total’ => number_format($total, 2) // changed from $total

This would be the first thing i’d try… :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service