|
| 1 | +--- |
| 2 | +"@bigcommerce/catalyst-core": patch |
| 3 | +--- |
| 4 | + |
| 5 | +Filter out child cart items (items with `parentEntityId`) from cart and cart analytics to prevent duplicate line items when products have parent-child relationships, such as product bundles. |
| 6 | + |
| 7 | +## Migration steps |
| 8 | + |
| 9 | +### Step 1: GraphQL Fragment Updates |
| 10 | + |
| 11 | +The `parentEntityId` field has been added to both physical and digital cart item fragments to identify child items. |
| 12 | + |
| 13 | +Update `core/app/[locale]/(default)/cart/page-data.ts`: |
| 14 | + |
| 15 | +```diff |
| 16 | + export const PhysicalItemFragment = graphql(` |
| 17 | + fragment PhysicalItemFragment on CartPhysicalItem { |
| 18 | + entityId |
| 19 | + quantity |
| 20 | + productEntityId |
| 21 | + variantEntityId |
| 22 | ++ parentEntityId |
| 23 | + listPrice { |
| 24 | + currencyCode |
| 25 | + value |
| 26 | + } |
| 27 | + } |
| 28 | + `); |
| 29 | + |
| 30 | + export const DigitalItemFragment = graphql(` |
| 31 | + fragment DigitalItemFragment on CartDigitalItem { |
| 32 | + entityId |
| 33 | + quantity |
| 34 | + productEntityId |
| 35 | + variantEntityId |
| 36 | ++ parentEntityId |
| 37 | + listPrice { |
| 38 | + currencyCode |
| 39 | + value |
| 40 | + } |
| 41 | + } |
| 42 | + `); |
| 43 | +``` |
| 44 | + |
| 45 | +### Step 2: Cart Display Filtering |
| 46 | + |
| 47 | +Cart line items are now filtered to exclude child items when displaying the cart. |
| 48 | + |
| 49 | +Update `core/app/[locale]/(default)/cart/page.tsx`: |
| 50 | + |
| 51 | +```diff |
| 52 | + const lineItems = [ |
| 53 | + ...cart.lineItems.giftCertificates, |
| 54 | + ...cart.lineItems.physicalItems, |
| 55 | + ...cart.lineItems.digitalItems, |
| 56 | +- ]; |
| 57 | ++ ].filter((item) => !('parentEntityId' in item) || !item.parentEntityId); |
| 58 | +``` |
| 59 | + |
| 60 | +### Step 3: Analytics Data Filtering |
| 61 | + |
| 62 | +Analytics data collection now only includes top-level items to prevent duplicate tracking. |
| 63 | + |
| 64 | +Update `core/app/[locale]/(default)/cart/page.tsx` in the `getAnalyticsData` function: |
| 65 | + |
| 66 | +```diff |
| 67 | +- const lineItems = [...cart.lineItems.physicalItems, ...cart.lineItems.digitalItems]; |
| 68 | ++ const lineItems = [...cart.lineItems.physicalItems, ...cart.lineItems.digitalItems].filter( |
| 69 | ++ (item) => !item.parentEntityId, // Only include top-level items |
| 70 | ++ ); |
| 71 | +``` |
| 72 | + |
| 73 | +### Step 4: Styling Update |
| 74 | + |
| 75 | +Cart subtitle text color has been updated for improved contrast. |
| 76 | + |
| 77 | +Update `core/vibes/soul/sections/cart/client.tsx`: |
| 78 | + |
| 79 | +```diff |
| 80 | +- <span className="text-[var(--cart-subtext-text,hsl(var(--contrast-300)))] contrast-more:text-[var(--cart-subtitle-text,hsl(var(--contrast-500)))]"> |
| 81 | ++ <span className="text-[var(--cart-subtext-text,hsl(var(--contrast-400)))] contrast-more:text-[var(--cart-subtitle-text,hsl(var(--contrast-500)))]"> |
| 82 | + {lineItem.subtitle} |
| 83 | + </span> |
| 84 | +``` |
0 commit comments