WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Woocommerce cart total displaying incorrectly (10 posts)

  1. foxylad85
    Member
    Posted 1 year ago #

    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/

  2. Roy Ho
    Member
    Posted 1 year ago #

    Could this be related to your theme?

  3. foxylad85
    Member
    Posted 1 year ago #

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

  4. Roy Ho
    Member
    Posted 1 year ago #

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

  5. foxylad85
    Member
    Posted 1 year ago #

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

  6. foxylad85
    Member
    Posted 1 year ago #

    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

  7. Roy Ho
    Member
    Posted 1 year ago #

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

  8. smithcreate
    Member
    Posted 1 year ago #

    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.

  9. dr.hammer
    Member
    Posted 1 year ago #

    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

  10. Mike
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.