Retrieve entered quantity in custom liquid block

Thanks a lot!

Where do I need to place the first code block exactly?

And second question:

In case I just wanted to have a variable {{ selectedQuantity }} available in the custom liquid code block, so that I can generate the message from there based on some checks, would that also be possible?