Applying discount codes in the cart (prior to checkout)

Shopify doesn’t allow to process discounts in checkout directly. There is no API to apply a discount code. There is workaround with making ajax call to checkout page but it’s quite complicated.

I was searching for liquid code to achieve that and stumbled upon an app. It works perfectly with cart drawer and cart page. Here is how my drawer now looks like:

https://apps.shopify.com/discount-in-cart