Skip to content

Instantly share code, notes, and snippets.

@gil--

gil--/script.rb Secret

Created October 16, 2022 16:07
Embed
What would you like to do?
BLOCK_ID = "631f8edae5f9ce785673920c" # Replace with block id
DISCOUNT = 0.90
DISCOUNT_MESSAGE = "Checkout offer"
Input.cart.line_items.each do |line_item|
next unless line_item.properties.has_key?("_checkoutblocks")
next unless line_item.properties.has_value?(BLOCK_ID)
line_item.change_line_price(line_item.line_price * DISCOUNT, message: DISCOUNT_MESSAGE)
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment