jeudi 15 septembre 2016

PHP: How to check if at least 2 checkboxes are marked in order to continue?

How to require at least 2 checkboxes to be checked in order to continue? I have the following php:

/**
     * check_required_addons function.
     *
     * @access private
     * @param mixed $product_id
     * @return void
     */
    private function check_required_addons( $product_id ) {
        $addons = get_product_addons( $product_id, false, false, true ); // No parent addons, but yes to global

        if ( $addons && ! empty( $addons ) ) {
            foreach ( $addons as $addon ) {
                if ( '1' == $addon['required'] ) {
                    return true;
                }
            }
        }

        return false;
    }

Where $addons = array(); and within this array there are the checkboxes. How to check at least 2 checkboxes to be marked in order to continue?




Aucun commentaire:

Enregistrer un commentaire