|
|
1 yıl önce | |
|---|---|---|
| .. | ||
| api | 2 yıl önce | |
| config | 2 yıl önce | |
| payment | 2 yıl önce | |
| service | 1 yıl önce | |
| README.md | 1 yıl önce | |
| constants.ts | 2 yıl önce | |
| multivendor.plugin.ts | 1 yıl önce | |
| types.ts | 2 yıl önce | |
This is an example plugin which demonstrates how to build a multi-vendor marketplace with Vendure. It uses new APIs and features introduced in Vendure v2.0.
The parts of the plugin are documented with explanations, and the overall guide can be found in the Multi-vendor marketplace section of the Vendure docs.
Add this plugin to your VendureConfig:
import { MultivendorPlugin } from './plugins/multivendor-plugin/multivendor.plugin';
plugins: [
MultivendorPlugin.init({
platformFeePercent: 10,
platformFeeSKU: 'FEE',
}),
// ...
]
Now you can create new sellers with the following mutation in the Shop API:
mutation RegisterSeller {
registerNewSeller(input: {
shopName: "Bob's Parts",
seller: {
firstName: "Bob"
lastName: "Dobalina"
emailAddress: "bob@bobs-parts.com"
password: "test",
}
}) {
id
code
token
}
}
This mutation will:
Bob can then go and sign in to the Admin UI using the provided emailAddress & password credentials, and start creating some products.
Repeat this process for more Sellers.
To create a multivendor Order, use the default Channel in the storefront and add variants to an Order from various Sellers.
When it comes to setting the shipping method, the eligibleShippingMethods query should just return the
shipping methods for the shops from which the OrderLines come. So assuming the Order contains items from 3 different
Sellers, there should be at least 3 eligible ShippingMethods (plus any global ones from the default Channel).
You should now select the IDs of all the Seller-specific ShippingMethods:
mutation {
setOrderShippingMethod(shippingMethodId: ["3", "4"]) {
... on Order {
id
}
}
}
This plugin automatically creates a "connected payment method" in the default Channel, which is a simple simulation of something like Stripe Connect.
mutation {
addPaymentToOrder(input: { method: "connected-payment-method", metadata: {} }) {
... on Order { id }
... on ErrorResult {
errorCode
message
}
... on PaymentFailedError {
paymentErrorMessage
}
}
}
After that, you should be able to see that the Order has been split into an "aggregate" order in the default Channel, and then one or more "seller" orders in each Channel from which the customer bought items.