Woocommerce "Simple Product Type" Change Price text for Zero Price Products, No Price Products

Viewed 114

I have this code that replaces price text for all products with Zero or No Price. I need to ammend code to only target simple_product or custom_product_type.

I was thinking something like;

if ( $product_type == 'simple' ) {

but I do not know how to execute it. Any suggestions please.

add_filter( 'woocommerce_get_price_html', 'simple_price_free_zero_empty', 9999, 2 );
   
function simple_price_free_zero_empty( $price, $product ){
    if ( '' === $product->get_price() || 0 == $product->get_price() ) {
        $price = '<span class="woocommerce-Price-amount amount">NEW PRICE TEXT HERE</span>';
    }  
    return $price;
}
0 Answers
Related