Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error on order - unable to make a division by zero #907

Open
MKlblangenois opened this issue May 16, 2024 · 0 comments
Open

Fatal error on order - unable to make a division by zero #907

MKlblangenois opened this issue May 16, 2024 · 0 comments

Comments

@MKlblangenois
Copy link

When we've order that has specific vat rates on shipping or even equals to zero, we got a fatal error when customer try to make complete checkout.

In log, we got a "unable to make a division by zero" and I've fixed that by adding the next line inside the plugin file, but I'm not sure that fix doesn't affect other parts of code:

./src/Payment/OrderLines.php#528

 /**
     * Get shipping method tax rate.
     *
     * @since 1.0
     *
     * @access private
     *
     * @return float|int $shipping_vat_rate Tax rate for selected shipping method.
     *
     * @psalm-return 0|float
     */
    private function get_shipping_vat_rate() {
        $shipping_vat_rate = 0;

+       if (WC()->cart->shipping_tax_total > 0 && WC()->cart->shipping_total > 0) {
            $shipping_vat_rate = round(WC()->cart->shipping_tax_total / WC()->cart->shipping_total, 2) * 100;
+      }

        return $shipping_vat_rate;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant