Skip to content

Commit

Permalink
Prevent total null error
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinwy committed Dec 13, 2024
1 parent 5d864d7 commit e2aa0dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions includes/class-wc-gateway-komoju-single-slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,22 @@ public function create_session_for_fields()
{
$komoju_api = $this->komoju_api;
$currency = get_woocommerce_currency();
$orderTotal = 0;

if (WC()->cart) {
$orderTotal = $this->get_order_total();
}

$session_params = [
'amount' => self::to_cents($this->get_order_total(), $currency),
'amount' => self::to_cents($orderTotal, $currency),
'currency' => $currency,
'default_locale' => self::get_locale_or_fallback(),
'metadata' => [
'woocommerce_note' => 'This session is only for rendering inline fields, and will not be completed.',
],
];

if ($this->get_order_total() == 0) {
if ($orderTotal == 0) {
return null;
}

Expand Down

0 comments on commit e2aa0dd

Please sign in to comment.