Discount product B if product A is in the cart
This WooCommerce snippet checks the cart for two specific products. If both are present, it applies a discount to one of them based on its price and quantity. The discount is added as a negative fee during cart calculation. The code avoids running in the admin area unless it’s an AJAX request, and can be…

