• Resolved csesupport

    (@csesupport)


    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not seen any activity on this thread for a while, so I’m marking this thread as resolved.

    Hopefully, you were able to come up with a solution and the above resources were helpful. If you have further questions, please feel free to open a new topic.

    Thanks.

    Thread Starter csesupport

    (@csesupport)

    It’s not resolved and I’m still hoping for a solution. I’ve posted on the Facebook group too

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Empty cart script clears grouped product link’ is closed to new replies.