How can I apply a discount that is applied to specific item in my catalogue which can be used in store POS and on our website?

So far I can only get a discount code but for the entire transaction and the code only works in the store POS and not on our website.

If it’s for a specific item, you can set up automatically applied discounts. These, by default, would work on Square POS. To get them to work on your website, you would need to use the Orders API to also trigger applying of automatic discounts (and optionally taxes).