Skip to content
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 pickup-in-store international domains and multi-language support #848

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

tjoyal
Copy link
Member

@tjoyal tjoyal commented Nov 3, 2021

Why are these changes introduced?

Fixes #548

As per the issue description, we must always use the current domain to issue an ajax call or otherwise a CORS issue will occur.

Additionally, the concatenation was not valid for multi-language use cases where the resulting url was not valid.

Demo links
URL: https://jp.defaultglobal.com/products/blue-silk-tuxedo
Generated XHR: https://defaultglobal.com/variants/31362180874262/?section_id=pickup-availability
Result:

Access to fetch at 'https://defaultglobal.com/variants/31362180874262/?section_id=pickup-availability' from origin 'https://jp.defaultglobal.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Screen Shot 2021-11-03 at 7 01 31 PM

URL: https://defaultglobal.com/en-fr/products/blue-silk-tuxedo
Generated XHR: https://defaultglobal.com/en-fr/en-frvariants/31362180874262/?section_id=pickup-availability
Result:

<div id="shopify-section-pickup-availability" class="shopify-section">
</div>

Checklist

@tjoyal tjoyal requested a review from cbothner November 3, 2021 23:13
@tjoyal tjoyal marked this pull request as ready for review November 3, 2021 23:20
cbothner
cbothner previously approved these changes Nov 4, 2021
assets/pickup-availability.js Outdated Show resolved Hide resolved
@tjoyal tjoyal requested a review from kostyl November 4, 2021 16:58
@kostyl kostyl requested a review from wroy November 4, 2021 17:20
wroy
wroy previously approved these changes Nov 4, 2021
@ludoboludo ludoboludo self-requested a review November 5, 2021 15:33
if (!rootUrl.endsWith("/")) {
rootUrl = rootUrl + "/";
}
const variantSectionUrl = `${rootUrl}variants/${variantId}/?section_id=pickup-availability`;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great from what I can tell. I noticed when testing this fix on the store mentioned in the issue that there is a conditional we need to add in order to display the proper information on the storefront.

In the renderPreview() function, we need to check if the button exists first before this.querySelector('button').addEventListener...

Maybe we can add an early return before if the button doesn't exist:

if (!this.this.querySelector('button')) return;

Let me know if you're ok with adding this fix in this PR as well, otherwise I can create a follow up issue and PR 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Let me know if you're ok with adding this fix in this PR as well, otherwise I can create a follow up issue and PR

I think since it is unrelated to the specific of the issue being solved here, I would prefer to have this shipped and iterated over.

I would also appreciate since you are offering to have you take over this specific change. I'm not familiar with the specifics of the JS enhancements in Dawn(in themes in general) to be confident as to the blast radius here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for sake of visibility, I've created the follow up PR about this issue here: #855

But nothing is needed, I requested reviews from my teammates.

@tjoyal tjoyal requested a review from cbothner November 8, 2021 16:53
@ludoboludo ludoboludo merged commit 24a5801 into main Nov 8, 2021
@ludoboludo ludoboludo deleted the fix-pickup-in-store branch November 8, 2021 18:10
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local pickup fails with CORS issue on non-primary domain
4 participants