0

If the tax you're adding is country specific (EU countries for example) the tax estimate is not shown in the cart totals (although I'm logged in with user specified its EU billing address). But it is shown in the checkout page.

I would like to ask if there is any way the tax is shown in the cart page just like it is when it isn't country specific tax.

I mean this: when the taxes country code is left blank (meaning it applies to all) this is the message and screen you get enter image description here

which is pretty awesome and works for me. But when you add a country specific code in my case DE, I don't get it in my cart page although I'm logged in with user with billing address Germany.

enter image description here

I get the tax in my checkout, but not in the cart which I think might be quite misleading. I hope theres a solution for this

enter image description here

1
  • Please use only one account. You can edit your question without review if you do that.
    – fuxia
    Sep 26, 2013 at 10:30

1 Answer 1

3

This is a matter of configuration:

tax settings

This way taxes will be shown on the cart page:

cart

But because the address can be changed at checkout, this isn't and can't be conclusive - like it's stated taxes are estimated and will be updated on checkout.


Update:

Last week I quickly looked at the woocommerce code, but didn't have time to complete my answer. What I found is that there is a filter - woocommerce_matched_rates - you can hook into. The filter is part of the get_rates() function inside class-wc-tax.php. Below some code sample to begin with:

add_filter( 'woocommerce_matched_rates', 
            'wpse115734_wc_customer_based_tax_on_cart' );

function wpse115734_wc_customer_based_tax_on_cart( $matched_tax_rates = '', $tax_class = '' ) {
    global $woocommerce,$product;
    $tax_class = sanitize_title( $tax_class );
    $_taxobj = new WC_Tax();

    list( $country, $state, $postcode, $city ) = $woocommerce->customer->get_taxable_address();
    $shop_country = $woocommerce->countries->get_base_country();

    if ( ! ( $country == $shop_country ) ) {
        $matched_tax_rates = $_taxobj->find_rates( array(
            'country'   => $country,
            'state'     => $state,
            'postcode'  => $postcode,
            'city'      => $city,
            'tax_class' => $tax_class
        ) );
        return $matched_tax_rates;
    } else {
        $matched_tax_rates = $_taxobj->get_shop_base_rate( $tax_class );
        return $matched_tax_rates;
    }
}

As you can see this hooks into the filter and does some conditional check based on the shop base and the customer country. This is working for me, the taxes is shown based on the customer address, if it differs from the shop country. But like I said this is to begin with, because I did no further testing, it's merely proof of the possibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.