I am trying to set a discount for when BOTH products are in the cart no matter what other products are also in there.
As of now, all it takes is one of the two within the array.
add_action( 'woocommerce_cart_calculate_fees', 'discount_for_ab_products' );
function discount_for_ab_products( $cart ) {
$product_ids = array(34,35);
foreach ($product_ids as $product_id => $product) {
$product_cart_id = WC()->cart->generate_cart_id( $product );
$product_ab_in_cart = WC()->cart->find_product_in_cart( $product_cart_id );
if ( $product_ab_in_cart ) {
$discount = $cart->subtotal * 0.1;
$cart->add_fee( __( 'Discount', 'woocommerce' ) , -$discount );
}
}
}