For the frontend code as the original poster was using only one discount-code for the discount parameter as part of a cart/checout submission is used.
Checkout-scripts are another matter for shopify-plus stores
https://community.shopify.com/topic/1466239
bearing in mind checkout-scripts are being depreciated in 2024 in favor of shopify functions