https://shopify.dev/docs/apps/checkout/product-offers/pre-purchase/getting-started
Following this direction, I created “pre-purchase product offers”. I want to ensure that only the specific products I desire are displayed instead of appearing randomly. Please assist me if this is possible.
Hi Unidatnj,
if you want to filter the product in pre-purchase, you can always use product tag as a filter. In above mentioned doc code, in filter section and line code . please see the below code and compare with your.
Hope this will resolve your problem.
// Get the IDs of all product variants in the cart
const cartLineProductVariantIds = lines.map((item) => item.merchandise.id);
// Filter out any products on offer that are already in the cart and have the "featured" tag
const productsOnOffer = products.filter(
(product) => {
const isProductVariantInCart = product.variants.nodes.some(
({ id }) => cartLineProductVariantIds.includes(id)
);
return !isProductVariantInCart && product.tags.includes('featured');
// Filter based on the "featured" tag
}
);