Note the extra if conditions who check the price. Explanation via comment tags added in the code
function custom_add_to_cart_price( $button_text, $product ) {
// Product type = variable
if ( $product->is_type('variable') ) {
// NOT return true when viewing a single product.
if( ! is_product() ) {
// Get price
$price = wc_get_price_to_display( $product, array( 'price' => $product->get_variation_price() ) );
// Greater than
if ( $price > 0 ) {
$product_price = wc_price( $price );
$button_text .= ' - From ' . strip_tags( $product_price );
}
}
} else {
// Get price
$price = wc_get_price_to_display( $product );
// Greater than
if ( $price > 0 ) {
$product_price = wc_price( $price );
$button_text .= ' - Just ' . strip_tags( $product_price );
}
}
return $button_text;
}
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_price', 10, 2 );
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_price', 10, 2 );