From ad970495efc8baaafe33a73613252b18f6bde9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kraft?= Date: Thu, 27 Jul 2023 11:33:40 +0200 Subject: [PATCH] Issue #182 - Fix Envato Fatal Error --- src/Integration/EnvatoMarket.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Integration/EnvatoMarket.php b/src/Integration/EnvatoMarket.php index fb6dc33..572cbee 100644 --- a/src/Integration/EnvatoMarket.php +++ b/src/Integration/EnvatoMarket.php @@ -51,8 +51,12 @@ public function filter_package_download_url( string $download_url ): string { $download_url = ''; if ( $vars['item_id'] ) { - $args = $this->get_bearer_args( $vars['item_id'] ); - $download_url = envato_market()->api()->download( $vars['item_id'], $args ); + $args = $this->get_bearer_args( $vars['item_id'] ); + $envato_download_url = envato_market()->api()->download( $vars['item_id'], $args ); + // Envato returns false, if the download fails. i.e id is missing, product does not exist anymore. + if ( $envato_download_url ) { + $download_url = $envato_download_url; + } } }