get_stock_quantity() on a never-managed product returns 0, which equaled BC's inventory for out-of-stock items, so the "did the value change?" guard treated it as no-op and never called set_manage_stock(true). The product was left at WooCommerce's default stock_status of "instock" with no quantity tracked - looked fine for in-stock items (real quantity forced the block to run) but silently wrong for anything actually out of stock. Now also runs whenever stock isn't managed yet, regardless of whether the value looks unchanged. Also enables manage_stock at product creation time so newly created products never sit in that ambiguous state to begin with. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37 KiB
37 KiB