WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Pricing separator (tax comma) (4 posts)

  1. mbs1337
    Member
    Posted 8 months ago #

    Hello there.

    Is it possible to add a comma to the tax pricing on a product page?

    See this: http://tkmaskiner.dk/produkt/foton-824/

    The price:

    kr235.000
    kr188000 (excl. moms)

    I want:

    kr235.000
    kr188.000 (excl. moms)

    For the tax price i put this in price.php:

    <p itemprop="price" class="priceex">kr<?php echo $product->get_price_excluding_tax(); ?> (excl. moms)</p>

    Thanks in advance!

    Regards Michael

    http://wordpress.org/plugins/woocommerce/

  2. mbs1337
    Member
    Posted 6 months ago #

    This link gave me some hope, but it returns in a bunch of errors, and then the sidebar does not work.

    http://wordpress.stackexchange.com/questions/106355/how-to-display-price-including-tax-with-formatting

  3. mbs1337
    Member
    Posted 6 months ago #

    Okay. With the help on Facebook i got it fixed with:

    <p itemprop="price" class="priceex"><?php echo number_format( $product->get_price_excluding_tax(), 0, ',', '.' ); ?> kr (excl. moms)</p>

    in

    /plugins/woocommerce/templates/single-product/price.php

  4. mbs1337
    Member
    Posted 6 months ago #

    Sorry for fast answer. Here is a fix for:

    1) Only comma separator when needed
    2) The last message (without tax) only to be displayed on products with price
    3) When a straight price, the comma separator is gone

    <p itemprop="price" class="priceex">
    <?php 
    
    if (strlen($product->get_price_html()) > 0) {
        if (fmod($product->get_price_excluding_tax(), 1) == 0) {
            echo number_format( $product->get_price_excluding_tax(), 0, '.', '.' );
        }
        else {
            echo number_format( $product->get_price_excluding_tax(), 2, '.', '.' );
        }
        echo ' kr (excl. moms)';
    }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    excl. moms is Danish for "no tax" :-)

    Regards from Denmark
    Michael Bay

Reply

You must log in to post.

About this Plugin

About this Topic