Raise the price of a product after every sale, with Mechanic.

Mechanic is a development and ecommerce automation platform for Shopify. :)

Raise the price of a product after every sale

This task monitors purchases for a specific product ID, and raises the price every time it's purchased, by the amount that you specify. (To be specific, this task will raise the price on the individual variant that was purchased.)

Runs Occurs whenever an order is paid. Configuration includes product id, increase price by this much, and maximum price.

15-day free trial – unlimited tasks

Documentation

This task monitors purchases for a specific product ID, and raises the price every time it's purchased, by the amount that you specify. (To be specific, this task will raise the price on the individual variant that was purchased.)

Configure this task with the ID of the product you want to monitor. Find the product ID by opening the product in the Shopify admin, and using the numbers at the very end of the URL in your browser. For example, the product at https://example.myshopify.com/admin/products/1234567890 would have a product ID of 1234567890.

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

(By the way, have you seen our documentation? Have you joined the Slack community?)

Open source
View on GitHub to contribute to this task
Subscriptions
shopify/orders/paid
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
product id (required, number), increase price by this much (number, required), maximum price (number)
Code
{% assign purchased_variant = nil %}
{% for line_item in order.line_items %}
  {% if line_item.product_id == options.product_id__required_number %}
    {% assign purchased_variant = line_item.variant %}
    {% break %}
  {% endif %}
{% endfor %}

{% if event.preview or purchased_variant %}
  {% assign next_price = purchased_variant.price | plus: options.increase_price_by_this_much__number_required %}

  {% unless event.preview != true and options.maximum_price__number != blank and next_price > options.maximum_price__number %}
    {
      "action": {
        "type": "shopify",
        "options": [
          "update",
          [
            "variant",
            {{ purchased_variant.id | json }}
          ],
          {
            "price": {{ next_price | json }}
          }
        ]
      }
    }
  {% endunless %}
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more