I want to validate the total quantity for grouped products.. i’ve tried a hook

add_filter( 'woocommerce_add_to_cart_validation', 'woocommerce_add_to_cart_validations', 10, 4);
function woocommerce_add_to_cart_validations( $valid, $product_id, $quantity) {

    if ($product_id->is_type('grouped') && $quantity % 7 != 0) {
        wc_add_notice( __( 'Multiple of 7 required quantity.', 'woocommerce' ), 'error' );
        $valid = false;
    }
    return $valid;
}

but that checks for each product

Read more here: Valid total quantity of grouped products on Woocommerce


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: