Most products had an in-stock alternative - just a different size. For example: the 30 ml pack sold out and kept getting traffic from an AI Overview, while the 70 ml pack of the same product was fully available. Instead of leaving the shopper facing an empty shelf, we added a dynamic alternative button: it appears only when the product is out of stock, and points the shopper to the size or version that is in stock - on the same page, without breaking the buying experience.
Because we work directly in the code and the catalog, the fix was designed, tested and shipped the same day. From that moment, the traffic reaching sold-out pages - traffic paid for with months of SEO work - gets a path to purchase instead of a dead end.
So why not just redirect the shopper to another page?
It is the first question that comes up, and usually the wrong fix. A 301 redirect tells Google the page is gone permanently - so it erases the ranking the page built and its citation in AI engines, exactly the assets months of SEO created. But a stockout is almost always temporary, while a redirect is permanent: when the product returns, there is no ranked page left to come back to. On top of that, Google may read a redirect to a different product as irrelevant, treat it as a soft 404 and ignore it - and the shopper gets dumped on another page with no explanation. The dynamic button does the opposite: the page stays live and keeps its ranking and citation, the shopper gets a transparent choice, and when the product is back in stock the button disappears on its own - with nothing lost and nothing to clean up.