Skip to content

Hide sold-out products from profile when 'Hide sold out versions' is enabled#4375

Open
gumclaw wants to merge 2 commits intomainfrom
fix/hide-sold-out-products-on-profile
Open

Hide sold-out products from profile when 'Hide sold out versions' is enabled#4375
gumclaw wants to merge 2 commits intomainfrom
fix/hide-sold-out-products-on-profile

Conversation

@gumclaw
Copy link
Copy Markdown
Contributor

@gumclaw gumclaw commented Apr 8, 2026

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 ProfileSectionsPresenter where hide_sold_out_variants? is true AND remaining_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

@slavingia
Copy link
Copy Markdown
Contributor

@gumclaw any spec updates/additions needed?

@gumclaw
Copy link
Copy Markdown
Contributor Author

gumclaw commented Apr 8, 2026

Looked through the diff and the existing spec file. A few things to tighten up:

1. total count will be wrong after filtering
cached_props[:search_results][:total] is set before the reject, so the total won't match the actual products returned. If the frontend uses that for pagination or "X products" display, it'll be off. Should update total after filtering:

products = products.reject { |product| product.hide_sold_out_variants? && product.remaining_for_sale_count == 0 }
cached_props[:search_results][:total] = products.size

2. Should sellers still see their own sold-out products?
The filter runs for both owner and visitor views. The seller probably wants to see their sold-out products on their own profile (for management). Consider gating this on !is_owner:

products = products.reject { |product| product.hide_sold_out_variants? && product.remaining_for_sale_count == 0 } unless is_owner

3. Potential N+1 for bundles
remaining_for_sale_count calls bundle_products.alive (and their associated products/variants), which isn't included in ASSOCIATIONS_FOR_CARD. For bundle products with hide_sold_out_variants enabled, this could trigger extra queries per product.

4. No test coverage
profile_sections_presenter_spec.rb has no specs for this filtering. Would be good to add at least:

  • Product with hide_sold_out_variants + remaining_for_sale_count == 0 is excluded for visitors
  • Same product still appears for the owner
  • Product with hide_sold_out_variants but stock remaining is NOT excluded

@slavingia
Copy link
Copy Markdown
Contributor

@gumclaw fix all of those issues, and upon green build re-assign to me to review.

gumclaw and others added 2 commits April 8, 2026 15:25
…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>
@gumclaw gumclaw force-pushed the fix/hide-sold-out-products-on-profile branch from 5867ed9 to fb78381 Compare April 8, 2026 19:25
@gumclaw
Copy link
Copy Markdown
Contributor Author

gumclaw commented Apr 9, 2026

🤖 Gumclaw Local Spec Run

Specs run: spec/presenters/profile_sections_presenter_spec.rb
Results: 7 examples, 0 failures ✅

All specs pass, including the new sold-out product filtering specs added in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Product quantities not showing today

2 participants