Empty cart script clears grouped product link
-
We use our Woocommerce for direct marketing, so we don’t use the shop, cart, etc. we use the Add to Checkout links from emails. e.g. /checkout/?add-to-cart=53007
We used the following script to stop people adding multiple products to their cart, e.g. someone clicks the link and doesn’t buy, then clicks the link again and there’s x2 in their cart.
add_action( 'woocommerce_add_cart_item_data', 'woocommerce_clear_cart_url' ); function woocommerce_clear_cart_url() { global $woocommerce; $woocommerce->cart->empty_cart(); }This works for Single Product Checkout links, but we sell more Grouped Products.
With a Grouped Product Checkout link, e.g. /checkout/?add-to-cart=53007&quantity[48582]=1&quantity[46646]=1&quantity[29667]=1, only 1 product from the group is in the checkout, the others have been removed by the above script.
Woo Support told me this is out of their remit and to try here.
Does anyone know how to edit this script, or even a better solution? Maybe a plugin that could do it (not CartFlows, we’ve tried that and had issues).
Any help appreciated. Thanks
The topic ‘Empty cart script clears grouped product link’ is closed to new replies.