diff --git a/config/shortcode-plus.php b/config/shortcode-plus.php index 11d134a..a58cc55 100644 --- a/config/shortcode-plus.php +++ b/config/shortcode-plus.php @@ -40,7 +40,7 @@ 'text' => 'Questo contenuto è ospitato su una piattaforma esterna. Per visualizzarlo, è necessario accettare i cookie', ], 'widgetbay' => [ - 'endpoint' => 'https://widgetbay.3labs.it/widgetbox', + 'endpoint' => 'https://widgetbay.3labs.it', ], 'linksToParse' => [ diff --git a/src/Shortcodes/WidgetbayShortcode.php b/src/Shortcodes/WidgetbayShortcode.php index 4585934..384312d 100644 --- a/src/Shortcodes/WidgetbayShortcode.php +++ b/src/Shortcodes/WidgetbayShortcode.php @@ -6,7 +6,7 @@ class WidgetbayShortcode { public function register($shortcode) { - $endpoint = config('shortcode-plus.widgetbay.endpoint'); + $endpoint = config('shortcode-plus.widgetbay.endpoint').'/widgetbox'; $widgetbayLink = ''; $heightListClass = null; @@ -41,8 +41,13 @@ public function register($shortcode) protected function calculateIframeHeight($products, $layout = null) { - $products = explode(',', $products); - $count = count($products); + $endpoint = config('shortcode-plus.widgetbay.endpoint').'/api/widgetbox-count-available-products?link='.$products; + + //create HTTP request + $request = new \GuzzleHttp\Client; + $response = $request->get($endpoint); + $count = json_decode($response->getBody()->getContents(), true); + $prefix = $layout === 'hero' ? 'shortcode_widgetbay_list_hero_' : 'shortcode_widgetbay_list_'; if ($count > 1) { @@ -51,4 +56,9 @@ protected function calculateIframeHeight($products, $layout = null) return null; } + + protected function checkIfProductIsAvailable($product) + { + return $product->isAvailable(); + } }