Format post URL with multiple of the same input types

I have a form with multiple of the same input fields with the same names like this:

<form method="post" enctype="multipart/form-data">
    <input type="number" step="1" min="1" max="" name="quantity" value="1" title="Quantity" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric">
    <input type="hidden" name="add-to-cart" value="<?php echo get_the_ID(); ?>">

    <input type="number" step="1" min="1" max="" name="quantity" value="1" title="Quantity" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric">
    <input type="hidden" name="add-to-cart" value="<?php echo get_the_ID(); ?>">
</form>

I need my post-url to look something like this: “example.com?add-to-cart=5555,6666&quantity=5,6”.
5555 and 6666 is the data from the input field “add-to-cart”
5 and 6 is the data from the input field “quantity”.

What’s the easiest way to do this?