Conditionally adding or removing a free product in cart
问题 I've a function in woocommerce that add automatically to cart a free gift. I would like to add this based on minimum quantity of 15 i've this code that works, but when i update the cart don't remove the item if the quantity is not 15. How I can automatic remove product when I update the cart if total id different to 15 ? } //add_action( 'init', 'wcsg_add_product_to_cart' ); add_action( 'wp_loaded', 'wcsg_add_product_to_cart', 99 ); function wcsg_add_product_to_cart() { if ( ! is_admin() ) {