@shopify/discount-app-components provides a set of stateless discount components to help 3p app developers create discounts apps.
🚨 This package is deprecated. Please use Polaris instead.
We're officially deprecating the @shopify/discount-app-components package, as it hasn't been actively maintained or supported for an extended period. This deprecation helps reduce maintenance overhead for our team and directs developers toward our current recommended solutions.
Polaris Components: For general UI components, please use Polaris which offers a comprehensive set of maintained, accessible components.
Admin UI Extensions: For building discount apps specifically, we strongly recommend using Admin UI Extensions, which provide a more integrated, future-proof approach to building discount apps.
This change aligns with our broader strategy of consolidating component libraries and providing extension-based approaches for app development.
For more information about creating apps for the Shopify App Store, see the app development documentation.
Run the following command using npm:
npm install @shopify/discount-app-components --save
If you prefer Yarn, use the following command instead:
yarn add @shopify/discount-app-components
🛑 The project has
peerDependenciesof@shopify/app-bridge, and@shopify/polariswhich must also be installed in your app.
Import the CSS for this repo and Polaris directly into your project if your asset packager supports it:
js
import '@shopify/discount-app-components/build/esm/styles.css';
import '@shopify/polaris/build/esm/styles.css';
Otherwise include the CSS in your HTML. We suggest copying the styles file into your own project, but you may also use it directly:
html
<link
rel="stylesheet"
href="https://unpkg.com/@shopify/discount-app-components@<your version number>/build/esm/styles.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/@shopify/polaris@<your version number>/build/esm/styles.css"
/>
This library contains a number of locale-specific components, and you will be required to pass a locale and a ianaTimezone to the discounts AppProvider.
```js import {Page, AppProvider as PolarisAppProvider} from '@shopify/polaris'; import {AppProvider as DiscountsProvider} from '@shopify/discount-app-components';
// See Polaris AppProvider documentation for more details on using Polaris translations import enPolarisTranslations from '@shopify/polaris/locales/en.json';
// Import polaris styles import "@shopify/polaris/build/esm/styles.css";
// Import this discount-app-components styles import "@shopify/discount-app-components/build/esm/styles.css";
export default function App() {
...
return ( {/ discount-app-component specific AppProvider /} {/ Add your discount components here /} ); } ```
Note: you may need to rename the discounts AppProvider to avoid clashing with another AppProvider component:
In your terminal, install yalc globally. npm i yalc -g
In your terminal, run yalc publish --private from the discount-app-components repo
In your terminal, open a second tab in your consuming project's directory and run yalc add @shopify/discount-app-components. This will the dependency to your project's package.json that resembles the following:
"dependencies": {
...
"@shopify/discount-app-components": "file:.yalc/@shopify/discount-app-components",
...
}
yarn). NOTE This may update your project's dependency lockfile, be cautious about committing changes added by importing @shopify/discount-app-components locally.yalc publish --privateyalc update @shopify/discount-app-componentsrm -rf ./node_modules && rm -rf .yalc && yarn for the changes to apply.XYZ from non EcmaScript module (only default export is available)If you run into an error that resembles the following:
ERROR in ./node_modules/@shopify/react-i18n/build/esm/i18n.mjs 406:68-76
Can't import the named export 'TimeUnit' from non EcmaScript module (only default export is available)
@ ./node_modules/@shopify/react-i18n/build/esm/index.mjs
@ ./node_modules/@shopify/react-i18n/index.mjs
@ ./node_modules/@shopify/discount-app-components/build/esm/components/FormattedNumberField/FormattedNumberField.js
@ ./node_modules/@shopify/discount-app-components/build/esm/index.js
@ ./src/App.js
@ ./src/index.js
You may need to update your webpack.config.js to include a module.rules of:
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
}
Writing changelogs and releasing should be as seamless and automated as possible. This repo uses changesets to version and release packages. To create a new version and release, follow these steps:
yarn changeset add and commit the generated changesets.
b. If you don't want to include those changes in the changelog, you can label your pr with 🤖 Skip Changelog.yarn version and incorporates the changesets into the changelog and bumps the version accordingly. (patch/minor/major) It then creates a Version Packages pull request.yarn release, which publishes the package to npm.Please see our contributing guidelines for details.
$ claude mcp add discount-app-components \
-- python -m otcore.mcp_server <graph>