Conversation
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
…-new-validation-hooks
…-new-validation-hooks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the plugin-ecommerce by moving cart logic to the server-side, adding new React hooks for cart/session management, fixing multiple bugs, and adding comprehensive translations for 40+ languages.
Changes:
- Cart operations moved to server-side REST API endpoints with MongoDB-style operators support
- New hooks:
onLogin,onLogout,clearSession,mergeCart,refreshCart,useEcommerceConfig - Bug fixes for guest checkouts, hardcoded collection slugs, addresses beforeChange hook, and type definitions
- Complete translation support added for 40+ languages with proper structure
Reviewed changes
Copilot reviewed 81 out of 82 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/scripts/src/generateTranslations/plugin-ecommerce.ts | New script for generating plugin translations |
| tools/scripts/package.json | Added generateTranslations:plugin-ecommerce command |
| test/plugin-ecommerce/int.spec.ts | Comprehensive integration tests for cart endpoints and operations |
| templates/ecommerce/src/components/product/Gallery.tsx | Fixed .toArray() implementation using Array.from() |
| packages/plugin-ecommerce/src/ui/VariantOptionsSelector/index.tsx | Fixed hardcoded collection slugs using field.custom |
| packages/plugin-ecommerce/src/types/index.ts | Updated CartItem.id type and added new types for cart operations |
| packages/plugin-ecommerce/src/translations/* | Added complete translation files for 40+ languages |
| packages/plugin-ecommerce/src/react/provider/index.tsx | Refactored cart operations to use server endpoints, added session management |
| packages/plugin-ecommerce/src/payments/adapters/stripe/confirmOrder.ts | Added cartsSlug parameter support |
| packages/plugin-ecommerce/src/index.ts | Exported cart operations and types |
| packages/plugin-ecommerce/src/endpoints/* | Updated to support cart secret via request context |
| packages/plugin-ecommerce/src/collections/variants/createVariantsCollection/index.ts | Added variantTypesSlug parameter |
| packages/plugin-ecommerce/src/collections/carts/operations/removeItem.ts | New server-side removeItem operation |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes several bugs reported here or on our Discord server as well as adds some new features to further improve some of the workflows and DX.
New React Hooks & Config
Added
useEcommerceConfighook and config property on the ecommerce context for accessing collection slugs and API settings. This will be used in the future in the template to ensure that collection slugs remain consistent across our components.onLoginhook to handle cart state after user authentication (merges guest cart with user's cart)onLogouthook to clear ecommerce session data during logoutclearSessionutility to reset all ecommerce state (cart, addresses, user)mergeCartutility for manually merging carts (useful for custom authentication flows)refreshCarthook to sync cart state with the serverCart logic is now server side
The cart logic has been moved to the server side and carts as a collection now have new REST API endpoints, this allows to provide better support for customising the flows and support additional logic, it also simplifies the React Context provider.
update-itemendpoint supports MongoDB-style{ $inc: number }operator for quantity changesupdate-itemendpoint hasremoveOnZerooption (defaults totrue)mergecan merge a new guest cart with a user's saved cart when logging inExample
Bug fixes
Documentation
Chores
customerFieldAccessfunction in favour ofisCustomerto improve clarity for how it's used - will be removed in V4Future enhancements
Once this PR is merged we can then allow automatic merging of carts if a user adds an item and then logs in, currently it will lose the previous guest cart.