LogoLogo
  • Help Center
  • Welcome To Inveterate
  • Guides
    • Getting Started
      • Install The Inveterate App
        • App Installation
        • Creating Your Inveterate Account
      • Set Up Company Profile
      • Enable Inveterate On Your Store
      • Adjust Customer Account Settings In Shopify
      • Add Membership Link Snippet to Customer Account Template
    • Program Setup
      • Tier Setup
        • Editing Tiers
        • Deleting Tiers
        • Free Trials For Paid Tiers
        • Universal Rebill Date
      • Benefits
        • Credit Based Benefits
          • Credit Expiration
          • Enabling Credit Based Benefits
          • Recurring Store Credits
          • Credits For Orders
          • Anniversary Credits
          • Store Credits For Purchase Referral
          • Sign Up Store Credits
        • Savings Based Benefits
          • Free Shipping
          • Member Only Discounts
          • Sign Up Discounts
          • Member Only Pricing
        • Access Based Benefits
          • Early Access
          • Exclusive Access
        • Gift Based Benefits
          • Free Gift At Signup
      • Landing Page
        • About The Landing Page
        • Configuring the Landing Page
          • Hero
          • Testimonial
          • Benefits
          • CTA
          • FAQ
        • Adding the Landing Page to Your Store
        • Landing Page Versioning
        • Adding Custom CSS Styling
      • Messaging
        • Content
        • Messaging Settings
    • Members
      • Member Portal
      • Manage Members
        • Canceling Members
        • Tier Upgrades and Downgrades
        • Members Page
        • Creating Segments
        • Exporting Member List
      • Member Profile
        • Fundamentals
        • Adjusting Credits
        • Anonymize Members
      • Shopify Account Pages
    • Settings
      • Users & Access
      • Profile Settings
      • Password Reset
      • Account Settings
    • Integrations
      • Shopify POS
      • Tapcart
      • Aftersell
      • Gorgias
      • Postscript
      • Klaviyo
      • Rebuy
      • Attentive
        • How to Enable Integration
        • Segmenting Customers by Inveterate's Membership Custom Attributes in Attentive
        • How to Create Journeys in Attentive with Inveterate's Custom Events
        • Attentive Custom Events List
  • Strategy & Best Practices
    • Memberships 101
  • Discount Information
    • Apply Discounts To Subscription Products
    • Editing Discount Codes
    • Codes For Free Memberships
    • Combining Discounts
  • Tag Information
    • Customer Tags
    • Order Tags
  • Advanced Guides
    • Editing Free Tier Signup Modals
    • Membership Currency Localization
    • Migrating From Scripts To Functions
    • Migrating To Tiers
    • Spend Based Tiers
      • About Spend Based Tiers
      • Spend Based Tiers Setup
      • About The Landing Page
    • Search Engine Crawling
    • Advanced Settings
      • App Embeds Settings
      • Early Access Settings
      • Exclusive Access Settings
    • Shopify Scripts
      • Free Shipping Script
      • Member Only Pricing
      • Free Gift At Sign Up
    • Theme Editor Sections
      • PDP Upsell Widget
    • Replace Inveterate Emails In Klaviyo
      • How to Send Member Notification Emails with Klaviyo
      • Klaviyo Member Notification Metrics and Their Template Variables
    • Sunsetting Your Membership Program
    • Shopify Flow
      • Flow Library
Powered by GitBook
On this page
  • Editable Values
  • Script

Was this helpful?

  1. Advanced Guides
  2. Shopify Scripts

Member Only Pricing

PreviousFree Shipping ScriptNextFree Gift At Sign Up

Last updated 7 months ago

Was this helpful?

Shopify Plus Only

This is an advanced guide that requires the app. If you are new to Shopify Plus, you will not have access to the Script Editor App. Please go back to the and continue editing this benefit with the steps provided.

Only one line item script can be active at a time. If you already have a line item script running and you want to run this script in tandem, this will not work. You'll need to customize the scripts to work together.

Editable Values

  • MESSAGE - {string} A message that will be displayed on every discounted product in checkout.

  • DISCOUNT_PERCENTAGE - {number} The percentage amount each line item will be discounted.

  • PRODUCT_ID_LIST - {array[number]} An array of product IDs for products that should be discounted. If left empty discount will apply to all products.

Script

# Editable Values
MESSAGE = 'Member only pricing!'
DISCOUNT_PERCENTAGE = XX
PRODUCT_ID_LIST = []

########
# DO NOT EDIT PAST THIS POINT
########

class MemberOnlyPricing 
  def initialize()
    @message = MESSAGE
    @percentage_off = (100 - DISCOUNT_PERCENTAGE) * 0.01
    @product_id_list = PRODUCT_ID_LIST
  end

  def run(cart)
    @cart = cart
    start
  end

  private

  def start
    return unless @cart.customer
    return unless @cart.customer.tags.include? "inveterate-subscriber"

    @cart.line_items.each do |line_item|
      if @product_id_list.size > 0
        unless @product_id_list.include? line_item.variant.product.id
          next
        end
      end
      line_item.change_line_price(
        line_item.line_price * @percentage_off,
        message: @message
      )
    end
  end
end

CAMPAIGNS = [
  MemberOnlyPricing.new()
]

CAMPAIGNS.each do |campaign|
  campaign.run(Input.cart)
end

Output.cart = Input.cart
Shopify Script Editor
Member Only Pricing setup doc