From 2b546d345a6885d9fa5eafac4bf0daa88f94b382 Mon Sep 17 00:00:00 2001 From: thibault Date: Mon, 5 Feb 2024 15:58:38 +0100 Subject: [PATCH] [FIX] Remove option attribute from body request if not set --- src/cartTransaction.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cartTransaction.ts b/src/cartTransaction.ts index fa538c3..a96fa18 100644 --- a/src/cartTransaction.ts +++ b/src/cartTransaction.ts @@ -41,11 +41,17 @@ export class CartTransaction { /* Convert to a JSON object suitable to send to the ERP */ toErpTransaction(): any { - return { + let data: any = { uuid: this.uuid, product_id: this.productId, qty: this.qty, - options: this.options, }; + if (this.options === null || Object.keys(this.options).length > 0) { + data = { + ...data, + options: this.options, + }; + } + return data; } }