-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix add-to-cart session event in Live View #614
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7d4fd76
Fix ATC event in Live View
wizardlyhel 13009d5
add changeset
wizardlyhel 1e036af
make sure other templates also passes in request
wizardlyhel 6cd5922
use headers instead
wizardlyhel ffd7c3e
make it not breaking change
wizardlyhel b016fc2
test env
wizardlyhel 9a7f908
test hard code domain
wizardlyhel 18e76e3
remove turbo cache
wizardlyhel a2e6ceb
log the right thing
wizardlyhel 2a35b9b
revert test codes
wizardlyhel 75e69f3
Merge remote-tracking branch 'origin/2023-01' into hl-fix-atc-live-view
wizardlyhel 27cd462
address feedbacks
wizardlyhel 29b714b
fix in other templates
wizardlyhel 5491f0b
export cart constants
wizardlyhel 79a3e92
remove props
wizardlyhel fb3347f
remove console log
wizardlyhel 2f0b14f
Update packages/hydrogen/src/storefront.ts
wizardlyhel 2bd49ba
Update packages/hydrogen/src/storefront.ts
wizardlyhel d00e454
Update packages/remix-oxygen/src/server.ts
wizardlyhel 588a6bd
lint
wizardlyhel b282a6f
fix type
wizardlyhel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
'@shopify/hydrogen-react': patch | ||
'@shopify/remix-oxygen': patch | ||
'@shopify/hydrogen': patch | ||
--- | ||
|
||
Fix active cart session event in Live View | ||
|
||
Introducing `getStorefrontHeaders` that collects the required Shopify headers for making a | ||
Storefront API call. | ||
|
||
- Make cart constants available as exports from `@shopify/hydrogen-react` | ||
- Deprecating `buyerIp` and `requestGroupId` props from `createStorefrontClient` from `@shopify/hydrogen` | ||
- Deprecating `getBuyerIp` function from `@shopify/remix-oxygen` | ||
|
||
```diff | ||
+ import {getStorefrontHeaders} from '@shopify/remix-oxygen'; | ||
import {createStorefrontClient, storefrontRedirect} from '@shopify/hydrogen'; | ||
|
||
export default { | ||
async fetch( | ||
request: Request, | ||
env: Env, | ||
executionContext: ExecutionContext, | ||
): Promise<Response> { | ||
|
||
const {storefront} = createStorefrontClient({ | ||
cache, | ||
waitUntil, | ||
- buyerIp: getBuyerIp(request), | ||
i18n: {language: 'EN', country: 'US'}, | ||
publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, | ||
privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, | ||
storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, | ||
storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-01', | ||
storefrontId: env.PUBLIC_STOREFRONT_ID, | ||
- requestGroupId: request.headers.get('request-id'), | ||
+ storefrontHeaders: getStorefrontHeaders(request), | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export const STOREFRONT_REQUEST_GROUP_ID_HEADER = | ||
'Custom-Storefront-Request-Group-ID'; | ||
export const STOREFRONT_API_BUYER_IP_HEADER = 'Shopify-Storefront-Buyer-IP'; | ||
export const STOREFRONT_ID_HEADER = 'Shopify-Storefront-Id'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I guess
storefrontHeaders
will still be optional, perhaps better to warn only when the other properties are used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially was gonna detect by
buyerIp
andrequestGroupId
.. but both of these are null in dev modeand .. don't we need to have one or the other?