Show max variable price

Show max variable price

Short Intro:

I will provide code for showing max variable price.

Problem:

By default, it will show min and max price. But in the design provided, they wanted to display only the max price for a variable product.

Solution:

Go to theme editor under function.php and place this code.

// define the woocommerce_variable_price_html callback
function filter_woocommerce_variable_price_html( $wc_format_price_range, $instance ) {
$index = strpos($wc_format_price_range, "- ");
$wc_format_price_range = substr($wc_format_price_range, $index+7);
//This will remove the first price by dividing the standard string with dash
//You may add a prefix like, $wc_format_price_range = "Max Price: $wc_format_price_range";
return $wc_format_price_range;
};

// add the filter
add_filter( 'woocommerce_variable_price_html', 'filter_woocommerce_variable_price_html', 10, 2 );

Contact details

More solutions

by ilias

You're using JetFormBuilder and want to make sure users are at least 18 years old based on their birthday input.

by ilias

Roweij Spices wanted to have a filter that can choose number of products display per pagination

by ilias

This article will show you how to add dynamic code to your templates using the Elementor Shortcode widget and custom PHP code.