• Hi,

    I’m using this code:

    function cw_change_product_price_display( $price ) {
        $price .= ' <span id="tooltips">incl. VAT</span>';
        return $price;
    }
    add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
    add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );

    To display custom text after the price, how can I make it visible just for guest users?

Viewing 4 replies - 1 through 4 (of 4 total)
  • hello,

    You can use something like:

    function cw_change_product_price_display( $price ) {
        global $user_login;
        if( ! $user_login ) {
            $price .= ' <span id="tooltips">incl. VAT</span>';
            return $price;
        }
    }
    add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
    add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );

    Another option

    function cw_change_product_price_display( $price ) {
        if( ! is_user_logged_in() ) {
            $price .= ' <span id="tooltips">incl. VAT</span>'; 
        }
    
        return $price;
    }
    add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
    add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
    • This reply was modified 5 years, 4 months ago by wprock.
    Thread Starter Husein Yuseinov

    (@webg)

    Thank you guys!

    @wprock I’m using your suggestion and it works just fine!

    @crslz Thanks, I don’t know which of both suggestions is better?!

    I would like to show in this field tax name. I use 2 different taxes. how could this be possible?

    function cw_change_product_price_display( $price ) {
    $price .= ‘ <TAX NAME’;
    return $price;
    }
    add_filter( ‘woocommerce_get_price_html’, ‘cw_change_product_price_display’ );
    add_filter( ‘woocommerce_cart_item_price’, ‘cw_change_product_price_display’ );

    • This reply was modified 4 years, 11 months ago by ncfix.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom text after price’ is closed to new replies.