From dc2388458f86d388b766520c86ab8dd6b505828a Mon Sep 17 00:00:00 2001 From: PaulLiamAG <43734176+PaulLiamAG@users.noreply.github.com> Date: Fri, 23 Aug 2019 04:38:19 +0100 Subject: [PATCH] Updated the logic to resemble the readme The original code was using any? but it needed to use all? in order to verify all the line items had the tag before adding free shipping. --- Shipping/Free shipping for certain products/script.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shipping/Free shipping for certain products/script.rb b/Shipping/Free shipping for certain products/script.rb index cb6ee61..85779bf 100644 --- a/Shipping/Free shipping for certain products/script.rb +++ b/Shipping/Free shipping for certain products/script.rb @@ -1,6 +1,6 @@ FREE_TAG = 'freeship' -if Input.cart.shipping_address.country_code == 'US' && Input.cart.line_items.any?{|item| item.variant.product.tags.include? FREE_TAG} +if Input.cart.shipping_address.country_code == 'US' && Input.cart.line_items.all?{|item| item.variant.product.tags.include? FREE_TAG} Input.shipping_rates.each do |shipping_rate| next if shipping_rate.price == Money.zero shipping_rate.apply_discount(shipping_rate.price, message: "Free Shipping!")