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

View file

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

View file

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

View file

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