Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Block/Checkout/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ public function getCartTotals()
global $wp;

if (!isset($wp->query_vars['order-pay'])) {
return WC()->cart->total;
if (isset(WC()->cart)) {
return WC()->cart->total;
}
return 0;
Comment on lines +179 to +182

Copilot AI Jan 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this fix prevents the null pointer error, there is no test coverage for the new scenario where WC()->cart is null. Consider adding a test case that verifies the method returns 0 when the cart is not initialized, to prevent regression of this bug fix.

Copilot uses AI. Check for mistakes.
}
$orderId = $wp->query_vars['order-pay'];
$order = wc_get_order($orderId);
Expand Down
Loading