'Custom discount rule in WooCommerce

In WooCommerce (WordPress) I have a bundle which contains product A and product B and I set it to add to cart separately (When adding this bundle to cart, product A and B will be added to cart separately). I wish to implement discount like this: If 1 bundle added to cart, then %20 discount will be added to each product A and B, and if the customers changes both of them into 2 or 3 or ..., still gets 20% on these 2 products, but, if the customer for example adds 1 bundle then changes the number of product B into 2 (1 product A and 2 product B), then gets a %20 discount on 1 product A and 1 product B, and %0 discount on the second product B, again, if the number of product A changes into 2, then the %20 discount will be added to both of them.

I know I explained a little confusing 😅

How can I do that? I used WooCommerce Discount Rules (FlyCart) but couldn't find a solution to create desired rule.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source