• Resolved fellter2

    (@fellter2)


    Hi,
    I am adding a discount to the order when a specific checkbox is checked by the customer. I need this discount to be a fixed price, regardless of the tax rate, ie. a customer from a country with 20% tax rate should receive the same discount ($5) as someone from a country with 10% tax rate.

    I have this code

    // Set the discount
    add_action( 'woocommerce_cart_calculate_fees', 'checkout_set_discount', 20, 1 );
    function checkout_set_discount( $cart ) {
    if ( ( is_admin() && ! defined('DOING_AJAX') )  )
        return;
    
    $discount   = 5;
    
    if( WC()->session->get('priority_fee') ) {
        $cart->add_fee( sprintf( __( 'Discount', 'woocommerce') ),  -$discount );
    }
    

    but this results in the discount being 5.50 for a country with 10% tax rate, 6 for a country with 20% tax rate and so on…how can I make the tax a fixed 5$?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Thread Starter fellter2

    (@fellter2)

    @rainfallnixfig this shouldn’t be too complicated as I already have everything working, js etcc. It is just the part with the fixed discount! Please help me as I have already gone through many, many other forums and threads regarding this.

    Thanks!

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    Since this requires coding skills and our scope of support does not cover code customizations, as explained in our Support Policy, if you want to talk to an expert, we recommend reaching out to someone on our customizations page.

    Thanks.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to find a solution and the above resources for developers were helpful. If you have further questions, please feel free to open a new topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Help adding discount (tax issue)’ is closed to new replies.