我需要拒绝折扣,但我也希望只适用于某些产品的折扣金额。
例如:我的购物车是A,B,我有10%的订单折扣。我不想B产品打折,但我只想打折A,我的方法是这样
if cart.discount_code&.percentage
discount = cart.discount_code.percentage / 100.0
discount = 1.0 - discount.to_s.to_f # there's probably a better way to do this... but :)
cart.line_items.each do |line_item|