Exclude Product from All Coupon Codes - Empty Cart Error

Highlighted
New Member
10 0 0

We have a couple products that we do not discount but it's hard to exclude those items from email generated coupon codes. I found a script to that someone used during the holidays to reject all coupons and I thought I would modify but I keep getting an "Empty Cart" error. Any help with fixing this to work? 

Input.cart.line_items.each do |line_item|
product = line_item.variant.product
  if Input.cart.discount_code && product.id == 384805376
     Input.cart.discount_code.reject(
    message: "Maximum discount already applied! Discount codes can not be used during this promotion."
  )
end
Output.cart = Input.cart

 

0 Likes