Integrate Bundle Discounts with Script Editor (Shopify Plus)

Revy Bundles has a special and unique integration with Script Editor App by Shopify, this app works just with Shopify Plus customers at the moment.

This integration allows customers to have Bundle Discounts in their carts and also add another discount code, this is only possible because Shopify Plus customers have this special app that allows developers to write custom codes that can modify the customer's cart programmatically.

To setup this integration you need to follow this 3 steps:

Add Bundle code in the Script Editor

1.Open the Script Editor app (install the app HERE if you don't have it):

2. Create a new Script called "Revy Bundle Script"

3. Select the "Online Store only" channel and paste the code below in the code editor:

Here is the code:

# Version 2
DISCOUNT_MESSAGE = "Bundle Discount"
LINE_PROPERTY_KEY = "_rb" # DO NOT MODIFY THIS


def get_discount_value_from_item(line_item)
  property = 
    line_item.properties.find do |key, value|
      key == LINE_PROPERTY_KEY
    end
  property ? property[1].to_i : false
end


def change_line_item_price(line_item, discount)
  discount = Money.derived_from_presentment(customer_cents: discount)
  new_price = line_item.line_price - discount
  line_item.change_line_price(new_price, message: DISCOUNT_MESSAGE)
end


def remove_revy_bundle_property(line_item)
  new_properties = line_item.properties
  new_properties.delete(LINE_PROPERTY_KEY)
  line_item.change_properties(new_properties, message: "")
end


Input.cart.line_items.each do |line_item|
  discount = get_discount_value_from_item(line_item)
  if discount && !line_item.line_price_changed?
    change_line_item_price(line_item, discount)
    remove_revy_bundle_property(line_item)
  end
end


Output.cart = Input.cart

Save the file and publish.

Add reload code on revy-bundle-script.liquid

Your theme should have a file called revy-bundle-script.liquid, open this file and add this line below inside the window.revyBundleThemeSettings:

reloadOnLineItemProperties: true

The final file code will look like this(not exactly sometimes, but make sure you have the line above added):

Enable the integration inside the app

1. Open the Revy Bundles app and open the "Integrations" item in the menu:

2. Enable the "Script Editor" app integration:

IMPORTANT: Due to Shopify limitations the browser sometimes will reload if the customer go to checkout and go back to shopping, this page reload is needed to remove some properties from the cart. Please don't panic if the browser reloads automatically after you go to checkout(with bundle discount) and go back to store without finish the order.


Please let us know if you need help at, we can install the codes for you if you prefer, just ping us and request the installation and we will ask permission and do it for you.

Still need help? Contact Us Contact Us