Skip to content

Instantly share code, notes, and snippets.

@marcosfreitas
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcosfreitas/9070982 to your computer and use it in GitHub Desktop.
Save marcosfreitas/9070982 to your computer and use it in GitHub Desktop.
Override price.php file - woocommerce - price do not returns decimal zero - put this script in "your-theme/woocommerce/loop/price.php"
<?php
/**
* Loop Price
* Overriding original price.php
* @author Marcos Freitas - WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product;
/**
* Deixei a verificação original
* o price_html não estava retornando as casas decimais quando elas eram zeros
*/
if ( $price_html = $product->get_price_html() ) :
$currency = get_woocommerce_currency_symbol(); // pega o símbolo da moeda
$price_value = number_format($product->price, 2, ',', '.'); // formata o valor para o padrão BR
?>
<div class="price"><span class="amount"><?php echo $currency.' '.$price_value;?> </span></div>
<?php
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment