Skip to content

Commit

Permalink
Add null check to prevent fatal error when WC()->cart is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Karimov committed Apr 17, 2023
1 parent b01bfca commit 1996305
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion includes/class-wc-payments-upe-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public function get_payment_fields_js_config() {
} elseif ( WC_Payments_Features::is_upe_deferred_intent_enabled() ) {
$payment_fields['checkoutTitle'] = $this->gateway->get_checkout_title();
$payment_fields['currency'] = get_woocommerce_currency();
$payment_fields['cartTotal'] = WC_Payments_Utils::prepare_amount( WC()->cart->get_total( '' ), get_woocommerce_currency() );
$cart_total = ( WC()->cart ? WC()->cart->get_total( '' ) : 0 );
$payment_fields['cartTotal'] = WC_Payments_Utils::prepare_amount( $cart_total, get_woocommerce_currency() );
}

$enabled_billing_fields = [];
Expand Down

0 comments on commit 1996305

Please sign in to comment.