Skip to content

Commit

Permalink
Try and catch the theme support and any error we keep the theme null
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyon147 committed May 16, 2024
1 parent b3047a4 commit f8d7e7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Actions/InstallShop.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Osiset\ShopifyApp\Objects\Values\NullAccessToken;
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
use Osiset\ShopifyApp\Objects\Values\ThemeSupportLevel;
use Osiset\ShopifyApp\Objects\Enums\ThemeSupportLevel as ThemeSupportLevelEnum;
use Osiset\ShopifyApp\Util;

/**
Expand Down Expand Up @@ -100,8 +101,15 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
$data = $apiHelper->getAccessData($code);
$this->shopCommand->setAccessToken($shop->getId(), AccessToken::fromNative($data['access_token']));

$themeSupportLevel = call_user_func($this->verifyThemeSupport, $shop->getId());
$this->shopCommand->setThemeSupportLevel($shop->getId(), ThemeSupportLevel::fromNative($themeSupportLevel));
// Try to get the theme support level, if not, return the default setting
try {
$themeSupportLevel = call_user_func($this->verifyThemeSupport, $shop->getId());
$this->shopCommand->setThemeSupportLevel($shop->getId(), ThemeSupportLevel::fromNative($themeSupportLevel));
} catch (Exception $e) {
// Just return the default setting which is null
$themeSupportLevel = ThemeSupportLevelEnum::NONE;
}


return [
'completed' => true,
Expand Down
7 changes: 7 additions & 0 deletions src/Objects/Enums/ThemeSupportLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ class ThemeSupportLevel implements ValueObject
* @var int
*/
public const UNSUPPORTED = 2;

/**
* Support level: None.
*
* @var null
*/
public const NONE = null;
}

0 comments on commit f8d7e7c

Please sign in to comment.