Guides

A marketplace's distinct set of functionalities revolves around the differentiation between user groups: buyers and third-party vendors selling on the marketplace. Swell can accommodate an entire marketplace by building off of one store's data models.

💡

The examples below are using swell-node, but you can accomplish all examples below through any HTTP client.

To begin, define and establish the account hierarchies based on the user groups within your marketplace. You can use customer groups to differentiate each customer base within the Swell dashboard.

  1. From the dashboard, navigate to Settings > Customers
  2. Select Add customer group under the Groups section
  3. Provide the desired group name (edit the group ID—optional)
  4. Click Save

Once created, you can further manage customer groups in the dashboard in the Customer section.

💡

You will need the group's id when creating various accounts within your marketplace for a particular group.

For a marketplace, you'll want to create at least two specific customer groups:

  • Vendors: the customer group intending to add and sell products through your marketplace and fulfill orders.
  • Buyers: the customer group looking to only purchase products from the vendors in your marketplace.

Once you've created your customer groups, your Customers section in the dashboard should look something like this:

You can create additional groups as well depending on the needs of your marketplace—and designate them however you'd like.

With the customer groups created, you can now add new accounts by posting to the /accounts endpoint and associating them to either the buyers or vendors group. Passwords entered here encrypted immediately through bcrypt.

Assigning an account to the vendor customer group:

Assigning account to vendor customer group
await swell.post('/accounts', {
	email: 'vendor@mail.com',
	first_name: 'Vendor',
	last_name: 'Swell',
	password: 'password123',
	group: 'vendors' // Or buyers
});

In the response, you'll retrieve the account's id. This can be used as a vendor_id. Use this to create relationships between the vendor and their products and orders, as illustrated below.

With the various accounts for the marketplace configured, we'll look at expanding upon the base Swell model functionality to accommodate marketplace logic.