Skip to content

Commit

Permalink
PIWOO-382 dont cache empty methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Feb 22, 2024
1 parent 04b0b3b commit 656ee8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Shared/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public function getAllAvailablePaymentMethods($useCache = true)
delete_transient($transient_id);
}
// No cache exists, call the API and cache the result
if ($methods === false) {
if (empty($methods)) {
if (!$apiKey) {
return [];
}
Expand All @@ -720,8 +720,8 @@ public function getAllAvailablePaymentMethods($useCache = true)
// $methods_cleaned is empty array when the API doesn't return any methods, cache the empty array
$methods = $methods_cleaned;

// Set new transients (as cache)
if ($useCache) {
// Set new transients (as cache) only if we have something in
if ($useCache && !empty($methods)) {
set_transient($transient_id, $methods, HOUR_IN_SECONDS);
}
}
Expand Down

0 comments on commit 656ee8f

Please sign in to comment.