WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Remove taxes from cart total during checkout (3 posts)

  1. imfromio
    Member
    Posted 10 months ago #

    I am trying to set up a way for customers to be tax exempt. Currently, my cart charges state sales tax for customers in Wisconsin, US. I have added a tax exemption field to the checkout and account pages and tied those fields to the user meta data.

    I'm using get_user_meta($current_user->ID, 'aacer_tax_exempt', true) to check their tax exempt status and everything is working so far.

    Now, when a user is tax exempt and they are on the checkout page I want to remove the tax from the cart total.

    I found this snippet on stackoverflow that allowed me to modify the cart prices:

    add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );

    function add_custom_price( $cart_object ) {
    $custom_price = 10; // This will be your custome price
    foreach ( $cart_object->cart_contents as $key => $value ) {
    $value['data']->price = $custom_price;
    }
    }
    But I can not make it work for taxes.

    Anybody have any ideas how to remove the taxes from the cart total during checkout? Thank you!

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

  2. Washington Equipment
    Member
    Posted 10 months ago #

    I am looking to do the same thing. We have a lot of government/university/resale customers and I need a way to make customers tax exempt either by user or ideally by role.

  3. imfromio
    Member
    Posted 10 months ago #

    I was able to solve this using a combination of two sources. I'll list them here for others searching for something similar.

    From WooCommerce tech support I got this suggestion:

    if ( !is_admin() ) { // breaks backend if called without this check
    	add_action( 'init', 'aacer_woocommerce_customer_tax_exempt' );
    	function aacer_woocommerce_customer_tax_exempt() {
    		global $woocommerce;
    		if ( is_user_logged_in() ) {
    			$current_user = wp_get_current_user();
    			$tax_exempt = get_user_meta( $current_user->ID, 'aacer_tax_exempt', true );
    			$woocommerce->customer->set_is_vat_exempt( $tax_exempt );
    		}
    	}
    }

    I added the is_admin check since it was causing an error when in the backend.

    The second is from a recent entry in stackoverflow:
    http://stackoverflow.com/questions/16867447/add-tax-exempt-form-on-checkout-in-woocommerce

Reply

You must log in to post.

About this Plugin

About this Topic