Customizing the Initial Offer Incentive (IOI) using Shopify Scripts
Shopify Scripts are small pieces of code that let you create unique experiences for your customers in their cart and at checkout. Find out more here on Shopify Help Center articles.
Caution: Some aspects of this article may require technical expertise with coding languages.
If you do not currently have someone on staff or contract that can provide that level of technical assistance, Ordergroove suggests seeking out that level of support before attempting to add or alter any working code relating to your subscriptions or storefront.
Our script below is a starting point that allows you to give customers a percent or dollar amount off their subscription purchase. To get started, install the Shopify Script Editor app if you don't already have it.
Create a new script for "Line Items" and begin with a blank template:
Once you have that, you can add the following code. This script will give a customer a discount on the subscription item only for whatever percentage you set. You can change the discount_amount and the discount_message to whatever you'd like. If you'd like to change this further, we recommend using Shopify's excellent documentation on their Script Editor.
DISCOUNTS = [
discount_message: '25% off subscription products!'
def initialize(discount_type, discount_amount, discount_message)
@discount_type = discount_type
@discount_message = discount_message
@discount_amount = if discount_type == :percent
1 - (discount_amount * 0.01)
Money.new(cents: 100) * discount_amount
new_line_price = if @discount_type == :percent
line_item.line_price * @discount_amount
[line_item.line_price - (@discount_amount * line_item.quantity), Money.zero].max
line_item.change_line_price(new_line_price, message: @discount_message)
@discounts = discounts
@discounts.each do |discount|
discount_applicator = DiscountApplicator.new(
cart.line_items.each do |line_item|
CAMPAIGNS = [
CAMPAIGNS.each do |campaign|
Output.cart = Input.cart
Once you copied the code in, click on the Save and Publish button to complete it.
For further customizations to the above script, you can reference Shopify's excellent documentation on the Shopify Help Center. You'll find great examples of popular scripts and more that you can adapt and use with your subscription program.