1.2.2 • Published 10 months ago

@shopnex/cj-plugin v1.2.2

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

CJ Dropshipping Plugin for Payload CMS

This plugin integrates CJ Dropshipping into your Payload CMS project by:

  • Adding "CJ" as a product source.
  • Automatically creating CJ orders after local orders are created.
  • (Optionally) generating a cj-settings collection for managing API credentials dynamically.
  • Syncing CJ credentials on app initialization.

Installation

pnpm install @shopnex/cj-plugin

or

npm install @shopnex/cj-plugin

or

yarn add @shopnex/cj-plugin

Usage

Import and add the cjPlugin to your Payload config:

import { buildConfig } from "payload/config";
import { cjPlugin } from "@shopnex/cj-plugin";

export default buildConfig({
    collections: [
        // your collections
    ],
    plugins: [
        cjPlugin({
            cjApiKey: "your-cj-api-key",
            cjEmailAddress: "your-email@example.com",
            cjRefreshToken: "optional-refresh-token", // optional
            asCollection: true, // optional - creates a cj-settings collection
            collectionOverrides: {
                // optional - override fields or settings for the cj-settings collection
            },
        }),
    ],
});

Plugin Options

OptionTypeRequiredDescription
cjApiKeystringYesYour CJ Dropshipping API key.
cjEmailAddressstringYesYour CJ account email address.
cjRefreshTokenstringNoYour CJ refresh token if available.
asCollectionbooleanNoIf true, automatically creates a cj-settings collection to manage CJ API credentials per tenant/shop.
collectionOverridesobjectNoAllows overriding the default cj-settings collection config (fields, hooks, etc).

What the Plugin Does

  • Modifies the products collection:
    • Adds a source option: { label: 'CJ', value: 'cj' }.
  • Hooks into the orders collection:
    • On every new order or update, triggers the CJ order creation logic automatically.
  • Manages CJ credentials dynamically:
    • On Payload startup (onInit), loads all cj-settings documents and sets up credentials per shop.
  • Optional cj-settings collection:
    • If asCollection is true, a new cj-settings collection will be added automatically.
    • Useful for multi-tenant setups or dynamically changing credentials.

Example: cj-settings Collection

If asCollection: true, the following collection will be generated by default:

FieldTypeDescription
shopRelationReference to your shop or tenant.
emailTextYour CJ email address.
apiTokenTextYour CJ API key.

You can override this structure with collectionOverrides.


Notes

  • The plugin assumes you have a products collection with a source select field already created.
  • It assumes you have an orders collection.
  • Make sure the source field in products uses a select type with options array.

License

MIT

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.0

10 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago