• Hello there,

    First, thanks for your awesome plugin.

    I have a big issue in production : I’ve realized that tax doesn’t work correctly when you set a free trial.

    What I tried :
    When I set a subscription at 1 euros per days with no free trial
    -> I see in subscription table that I’m subscribed with 1 euro per month, I see correct VAT the first day and the others days.

    When I set a one day free trial, the first day i have a order at 0 euro, but I see in subscription table that I’m subscribed with 1.20 euros per month. When I look at the subscribption post meta, I see 1 euro in order_total and wps_recurring_total. I see 0.20 in _order_tax (it should be 0.17).

    _prices_include_tax post_meta is set to yes
    line_subtotal_tax and line_tax post_meta are set at 0
    line_subtotal and line_total post_meta are set at 1
    line_tax_data post_meta looks empty : a:2:{s:8:”subtotal”;a:1:{i:1;d:0;}s:5:”total”;a:1:{i:1;d:0;}}

    when free trial is not set, theses post metas are not the same

    Woocommerce is correctly configured for tax and the option “price is set vat included” is checked. I have no issue with other types of products.

    From what i understood in the code, at renewal, the plugin looks for the taxes in first order, but the first order is at 0 euro.

    I’m kinda in a situation here because I’ve already have few subscription in production with a 7 days trials. My customers will be charged more than they should be in three days.

    I’ve tried to change things with the wps_product_args_for_order filter and manage to pass the correct taxes in the array, but it didn’t change anything in the tax meta and it didn’t work correctly : at renewal, I had an order without tax and the order price was set at 0.83… No idea why.

    Any help appreciated, thanks !

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter gpourbaix

    (@gpourbaix)

    Hello again,

    So I came up with this filter and it worked like I needed to.

    I share it in case some one else has the same issue.
    It will only work if tax are activated and if tax of the subscription is at 0.
    I’ve only tested in “tax included in price” mode and I think it would work only if you can buy only one subscription at the time.

    add_filter('wps_sfw_cart_data_for_susbcription', 'gp_fix_tax_error_from_subscription_plugin', 1);
    function gp_fix_tax_error_from_subscription_plugin($wps_recurring_data) {
    
        if (get_option('woocommerce_calc_taxes')== "yes" && $wps_recurring_data["line_tax"]==0) {
    
        $product_id = $wps_recurring_data['product_id'];
        $product = wc_get_product(  $product_id );
    
        $tax_obj = new WC_Tax();
    
        // Get the tax data from customer location and product tax class
        $tax_rates_data = $tax_obj->find_rates( array(
            'country'   => WC()->customer->get_shipping_country() ? WC()->customer->get_shipping_country() : WC()->customer->get_billing_country(),
            'state'     => WC()->customer->get_shipping_state() ? WC()->customer->get_shipping_state() : WC()->customer->get_billing_state(),
            'city'      => WC()->customer->get_shipping_city() ? WC()->customer->get_shipping_city() : WC()->customer->get_billing_city(),
            'postcode'  => WC()->customer->get_shipping_city() ? WC()->customer->get_shipping_city() : WC()->customer->get_billing_city(),
            'tax_class' => $product->get_tax_class()
        ) );
    
        if( ! empty($tax_rates_data) ) {
            $taux_tva = reset($tax_rates_data)['rate'];
        }
        else  {
            $taux_tva = 0;
        }
    
        $calcul_tva = 1+($taux_tva/100); 
          
        $ttc_price = $wps_recurring_data["wps_recurring_total"];
    
        $ht_price = $ttc_price/$calcul_tva;
        $ht_price_rounded_2 = round( $ht_price, 2 );
    
        $tax = $ttc_price - $ht_price;
        $tax_price_rounded_2 = round( $tax, 2 );
    
        $wps_recurring_data['line_subtotal_tax'] = $tax_price_rounded_2;
        $wps_recurring_data['line_tax'] = $tax_price_rounded_2;
    
        $wps_recurring_data['line_total'] = $ttc_price;
        
        $wps_recurring_data['line_subtotal'] = $ttc_price;
    
        $wps_recurring_data["line_tax_data"]['subtotal'][1]=$tax;
        $wps_recurring_data["line_tax_data"]['total'][1]=$tax;
        }
    
        return $wps_recurring_data;
    }

    Best regards

    Plugin Author WP Swings

    (@wpswings)

    Hi,
    Thanks for reaching out!

    We really appreciate how you’re able to deliver a concern to the team and how you have invented a solution so quickly by yourself, thanks for sharing the solution too.

    We have noted the concern and we will surely fix this in the upcoming update.

    Best Regards,

    SomeoneElseEntirely

    (@someoneelseentirely)

    I’m also still having similiar problem with TAX/VAT.

    On the checkout amount is around 180 EUR and after checkout its 240 EUR and I’m not sure what amount is your plugin adding.

    Plugin Author WP Swings

    (@wpswings)

    Hello @someoneelseentirely

    We need to check on your website please connect our support

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Issue with tax and free trial’ is closed to new replies.