You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on the checkout flow, we discovered that the order is not updated correctly after an orderLine is removed from an Order.
To Reproduce
Add two items from two different sellers.
Assign the shipping methods from the eligible shipping options.
Remove one of the orderLines.
The response will return successfully, but with some properties not correctly updated, such as subTotalWithTax or totalQuantity.
Expected behavior
The response should return the updated order with the correct information
Environment:
@vendure/core version: 2.1.4
Nodejs version: 18.16.0
Database PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
Additional context
Possible solution:
Remove the "orphans" shippingLines and update the Order in the database before calling the applyPriceAdjustments method."
I have tried to implement a fix:
/** * @description * Removes the specified OrderLine from the Order. */asyncremoveItemFromOrder(ctx: RequestContext,orderId: ID,orderLineId: ID,): Promise<ErrorResultUnion<RemoveOrderItemsResult,Order>>{constorder=awaitthis.getOrderOrThrow(ctx,orderId);constvalidationError=this.assertAddingItemsState(order);if(validationError){returnvalidationError;}constorderLine=this.getOrderLineOrThrow(order,orderLineId);order.lines=order.lines.filter(line=>!idsAreEqual(line.id,orderLineId));// Remove shippingLines not valid for this orderconstorderLineShippingLineIds=order.lines.map(line=>line.shippingLineId);// Get all the shippingLines that are not included in the order linesconstshippingLinesToDelete=order.shippingLines.filter(shippingLine=>!orderLineShippingLineIds.includes(shippingLine.id),);// In case some shippingLines are founded, remove itif(shippingLinesToDelete.length){awaitthis.connection.getRepository(ctx,ShippingLine).remove(shippingLinesToDelete);}// Update the order before Hydrationawaitthis.connection.getRepository(ctx,OrderLine).remove(orderLine);constupdatedOrder=awaitthis.applyPriceAdjustments(ctx,order);this.eventBus.publish(newOrderLineEvent(ctx,order,orderLine,'deleted'));returnupdatedOrder;}
The text was updated successfully, but these errors were encountered:
While working on the checkout flow, we discovered that the order is not updated correctly after an
orderLine
is removed from anOrder
.To Reproduce
orderLines
.subTotalWithTax
ortotalQuantity
.Expected behavior
The response should return the updated order with the correct information
Environment:
Additional context
Possible solution:
Remove the "orphans"
shippingLines
and update theOrder
in the database before calling theapplyPriceAdjustments
method."I have tried to implement a fix:
The text was updated successfully, but these errors were encountered: