Role Based Price - How to change the price display for variable products

If you want change the price display for variable products (size range from 100 $ -200 $ to format From: $ 100)
Add this php code to the file functions.php of your theme:

 

if( defined( 'YWCRBP_PREMIUM') && function_exists( 'YITH_Role_Based_Prices_Product' ) ) {
add_filter( 'ywcrbp_variable_regular_price_html', 'ywcrbp_my_wc_custom_variable_price_html', 10, 4 );
add_filter( 'ywcrbp_variable_sale_price_html', 'ywcrbp_my_wc_custom_variable_price_html', 10, 4 );
add_filter( 'ywcrbp_variable_your_price_html', 'ywcrbp_my_wc_custom_variable_price_html', 10, 4 );
/**
* @param string $price
* @param WC_Product_Variable $product
* @return string
*/
function ywcrbp_my_wc_custom_variable_price_html( $price, $product, $min, $max )
{

if( $product->get_type() == 'variable' ) {

$suffix = YITH_Role_Based_Prices_Product()->get_price_suffix( $product );

// Return price if min is equal to max.
if( $min === $max ) {
return $price;
}
return sprintf( __( 'From %s', 'your-text-domain' ), wc_price( $min ) . $suffix );
}
return $price;
}
}
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center

Powered by Zendesk