• Hi, I have some code to slightly change what Woo shows in my theme (basically for Multi Prices it shows “From £X).
    However this removed the “inc VAT” label.
    I have added some code and the inc VAT now shows (Suffix) but I need to apply the Font Size “Small” to it.

    How do I do this. Code is below.

    Thanks in advance.

    function wc_ninja_custom_variable_price( $price, $product ) {
        // Main Price
        $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
        $price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    
        // Sale Price
        $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
        sort( $prices );
        $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    $suffix = ' inc VAT';
        if ( $price !== $saleprice ) {
            $price = '' . $saleprice . ' ' . $price . '';
        }
        
        return $price . $suffix;
    }
    
    add_filter( 'woocommerce_variable_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Riaan K.

    (@riaanknoetze)

    Would suggest using CSS instead of trying to add that with inline styles. Just grab the classname on the front end using Chrome’s dev tools, and then write your own custom CSS.

    As for the exact syntax, something along the lines of font-size: 0.8em should work just fine (Using small is a pretty outdated standard).

    @thenorth please provide a link to your site and show which elemenet you’re trying to style differently and I’ll provide you with some custom CSS code you can use.

    As pointed out by Riaan above, if you right-click any part of your theme and select the Inspect Element option, you can view the structure of your theme code.

    Locate and click on the element you wish to change and you will be able to see the classname of that element to the right amongst the CSS code that is being applied to the selected element.

    Hope this helps.

    Thread Starter thenorth

    (@thenorth)

    Hi, part of the issue is the text doesn’t have a Class of it’s own. It’s linked to the price (which the proper ones aren’t. Can I give it a Class in PHP?
    The Prices I don’t create are this <small class=”woocommerce-price-suffix”>Inc VAT</small>

    However the Prices created by the PHP above shows this ” inc VAT”.

    Appreciate any help.

    IMAGE of Website

    Thank you.

    Try this:

    $suffix = '<small class="woocommerce-price-suffix">' . '&nbsp;inc VAT' . '</small>';

    Hope this helps.

    • This reply was modified 9 years, 6 months ago by ThemeSumo.
    Thread Starter thenorth

    (@thenorth)

    That is the shot. Thank you ThemeSumo.

    No problem, good luck.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Applying CSS to PHP’ is closed to new replies.