Ecwid Provider, Shopping Bag, Product Browser views parameter #8
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.
Hello!
I'm not sure if you're open to pull requests or if I should make an issue and link to the branch first. Let me know if I should open an issue instead.
This pull request includes changes that:
Along with moving Ecwid loading into the Provider, I rewrote the initialization of the three components to wait for API Ready (via Provider state variable) and then call their respective initialization functions. This seems to work well in my testing so far, but I've only tried with app router.
My gut also tells me that the document.body.appendChild should be removed and the whole process of injecting ecwid's script needs to be made more react/next friendly, but this is what I was able to get to so far and has solved my immediate problem of needing store + cart.
I've also updated the README.md file to include instructions on how to use it via Wrapping the included EcwidProvider component in a client component, and then wrapping your store page in that. This works with app router for me, but I haven't tested with pages router.