ProductComparisonButton is the per-product action reusable that adds/removes items from the comparison list.Components/ProductSingle/Default.liquidReusables/ProductGridItem/Default.liquidReusables/ProductListItem/Default.liquidComponents/ProductSingle/Default.liquid:{% render 'Reusables\\ProductComparisonButton\\Default', id: product.id, title: product.title %}idtitletitle / aria-label.GlobalData.Settings.ShowProductComparisonx-data="productcomparisonbuttonreusabledefault.initComponent('{{ id }}')":class="` ${productExists ? 'active' : ''}`":disabled="isDisabled".isDisabled when the list is full and the current product is not already in the list.handleClick(...) and passes translated strings (and an HTML snippet that links to /comparison).{
"id": "Product Id",
"title": "Sample title"
}productcomparisondefault.comparisonListUpdated event to refresh its state.storage event when the comparisonSync key changes.productcomparisonbuttonreusabledefaultx-data="productcomparisonbuttonreusabledefault.initComponent('<productId>')"productExists, isListFull, isDisabled) derived from the comparison list.productcomparisondefault.getList().updateState().comparisonListUpdated (custom event)storage event for cross-tab sync (comparisonSync)storage listener keeps the button state in sync.productExists: whether the current id is in the listisListFull: whether list length is >= 8isDisabled: list is full AND the product is not in the listproductcomparisondefault.setList(this.list).comparisonListUpdated with a payload { id, timestamp }.$store.toast:removedProduct.addedProductAndListFull if list becomes exactly 8addedProductextraText, which contains the link to /comparison.extraText.extraText is HTML (includes an <a>). Ensure it is escaped/sanitized at the point it is constructed in Liquid.$store.toastadd(...) is called to show user feedback after add/remove.Reusables/ProductComparisonButton/Default.liquidReusables/ProductComparisonButton/Default.jsReusables/ProductComparisonButton/Default.jsonproductcomparisondefault (list storage helpers)$store.toast/comparison (used in the toast extra text)GlobalData.Settings.ShowProductComparison.updateState().title / aria-label includes title passed from Liquid, so send a human-readable product title.