From 314625ed5accfaeb83c5bccac42534a079f0ec25 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Fri, 21 Feb 2020 16:28:56 +0100 Subject: [PATCH] :zap: Small improvements on WooCommerce-Node --- .../nodes/WooCommerce/ProductDescription.ts | 45 +++++-------------- .../nodes/WooCommerce/ProductInterface.ts | 2 +- .../nodes/WooCommerce/WooCommerce.node.ts | 17 ++----- packages/nodes-base/package.json | 2 +- 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts b/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts index 8780922b2e..a22b394edf 100644 --- a/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts +++ b/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts @@ -19,9 +19,9 @@ export const productOperations = [ description: 'Create a product', }, { - name: 'Update', - value: 'update', - description: 'Update a product', + name: 'Delete', + value: 'delete', + description: 'Delete a product', }, { name: 'Get', @@ -34,9 +34,9 @@ export const productOperations = [ description: 'Get all products', }, { - name: 'Delete', - value: 'delete', - description: 'Delete a product', + name: 'Update', + value: 'update', + description: 'Update a product', }, ], default: 'create', @@ -117,21 +117,21 @@ export const productFields = [ name: 'catalogVisibility', type: 'options', options: [ - { - name: 'Visible', - value: 'visible', - }, { name: 'Catalog', value: 'catalog', }, + { + name: 'Hidden', + value: 'hidden', + }, { name: 'Search', value: 'search', }, { - name: 'Hidden', - value: 'hidden', + name: 'Visible', + value: 'visible', }, ], default: 'visible', @@ -220,13 +220,6 @@ export const productFields = [ default: '', description: 'Product parent ID.', }, - { - displayName: 'Price', - name: 'price', - type: 'string', - default: '', - description: 'Current product price.', - }, { displayName: 'Purchase Note', name: 'purchaseNote', @@ -752,13 +745,6 @@ export const productFields = [ default: '', description: 'Product parent ID.', }, - { - displayName: 'Price', - name: 'price', - type: 'string', - default: '', - description: 'Current product price.', - }, { displayName: 'Purchase Note', name: 'purchaseNote', @@ -1251,13 +1237,6 @@ export const productFields = [ default: '', description: 'Limit result set to products based on a minimum price.', }, - { - displayName: 'On Sale', - name: 'onSale', - type: 'boolean', - default: false, - description: 'Limit result set to products on sale.', - }, { displayName: 'Order', name: 'order', diff --git a/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts b/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts index c6a40a1af8..2c4072146d 100644 --- a/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts +++ b/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts @@ -1,4 +1,4 @@ -import { IDataObject } from "n8n-workflow"; +import { IDataObject } from 'n8n-workflow'; export interface IDimension { height?: string; diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts index 45104a51a2..a7865ba5d2 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts @@ -124,7 +124,7 @@ export class WooCommerce implements INodeType { body.catalog_visibility = additionalFields.catalogVisibility as string; } if (additionalFields.categories) { - body.categories = (additionalFields.categories as string[]).map(category => { id: parseInt(category, 10); }) as unknown as IDataObject[]; + body.categories = (additionalFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[]; } if (additionalFields.crossSellIds) { body.cross_sell_ids = (additionalFields.crossSellIds as string).split(',') as string[]; @@ -153,9 +153,6 @@ export class WooCommerce implements INodeType { if (additionalFields.parentId) { body.parent_id = additionalFields.parentId as string; } - if (additionalFields.price) { - body.price = additionalFields.price as string; - } if (additionalFields.purchaseNote) { body.purchase_note = additionalFields.purchaseNote as string; } @@ -193,7 +190,7 @@ export class WooCommerce implements INodeType { body.stock_status = additionalFields.stockStatus as string; } if (additionalFields.tags) { - body.tags = (additionalFields.tags as string[]).map(tag => { id: parseInt(tag, 10); }) as unknown as IDataObject[]; + body.tags = (additionalFields.tags as string[]).map(tag => ({ 'id': parseInt(tag, 10) })) as unknown as IDataObject[]; } if (additionalFields.taxClass) { body.tax_class = additionalFields.taxClass as string; @@ -245,7 +242,7 @@ export class WooCommerce implements INodeType { body.catalog_visibility = updateFields.catalogVisibility as string; } if (updateFields.categories) { - body.categories = (updateFields.categories as string[]).map(category => { id: parseInt(category, 10); }) as unknown as IDataObject[]; + body.categories = (updateFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[]; } if (updateFields.crossSellIds) { body.cross_sell_ids = (updateFields.crossSellIds as string).split(',') as string[]; @@ -274,9 +271,6 @@ export class WooCommerce implements INodeType { if (updateFields.parentId) { body.parent_id = updateFields.parentId as string; } - if (updateFields.price) { - body.price = updateFields.price as string; - } if (updateFields.purchaseNote) { body.purchase_note = updateFields.purchaseNote as string; } @@ -314,7 +308,7 @@ export class WooCommerce implements INodeType { body.stock_status = updateFields.stockStatus as string; } if (updateFields.tags) { - body.tags = (updateFields.tags as string[]).map(tag => { id: parseInt(tag, 10); }) as unknown as IDataObject[]; + body.tags = (updateFields.tags as string[]).map(tag => ({ id: parseInt(tag, 10) })) as unknown as IDataObject[]; } if (updateFields.taxClass) { body.tax_class = updateFields.taxClass as string; @@ -378,9 +372,6 @@ export class WooCommerce implements INodeType { if (options.minPrice) { qs.max_price = options.minPrice as string; } - if (options.onSale) { - qs.on_sale = options.onSale as string; - } if (options.order) { qs.order = options.order as string; } diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 5e34ed9f07..7c26fd9b87 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -214,8 +214,8 @@ "dist/nodes/Webflow/WebflowTrigger.node.js", "dist/nodes/Webhook.node.js", "dist/nodes/Wordpress/Wordpress.node.js", - "dist/nodes/WooCommerce/WooCommerceTrigger.node.js", "dist/nodes/WooCommerce/WooCommerce.node.js", + "dist/nodes/WooCommerce/WooCommerceTrigger.node.js", "dist/nodes/WriteBinaryFile.node.js", "dist/nodes/Xml.node.js", "dist/nodes/Zendesk/Zendesk.node.js",