How to add a discount

When using blocks within checkout, you can leverage the Shopify Script Editor app to add discounts to products added via a checkout block. Please note that discounting behavior works differently for post purchase blocks.

Simply target any line item based on the following property:

Key: _checkoutblocks

Value: Your Block ID

Example Script

The following script can be found here:

BLOCK_ID = "631f8edae5f9ce785673920c" # Replace with block id
DISCOUNT_MESSAGE = "Checkout offer"

Input.cart.line_items.each do |line_item|
  next unless"_checkoutblocks")
  next unless
  line_item.change_line_price(line_item.line_price * DISCOUNT, message: DISCOUNT_MESSAGE)

Output.cart = Input.cart


  • Currently the discounted price does not show in the block. We are working on adding a setting to enable this by end of March.
  • The discount has the same limitations as any discount that uses Shopify scripts.
  • You may want to add a quantity check to prevent abuse from customers changing the quantity in cart. 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us