Error in VAT calculation on order thank you page (Order recieved)
-
hi, I use Germanized in combination with CheckoutWC. In the order thank you page, once the order is received, the taxes calculation (VAT) is wrong as; following the code; it tries to calculate the taxes on cart and not on the received order. below is my code snippet to fix this issue. But it would be helpful and better for all if you could please solve the issue in the plugin update.
function ax_wc_fix_gzd_thankyoupage_taxes($tax_array, $cart, $include_shipping_taxes){ if ( is_order_received_page() ) { global $wp; $tax_array = array(); // Get the order. Following lines are present in order_received() in includes/shortcodes/class-wc-shortcode-checkout.php file $order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order-received'] ) ); $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['key'] ) ? '' : wc_clean( $_GET['key'] ) ); if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); if ( ! $order || ! hash_equals( $order->get_order_key(), $order_key ) ) { $order = false; } } if ( $order instanceof WC_Order ) { $taxes = $order->get_tax_totals(); foreach ( $taxes as $code => $tax ) { $rate = wc_gzd_get_tax_rate( $tax->rate_id ); if ( ! $rate ) { continue; } if ( ! empty( $rate ) && isset( $rate->tax_rate ) ) { $tax->rate = $rate->tax_rate; } if ( ! isset( $tax_array[ $tax->rate ] ) ) { $tax_array[ $tax->rate ] = array( 'tax' => $tax, 'amount' => $tax->amount, 'contains' => array( $tax ), ); } else { array_push( $tax_array[ $tax->rate ]['contains'], $tax ); $tax_array[ $tax->rate ]['amount'] += $tax->amount; } } } return $tax_array; } } add_filter('woocommerce_gzd_cart_taxes','ax_wc_fix_gzd_thankyoupage_taxes',10, 3);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Error in VAT calculation on order thank you page (Order recieved)’ is closed to new replies.