• Resolved zokomon

    (@heminghela)


    I use the following custom code you provided to use tax in woocommerce cashback calculation

    // Calculates tax in woowallet cashback calculation
    add_filter('woo_wallet_cashback_amount', 'woo_wallet_cashback_amount', 10, 2);
    
    function woo_wallet_cashback_amount($cashback_amount, $order_id) {
        if ($order_id) {
            return $cashback_amount;
        }
        $global_cashbak_type = woo_wallet()->settings_api->get_option('cashback_type', '_wallet_settings_credit', 'percent');
        $global_cashbak_amount = floatval(woo_wallet()->settings_api->get_option('cashback_amount', '_wallet_settings_credit', 0));
        if ('percent' === $global_cashbak_type) {
            $cashback_amount = (wc()->cart->get_subtotal() + wc()->cart->get_subtotal_tax()) * ($global_cashbak_amount / 100);
        }
        return $cashback_amount;
    }
    

    My store does not use geolocate function. There tax calculation is done only after the customer selects billing state on the checkout page.
    But as tax is not yet calculated until user has input country and state, after he selects those field and the tax is updated, the cashback does not update.

    EG:
    Product 1 price = 427.62,
    Tax rate 5%
    total = 449

    cashback rate is 427.62

    When the checkout page loads, it shows you will get cashback of 42.76/-
    But when the user completes his checkout form, the sidebar shows additional tax of 21.38 and the total of 449.

    As per the above code the cashback amount should be 44.9 but it does not changes with the ajax reload. Can we make it update with AJAX?

    Sorry for the long post

  • The topic ‘Wrong Cashback amount’ is closed to new replies.