vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.71k stars 1.01k forks source link

V2: Cannot make multi-vendor order on admin-ui #2146

Open PKarics opened 1 year ago

PKarics commented 1 year ago

Describe the bug I would like to create a multi-vendor order on the admin-ui..

To Reproduce Steps to reproduce the behavior:

  1. Setup multi-vendor entities (2 seller, 2 channel, 2 product)
  2. Create a draft order
  3. Add 2 product from different sellers to the order

Expected behavior Order type should changed from regular to aggregate.

Environment (please complete the following information): Independent.

Additional context Possibly the type change is enough when draft state leaved so no more item change expected.

mpacary commented 1 year ago

I cannot create a multi-vendor order from Admin UI either on v2.0.1. I guess that for the moment, multi-vendor order creation is only supported by calling the relevant GraphQL mutations (as documented here)

More details:


EDIT this trace in server logs (when selecting a vendor shipping method) might be useful.

[server] TypeError: Cannot read properties of null (reading 'toString')
[server]     at idsAreEqual (/var/www/*snip*/node_modules/@vendure/core/src/common/utils.ts:42:16)
[server]     at /var/www/*snip*/src/plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.ts:47:22
[server]     at Array.filter (<anonymous>)
[server]     at MultivendorShippingLineAssignmentStrategy.assignShippingLineToOrderLines (/var/www/*snip*/src/plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.ts:46:28)
[server]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[server]     at async OrderService.setShippingMethod (/var/www/*snip*/node_modules/@vendure/core/src/service/services/order.service.ts:915:17)
mpacary commented 1 year ago

After further investigation, it turns out I had an issue with channels associated to a product variant (only default channel was assigned in DB, instead of default channel + the specific vendor channel), whereas the product itself was correctly assigned to the two channels 🤔

Therefore, in file .../multivendor-plugin/config/mv-shipping-line-assignment-strategy.ts, I had an issue in method assignShippingLineToOrderLines() where line.sellerChannelId could be null and make the call to idsAreEqual() method throw the Cannot read properties of null error.

After unassigning / reassigning the vendor channel to the product from the admin UI, this issue did not happen anymore.