Skip to content

Commit

Permalink
Remove hardcoded API version from JS client (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Jan 29, 2025
1 parent 4abeec9 commit 4e06d70
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion resources/js/shopify/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createStorefrontApiClient } from '@shopify/storefront-api-client';
*/
const client = createStorefrontApiClient({
storeDomain: window.shopifyConfig.url,
apiVersion: '2024-04',
apiVersion: window.shopifyConfig.apiVersion ?? '2024-07',
publicAccessToken: window.shopifyConfig.token,
});

Expand Down
2 changes: 1 addition & 1 deletion src/Tags/Shopify.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function productPrice()
public function tokens()
{
return "<script>
window.shopifyConfig = { url: '".(config('shopify.storefront_url') ?? config('shopify.url'))."', token: '".config('shopify.storefront_token')."' };
window.shopifyConfig = { url: '".(config('shopify.storefront_url') ?? config('shopify.url'))."', token: '".config('shopify.storefront_token')."', apiVersion: '".(config('shopify.api_version') ?? '2024-07')."' };
</script>";
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/TagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function outputs_shopify_tokens()
config()->set('shopify.storefront_token', '1234');

$this->assertEquals(str_replace(["\r", "\n"], '', "<script>
window.shopifyConfig = { url: 'abcd', token: '1234' };
window.shopifyConfig = { url: 'abcd', token: '1234', apiVersion: '2024-07' };
</script>"),
str_replace(["\r", "\n"], '', $this->tag('{{ shopify:tokens }}'))
);
Expand Down

0 comments on commit 4e06d70

Please sign in to comment.