diff --git a/src/Block/Page/Footer.php b/src/Block/Page/Footer.php index 6bf5d39..b15068d 100644 --- a/src/Block/Page/Footer.php +++ b/src/Block/Page/Footer.php @@ -82,8 +82,8 @@ public function getPackageJsonData() { $pathToTheme = substr($pathToTheme, 0, -7) . self::PACKAGE_JSON_FILE; if (file_exists($pathToTheme)) { - $packageData = json_decode(file_get_contents($pathToTheme)); - $this->scandiPWAPackgeVersion = $packageData->version ?? false; + $packageData = json_decode(file_get_contents($pathToTheme), true); + $this->scandiPWAPackgeVersion = $this->getScandiPWAFromPackageData($packageData); } else { $this->scandiPWAPackgeVersion = false; } @@ -112,6 +112,18 @@ public function getScandiPWADirectoryPath() { return $themeDirectoryPath; } + /** + * @param $data + * @return string|false + */ + public function getScandiPWAFromPackageData($data) { + if (isset($data['dependencies']['@scandipwa/scandipwa'])) { + return $data['dependencies']['@scandipwa/scandipwa']; + } + + return $data['version'] ?? false; + } + /** * @return string|false */