正在处理一个脚本,如果使用代码“FREESHIP”,则该脚本适用于特定运输方式的免费送货。当我尝试编写此脚本时,我收到一条错误消息:
Discount code requirements not met (Your cart)
Discount code requirements not met (Empty cart)
Discount code requirements not met (No customer)
我正在使用的代码:
Input.shipping_rates.each do |shipping_rate|
if (shipping_rate.source == "fedex" && shipping_rate.code == 'FEDEX_GROUND') || (shipping_rate.source == 'usps' && shipping_rate.code == 'Priority')
if Input.cart.discount_code && Input.cart.discount_code == "FREESHIP"
shipping_rate.apply_discount(shipping_rate.price * 1, message: "Discounted shipping")
end
end
end
Output.shipping_rates = Input.shipping_rates
答案 0 :(得分:0)
如果您换掉购物车中的物品和/或添加应解决此问题的客户,则您尝试使用的折扣代码似乎不是购物车中物品的有效代码。