Skip to content

Instantly share code, notes, and snippets.

@tom-it
Created April 17, 2019 12:38
Show Gist options
  • Save tom-it/24fae93640b86f9df0240bf4d7b2eed4 to your computer and use it in GitHub Desktop.
Save tom-it/24fae93640b86f9df0240bf4d7b2eed4 to your computer and use it in GitHub Desktop.
remove shipping option
puts('loop over all line_items, and check if one has weight over 50 lbs')
overWeight = false
Input.cart.line_items.each do |line_item|
if line_item.grams > 22679
overWeight = true
end
end
if overWeight
Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate|
(shipping_rate.name == 'Your Shipping rate name to remove')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment