Hide sold-out products from profile when 'Hide sold out versions' is enabled#4375
Hide sold-out products from profile when 'Hide sold out versions' is enabled#4375
Conversation
|
@gumclaw any spec updates/additions needed? |
|
Looked through the diff and the existing spec file. A few things to tighten up: 1. products = products.reject { |product| product.hide_sold_out_variants? && product.remaining_for_sale_count == 0 }
cached_props[:search_results][:total] = products.size2. Should sellers still see their own sold-out products? products = products.reject { |product| product.hide_sold_out_variants? && product.remaining_for_sale_count == 0 } unless is_owner3. Potential N+1 for bundles 4. No test coverage
|
|
@gumclaw fix all of those issues, and upon green build re-assign to me to review. |
…abled When a seller enables 'Hide sold out versions' on a product, sold-out variants are hidden in the product page configuration selector. But the product itself still appeared on the seller's profile page even when all variants were sold out (remaining_for_sale_count == 0). Now the profile sections presenter filters out products that have hide_sold_out_variants enabled AND remaining_for_sale_count == 0. Fixes #4367
…nd tests - Gate sold-out filtering on non-owner view so sellers still see their own sold-out products - Update search_results[:total] after filtering to match actual product count - Eager load bundle_products associations to prevent N+1 in remaining_for_sale_count - Add specs covering non-owner exclusion, owner inclusion, and in-stock retention Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5867ed9 to
fb78381
Compare
🤖 Gumclaw Local Spec RunSpecs run: All specs pass, including the new sold-out product filtering specs added in this PR. |
Problem
When a seller enables 'Hide sold out versions' on a product, the individual variant options are hidden on the product page. But the product card itself still appears on the seller's profile, even when all variants/stock are sold out (
remaining_for_sale_count == 0).This means customers see products on the profile, click into them, and then discover they can't buy anything. As the reporter (MillionairePaul.Gumroad.com) noted: 'if I had only 1 product left from 6 they would only find the available one by trial and error.'
Fix
Filter out products in
ProfileSectionsPresenterwherehide_sold_out_variants?is true ANDremaining_for_sale_count == 0. Simple one-line filter in the presenter, no search index changes needed.Context
The quantity display was intentionally removed from profile cards for performance (
compute_inventory: false). This fix doesn't change that. Instead, it removes sold-out products entirely when the seller has opted into hiding sold-out variants.Fixes #4367