Small improvements on WooCommerce-Node

This commit is contained in:
Jan Oberhauser 2020-02-25 11:01:13 +01:00
parent 530bafd2bc
commit 698a69207c
6 changed files with 30 additions and 42 deletions

View file

@ -101,8 +101,7 @@ export function setMetadata(data:
//@ts-ignore
data[i].meta_data = data[i].metadataUi.metadataValues;
//@ts-ignore
delete data[i].metadataUi
console.log(data[i]);
delete data[i].metadataUi;
} else {
//@ts-ignore
delete data[i].metadataUi;
@ -128,7 +127,7 @@ export function toSnakeCase(data:
remove = true;
}
//@ts-ignore
data[i][snakeCase(key)] = data[i][key]
data[i][snakeCase(key)] = data[i][key];
if (remove) {
//@ts-ignore
delete data[i][key];
@ -137,4 +136,3 @@ export function toSnakeCase(data:
}
}
}

View file

@ -111,13 +111,6 @@ export const orderFields = [
default: '',
description: 'Payment method title.',
},
{
displayName: 'Payment Method Title',
name: 'paymentMethodTitle',
type: 'string',
default: '',
description: 'Payment method title.',
},
{
displayName: 'Set Paid',
name: 'setPaid',
@ -130,14 +123,14 @@ export const orderFields = [
name: 'status',
type: 'options',
options: [
{
name: 'completed',
value: 'completed',
},
{
name: 'cancelled',
value: 'cancelled',
},
{
name: 'completed',
value: 'completed',
},
{
name: 'failed',
value: 'failed',
@ -831,26 +824,19 @@ export const orderFields = [
default: '',
description: 'Payment method title.',
},
{
displayName: 'Payment Method Title',
name: 'paymentMethodTitle',
type: 'string',
default: '',
description: 'Payment method title.',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
options: [
{
name: 'completed',
value: 'completed',
},
{
name: 'cancelled',
value: 'cancelled',
},
{
name: 'completed',
value: 'completed',
},
{
name: 'failed',
value: 'failed',
@ -1568,6 +1554,10 @@ export const orderFields = [
displayName: 'Decimal Points',
name: 'decimalPoints',
type: 'number',
typeOptions: {
minValue: 0,
maxValue: 10,
},
default: 2,
description: 'Number of decimal points to use in each resource.',
},

View file

@ -10,10 +10,10 @@ import {
INodePropertyOptions,
} from 'n8n-workflow';
import {
setMetadata,
toSnakeCase,
woocommerceApiRequest,
woocommerceApiRequestAllItems,
toSnakeCase,
setMetadata,
} from './GenericFunctions';
import {
productFields,
@ -22,18 +22,18 @@ import {
import {
orderFields,
orderOperations,
} from './Orderdescription';
} from './OrderDescription';
import {
IProduct,
IImage,
IDimension,
IImage,
IProduct,
} from './ProductInterface';
import {
IOrder,
IAddress,
ICouponLine,
IFeeLine,
ILineItem,
IOrder,
IShoppingLine,
} from './OrderInterface';
@ -41,7 +41,7 @@ export class WooCommerce implements INodeType {
description: INodeTypeDescription = {
displayName: 'WooCommerce',
name: 'wooCommerce',
icon: 'file:woocommerce.png',
icon: 'file:wooCommerce.png',
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@ -64,14 +64,14 @@ export class WooCommerce implements INodeType {
name: 'resource',
type: 'options',
options: [
{
name: 'Product',
value: 'product',
},
{
name: 'Order',
value: 'order',
},
{
name: 'Product',
value: 'product',
},
],
default: 'product',
description: 'Resource to consume.',
@ -455,10 +455,10 @@ export class WooCommerce implements INodeType {
body.parent_id = parseInt(additionalFields.parentId as string, 10);
}
if (additionalFields.paymentMethodId) {
body.payment_method = additionalFields.paymentMethodId as string
body.payment_method = additionalFields.paymentMethodId as string;
}
if (additionalFields.paymentMethodTitle) {
body.payment_method_title = additionalFields.paymentMethodTitle as string
body.payment_method_title = additionalFields.paymentMethodTitle as string;
}
if (additionalFields.setPaid) {
body.set_paid = additionalFields.setPaid as boolean;
@ -528,10 +528,10 @@ export class WooCommerce implements INodeType {
body.parent_id = parseInt(updateFields.parentId as string, 10);
}
if (updateFields.paymentMethodId) {
body.payment_method = updateFields.paymentMethodId as string
body.payment_method = updateFields.paymentMethodId as string;
}
if (updateFields.paymentMethodTitle) {
body.payment_method_title = updateFields.paymentMethodTitle as string
body.payment_method_title = updateFields.paymentMethodTitle as string;
}
if (updateFields.status) {

View file

@ -21,7 +21,7 @@ export class WooCommerceTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'WooCommerce Trigger',
name: 'wooCommerceTrigger',
icon: 'file:woocommerce.png',
icon: 'file:wooCommerce.png',
group: ['trigger'],
version: 1,
description: 'Handle WooCommerce events via webhooks',

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB