Thank you for your response
I added a code to WooCommerce to control the number of purchases of the user’s product.
The only part that I have a problem with that does not work is the part that is done by ajax.
And I felt that you wrote your own function for the theme and did not use WooCommerce functions.
Do you have a suggestion that can help me in this matter?