如果使用代码“FREESHIP”,m 正在编写一个脚本,该脚本在特定的运输方式上应用免费送货。当我尝试编写此脚本时,我收到一条错误消息:
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