Shopify discount function dynamic product

I’m writing an app that suggests users can buy a few more products and get a discount (bundle).

For example: When a user visits product A, I will have algorithms to recommend the trio of products B - C - D with a 10% discount. These 3 products B - C - D are not fixed and will follow the recomendation logic depending on each person, product,…

How can I implement discount function for this case?