Skip to content

Instantly share code, notes, and snippets.

@eltondev
Last active August 29, 2015 14:24
Show Gist options
  • Save eltondev/09dc7f680be698ebec6b to your computer and use it in GitHub Desktop.
Save eltondev/09dc7f680be698ebec6b to your computer and use it in GitHub Desktop.
Display Custom Variable Price Products
function variable_price_html_custom_text( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'A partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
$price .= '<span class="to"> ' . __( 'até' ) . ' </span>';
$price .= woocommerce_price( $product->max_variation_price );
}
return $price;
}
add_filter( 'woocommerce_variable_price_html', 'variable_price_html_custom_text', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment