Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit a19477a

Browse files
committed
checkout fix: lines now ordered
1 parent fd001c7 commit a19477a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/checkout/checkout.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export class CheckoutService {
174174
where: { id },
175175
include: {
176176
lines: {
177+
orderBy: { createdAt: 'asc' },
177178
include: {
178179
productVariant: {
179180
include: {
@@ -251,9 +252,9 @@ export class CheckoutService {
251252
return checkout.lines.find((line) => line.productVariant.id === variantId);
252253
}
253254

254-
async addOneToCheckoutLineByLineId(lineId: string): Promise<boolean> {
255+
async addOneToCheckoutLineByLineId(id: string): Promise<boolean> {
255256
await this.prisma.checkoutLine.update({
256-
where: { id: lineId },
257+
where: { id },
257258
data: {
258259
quantity: {
259260
increment: 1,
@@ -264,9 +265,9 @@ export class CheckoutService {
264265
return true;
265266
}
266267

267-
async removeOneFromCheckoutLineByLineId(lineId: string): Promise<boolean> {
268+
async removeOneFromCheckoutLineByLineId(id: string): Promise<boolean> {
268269
const updated = await this.prisma.checkoutLine.update({
269-
where: { id: lineId },
270+
where: { id },
270271
data: {
271272
quantity: {
272273
decrement: 1,
@@ -275,7 +276,7 @@ export class CheckoutService {
275276
});
276277

277278
if (updated.quantity <= 0) {
278-
await this.prisma.checkoutLine.delete({ where: { id: lineId } });
279+
await this.prisma.checkoutLine.delete({ where: { id } });
279280
}
280281

281282
return true;

0 commit comments

Comments
 (0)