Add used-product flag for store listings.
Merchants can mark items as used on create/edit, see a used badge on cards, and filter the store list for used products. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
32f0dbab63
commit
61d145d92e
@@ -6,6 +6,7 @@ export interface StoreListingFilters {
|
||||
minPrice: number | null
|
||||
maxPrice: number | null
|
||||
onlyDiscounted: boolean
|
||||
onlyUsed: boolean
|
||||
}
|
||||
|
||||
export const EMPTY_STORE_LISTING_FILTERS: StoreListingFilters = {
|
||||
@@ -13,6 +14,7 @@ export const EMPTY_STORE_LISTING_FILTERS: StoreListingFilters = {
|
||||
minPrice: null,
|
||||
maxPrice: null,
|
||||
onlyDiscounted: false,
|
||||
onlyUsed: false,
|
||||
}
|
||||
|
||||
function listingEffectivePrice(listing: StoreProductListing): number | null {
|
||||
@@ -50,6 +52,10 @@ export function filterStoreListings(
|
||||
if (!hasDiscount) return false
|
||||
}
|
||||
|
||||
if (filters.onlyUsed && !listing.isUsed) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface StoreProductListing {
|
||||
displayPrice: number | null
|
||||
displayDiscountedPrice: number | null
|
||||
showFestival: boolean
|
||||
isUsed: boolean
|
||||
}
|
||||
|
||||
function effectivePrice(item: StoreItem): number | null {
|
||||
@@ -103,6 +104,7 @@ export function groupStoreItemsByProduct(
|
||||
showFestival: sorted.some(
|
||||
(variant) => variant.isFestival || (variant.rewardPoints ?? 0) > 0,
|
||||
),
|
||||
isUsed: sorted.some((variant) => variant.isUsed),
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ function specialStoreItemToVariants(item: StoreSpecialStoreItem): StoreItem[] {
|
||||
stockQuantity: variant.stockQuantity,
|
||||
rewardPoints: variant.rewardPoints,
|
||||
isFestival: variant.isFestival,
|
||||
isUsed: item.isUsed ?? false,
|
||||
sortOrder: variant.sortOrder,
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
@@ -55,6 +56,7 @@ function listingFromStoreItemWithoutVariants(
|
||||
stockQuantity: null,
|
||||
rewardPoints: null,
|
||||
isFestival: false,
|
||||
isUsed: item.isUsed ?? false,
|
||||
sortOrder: item.sortOrder,
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
@@ -72,6 +74,7 @@ function listingFromStoreItemWithoutVariants(
|
||||
displayPrice: null,
|
||||
displayDiscountedPrice: null,
|
||||
showFestival: false,
|
||||
isUsed: item.isUsed ?? false,
|
||||
storeItemId: item.id,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user