Meta tag “product:price:amount” displays price excluding VAT

#487236
  • Resolved Xeilakos Kostas
    Rank Math free

    Hello, I have a website “gdktools.gr” where we set prices without vat and then Woocommerce calculates and adds the VAT amount. So, on single product pages, the generated tag product:price:amount displays the price excluding the VAT.

    I have found a filter like that to add the meta tag to the page including VAT

    add_action( 'rank_math/head', function() {
    if ( ! is_product() ) {
    return;
    }

    global $product;

    echo '<meta property="product:price:amount" content="'.wc_get_price_including_tax( $product ).'" />';
    }, 99 );

    but now, we have this meta tag displayed twice.
    So, Is it possible to make the tag displays the price including VAT and keep current Woocommerce configuration, e.g. keep setting prices without vat and WC calculates then ?
    Check the following screenshot:
    https://snipboard.io/YTWmgJ.jpg

    url to reproduce: https://www.gdktools.gr/product/nakayama-pro-nz100-trochilati-gennitria-elaioravdistikon-12v-70a-051350/

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    The filter you have used is to add another meta tag, which is shown in your screenshot.

    However, to achieve this, you can try the following filter instead:

    add_filter( "rank_math/opengraph/facebook/product_price_amount", function( $product_price ) {
        global $product;
        if (! is_product() ) {
            return;
        }
        $product_price = wc_get_price_including_tax( $product );
        return $product_price;
    });

    Hope that helps.

    Thank you.

    Xeilakos Kostas
    Rank Math free

    Thank you for your instant response. I really appreciate it!
    This is actually, what I have been looking for. So, you suggest to replace the price used by Rankmath with the one including the VAT. Smart solution.
    Thank you very much. I tried it and it works like a charm.

    You may close the ticket.

    Hello,

    You’re welcome.

    We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Meta tag “product:price:amount” displays price excluding VAT’ is closed to new replies.