how to set discount for shop when customer buy two item?

when customer buy 2 the same product how to add discount for cart for example 20%
and/or when customer buy 2 product for the same category other discount, how to do that?

Replies are visible only to logged in members with an active subscription.