Support » Plugin: WooCommerce » Woocommerce cart total displaying incorrectly

  • Hi all,
    For some reason, the cart total on the ‘Cart’ page of my woocommerce installation displays correctly, with 2 decimal places (eg £7.98). However, the cart total in the website header is displaying with 3 decimal places (eg £7.982).
    Can anyone tell my why this is happening and how to remedy it?
    Thanks,
    Chris

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Roy Ho

    (@splashingpixelscom)

    Could this be related to your theme?

    Possibly, but it is a theme provided by WooThemes as well. A free theme called Mystile.

    Roy Ho

    (@splashingpixelscom)

    If you put the cart widget in your sidebar, does it show the correct decimal places?

    Yes it does. Starnge. It’s just the cart total in the header…

    Hi,
    I have worked out what this is. It’s the number of items that are in the cart displaying directly next to the price. So the cart at the top of the page is showing £62, it is in fact £6 with 2 items in the cart.
    Does any one know why this ‘Mystile’ theme is displaying it like this?
    Cheers,
    Chris

    Roy Ho

    (@splashingpixelscom)

    Perhaps use CSS to re-position that so it looks correct.

    I’m having the same issue with this theme. I can add padding to the .amount class in CSS which moves the number of items over. But I also noticed that the quotes surrounding the item quantity are not displaying, but I see them in the source.

    From a usability standpoint, just having a number hanging out there doesn’t tell the user what that number is. I’m still trying to find a solution to this. Any further help would be greatly appreciated.

    Here’s my temporary solution (remove the quantity, and only leave the $amount). At least it’s not confusing… Hopefully someone comes up with a better fix.

    Remove the following line:
    echo $woocommerce->cart->get_cart_contents_count();

    From here:

    // Handle cart in header fragment for ajax add to cart
    add_filter(‘add_to_cart_fragments’, ‘woocommerce_cart_link’);
    function woocommerce_cart_link() {
    global $woocommerce;
    ?>
    <li class=”cart”>
    cart->get_cart_url(); ?>” title=”<?php _e(‘View your shopping cart’, ‘woothemes’); ?>” class=”cart-parent”>
    <span>
    <?php
    echo $woocommerce->cart->get_cart_total();;
    echo $woocommerce->cart->get_cart_contents_count();
    ?>
    </span>

    <?php
    }
    }

    Found here:
    mystile/includes/theme-woocommerce.php

    Instead of changing around the whole header php for such a minor change, try this simple and clean (but still hacky) fix. Simply add the following lines to your custom.css:

    ul.wc-nav li.cart a > span { padding-left: 20px; }
    ul.wc-nav li.cart a > span:after { content: 'items'; }
    ul.wc-nav li.cart a > span span.amount { position: relative; left: -20px; }

    This also adds ‘items’ after the number.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Woocommerce cart total displaying incorrectly’ is closed to new replies.