Skip to content

Instantly share code, notes, and snippets.

@arush
Created August 11, 2011 12:05
Show Gist options
  • Save arush/1139484 to your computer and use it in GitHub Desktop.
Save arush/1139484 to your computer and use it in GitHub Desktop.
price decimal modifyer
// trim all decimals
public function formatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
return preg_replace('/.[0-9]*$/', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
// return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
}
return $price;
}
//trim only .00
public function formatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
return str_replace('.00', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
// return preg_replace('/.[0-9]*$/', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
// return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
}
return $price;
}
return str_replace('.00', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
@psychocrackpot
Copy link

public function formatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
return str_replace('.00', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
// return preg_replace('/.[0-9]*$/', '', $this->getCurrentCurrency()->format($price, array(), $includeContainer));
// return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
}

   return $price;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment