I am trying to write a script to create a buy 3 units and get 20% off these three units. (The product IDs 6250082822 or 6250082566 ) The script below works to take 20% off 3 units if the line item is the same product ID and colour. But what I'd like to do is allow this discount to be applied accross the two product IDs and colour variations.
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
next unless line_item.quantity == 3
next unless product.id == 6250082822 or 6250082566
line_item.change_line_price(line_item.line_price * 0.80, message: "20% bundle discount")