Skip to content

Instantly share code, notes, and snippets.

@eder-dias
Forked from claudiosanches/functions.php
Created October 23, 2013 18:53
Show Gist options
  • Save eder-dias/7124432 to your computer and use it in GitHub Desktop.
Save eder-dias/7124432 to your computer and use it in GitHub Desktop.
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
function custom_variation_price( $price, $product ) {
$price = '';
if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
$price .= woocommerce_price($product->get_price());
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
$price .= '<span class="to"> ' . _x('to', 'max_price', 'woocommerce') . ' </span>';
$price .= woocommerce_price($product->max_variation_price);
}
return $price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment