npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@haus-tech/campaign-price-plugin

v1.0.2

Published

Campaign price plugin

Readme


name: campaign-price-plugin title: Campaign Price Plugin description: Vendure plugin that adds campaign pricing with an ordinaryPrice field for "was / now" display. version: 1.0.0 tags: [vendure, plugin, campaign, price, sale]

Campaign Price Plugin

The Campaign Price Plugin is a Vendure plugin that lets you run campaigns and sales by setting a campaign price on product variant prices. When a campaign price is set, it is used as the selling price instead of the ordinary price. The plugin also exposes an ordinaryPrice field in the Shop API so storefronts can show “was X, now Y” pricing.

Functionality

  • Campaign price custom field — Add a campaignPrice (integer) to ProductVariantPrice, editable per channel/currency in the Admin UI.
  • Price calculation strategy — If a variant has a campaign price set and it is greater than zero, that price is used; otherwise the existing price calculation strategy is used.
  • Ordinary price in Shop APIProductVariant, Product, and SearchResult get an ordinaryPrice field so the storefront can display the original price alongside the current (possibly campaign) price.

Use Cases

  • Time-limited sales or campaigns with a different price per channel/currency.
  • Showing strikethrough “was X” and “now Y” prices on product and search pages.
  • Running campaigns without changing the base price data; turn the campaign off by clearing the campaign price.

Installation

To install the Campaign Price Plugin, follow these steps:

  1. Install the plugin package:

    yarn add @haus-tech/campaign-price-plugin

    Or, if using npm:

    npm install @haus-tech/campaign-price-plugin
  2. Add the plugin to your Vendure configuration in vendure-config.ts:

    import { CampaignPricePlugin } from '@haus-tech/campaign-price-plugin'
    
    export const config = {
      plugins: [CampaignPricePlugin],
    }
  3. Restart your Vendure server.

Usage

Admin UI

In the Admin UI, each product variant price has a Campaign Price field (per channel/currency). Set it to run a campaign; leave it empty or zero to use the ordinary price. The field uses the currency form input component.

Shop API

The plugin extends the Shop API so you can read both the current price (which may be the campaign price) and the ordinary price.

  • ProductVariant.ordinaryPriceInt! — The ordinary (pre-campaign) price for the variant.
  • Product.ordinaryPriceSearchResultPrice! — Min/max ordinary price across the product’s variants (single value or range).
  • SearchResult.ordinaryPriceSearchResultPrice! — Ordinary price for search results. Requires the default search plugin to index product-ordinaryPriceMin and product-ordinaryPriceMax if you use search; add these to your search index configuration if needed.

Example: show “was / now” on a variant:

query VariantPricing($id: ID!) {
  productVariant(id: $id) {
    id
    price
    priceWithTax
    ordinaryPrice
  }
}

Example: product with variant price range:

query ProductPricing($id: ID!) {
  product(id: $id) {
    id
    priceRange {
      min
      max
    }
    ordinaryPrice {
      ... on SinglePrice {
        value
      }
      ... on PriceRange {
        min
        max
      }
    }
  }
}

Use price / priceRange for the current selling price (campaign or ordinary) and ordinaryPrice for the original price in your “was X, now Y” UI.

Testing

  1. Run yarn test to execute the tests.
  2. Implement additional tests to cover your specific use cases.

Publish to NPM

  1. Make sure you are logged in to NPM.

  2. Build the plugin:

    yarn build
  3. Publish the plugin:

    yarn publish

Resources