• Resolved ankitispace

    (@ankitispace)


    How can I apply coupon after-tax calculation?
    – I want the same tax amount coupon to apply & it’s like a tax-free product…
    – I Want tax based on subtotal then coupon discount apply like,
    subtotal + tax based on Subtotal – coupon discount amount (which is same as a tax based on Subtotal)= Total (Which is same as subtotal)

    but, When I apply coupon amount (same as tax amount) is change tax amount is like,
    subtotal – coupon discount amount = new subtotal & tax apply on new subtotal which is different tax amount as earlier.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    You can set taxes to be inclusive on cart and checkout, which would add taxes first and then apply discount on subtotal + tax: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/

    Link to image: https://snipboard.io/17n4wL.jpg

    Thread Starter ankitispace

    (@ankitispace)

    I don’t want product price inclusive tax…
    alternatively, I added another code that works fine…
    This can help others too…

    add_action( 'woocommerce_cart_calculate_fees','custom_shipping_tax_free', 10, 1 );
    function custom_shipping_tax_free( $cart ) {
    	global $woocommerce;
        if ( is_admin() && ! defined('DOING_AJAX') ) return;
    
    	$payment_method_id = WC()->session->get('chosen_payment_method');
        // For cash on delivery "COD"
    	if ( $payment_method_id === 'cod' ) {
    		$surcharge = - (array_sum($woocommerce->cart->taxes)) ;
    		$cart->add_fee( __( 'Discount Tax', 'woocommerce'), $surcharge, false );
    	}
    }
    
    add_filter( 'woocommerce_cart_totals_get_fees_from_cart_taxes', 'exclude_cart_fees_taxes', 10, 3 );
    function exclude_cart_fees_taxes( $taxes, $fee, $cart ) {
    	return array();
    }
    • This reply was modified 4 years, 10 months ago by ankitispace.

    Hi @ankitispace

    Thank you for sharing your solution. I’m marking this thread as resolved now. If you have any other questions, please feel free to open a new topic.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Apply Coupon AFTER taxes’ is closed to new replies.