chore: transfer repo
This commit is contained in:
22
components/cart/processCartItems.tsx
Normal file
22
components/cart/processCartItems.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
// Function to get a unique identifier for a cart item
|
||||
export function getUniqueItemKey(item: any, boxGroupId?: string, index?: number): string {
|
||||
// Start with the merchandise id
|
||||
let key = item.merchandise.id;
|
||||
|
||||
// Add the item's own id if available
|
||||
if (item.id) {
|
||||
key = `${key}-${item.id}`;
|
||||
}
|
||||
|
||||
// Add box group id if it's part of a box
|
||||
if (boxGroupId) {
|
||||
key = `${boxGroupId}-${key}`;
|
||||
}
|
||||
|
||||
// Add index as fallback to ensure uniqueness
|
||||
if (index !== undefined) {
|
||||
key = `${key}-${index}`;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
Reference in New Issue
Block a user