WooCommerce "Remove from cart" links are prefetched/preloaded in Speculative Loading #1141
Labels
[Plugin] Speculative Loading
Issues for the Speculative Loading plugin (formerly Speculation Rules)
[Type] Bug
An existing feature is broken
Bug Description
WooCommerce has a mini-cart that appears in the header. It has an ✖️ button (actually a link) to remove an item from the cart. Unfortunately Speculative Loading's speculation rules are preloading/prefetching the URL, resulting in the product being removed unexpectedly:
Screen.recording.2024-04-15.12.54.28.webm
Steps to reproduce
Additional Context
Here is the source code for the remove-from-cart button: https://github.com/woocommerce/woocommerce/blob/a8e84d8c8b20558f66ed33dcbee6c1dec300752f/plugins/woocommerce/templates/cart/mini-cart.php#L46-L60
The
wc_get_cart_remove_url()
function, importantly, returns a URL that includes a_wpnonce
(added viawp_nonce_url()
). An example remove-from-cart link:The speculation rules used for the plugin should exclude URLs with
_wpnonce
by default. This was previously brought up in #733 (comment).The text was updated successfully, but these errors were encountered: