“Starting from” text
-
Hi, I was looking for a way to eliminate the price variations of the products by replacing them with the text “starting from:”, I found this code on a forum and even if I am not familiar with codes I have entered it and it works fine except in the case of discounted products.
Can anyone tell me if they see any errors in this code?
Or maybe if someone can show me a code that works, thank you.function blogwp_wc_format_change( $price, $product ) {
$text = sprintf(‘%s: ‘, __(‘Starting from’, ‘iconic’));
$price_min_regular = $product->get_variation_regular_price( ‘min’, true );
$price_min_sale = $product->get_variation_sale_price( ‘min’, true );
$maximum_price = $product->get_variation_price( ‘max’, true );
$minimum_price = $product->get_variation_price( ‘min’, true );$price = ( $price_min_sale == $price_min_regular ) ? wc_price( $price_min_regular ) : ” . wc_price( $price_min_regular ) . ” . ” . wc_price( $price_min_sale ) . ”;
return ( $minimum_price == $maximum_price ) ? $price : sprintf(‘%s%s’, $text, $price);
}
add_filter( ‘woocommerce_variable_sale_price_html’, ‘blogwp_wc_format_change’, 10, 2 );
add_filter( ‘woocommerce_variable_price_html’, ‘blogwp_wc_format_change’, 10, 2 );The page I need help with: [log in to see the link]
The topic ‘“Starting from” text’ is closed to new replies.