# Member Only Pricing

{% hint style="warning" %}
Shopify Plus Only
{% endhint %}

{% hint style="danger" %}
This is an advanced guide meant for developers that not is supported by the Inveterate team. You should ensure you have the appropriate development resources to implement before proceeding.&#x20;
{% endhint %}

{% hint style="warning" %}
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.
{% endhint %}

## 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

```ruby
# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.inveterate.com/help-center/advanced-guides/shopify-scripts/member-only-pricing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
