FrugalWebGuy is Merging with Michael Mann Web Design under the new Title of I Do Web Work

WooCommerce Snippets: Functions.php Modification

Video Available (Signup to Access - Members Only)

Working with your theme's functions.php file, the following snippets can allow for modification to your WooCommerce Store. Use them with care, making sure to following the specific directions provided. Otherwise you might cause your site to "disappear" and only display a blank white page.

Show Just the Maximum Price on Variable Products

By default, variable products (those with options such as a size) will show on the category page as "From: 1.99" for example. To have it show just the maximum price, add the following to your theme's functions.php file.

Note: Be sure this is placed between the <?php and ?> tags.

Only applies to variable products NOT on sale. Any products with at least one variation on sale will still show as "From: 1.99" for example.

/** Returns max price for variably priced products **/
/* Variable Products without any on-sale */
add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);
/* Variable Products with at least 1 on-sale */
add_filter('woocommerce_variable_sale_price_html', 'custom_variation_price', 10, 2);
function custom_variation_price( $price, $product ) {
$price = woocommerce_price($product->max_variation_price);
return $price;
}

Wish to just change the text From: to Starting At:? Swap out the $price line above for the following:

$price = 'Starting at: ';
$price .= woocommerce_price($product->max_variation_price);

This will allow you to add any text you wish in front of the price.

Training inspired by code copied from: https://gist.github.com/mikejolley/1600117