woocommerce/packages/js/components/src/product-fields
Sam Seay 1834621d1a
Update the @woocommerce/eslint-plugin and fix bugs (#36988)
2023-03-02 11:36:38 +13:00
..
api Add basic fields for rendering of Product MVP (#36392) 2023-01-16 12:50:30 -08:00
fields Update the @woocommerce/eslint-plugin and fix bugs (#36988) 2023-03-02 11:36:38 +13:00
store Add basic fields for rendering of Product MVP (#36392) 2023-01-16 12:50:30 -08:00
stories Add basic fields for rendering of Product MVP (#36392) 2023-01-16 12:50:30 -08:00
README.md Initial product form field store (#36362) 2023-01-12 04:02:35 -04:00
index.ts Add basic fields for rendering of Product MVP (#36392) 2023-01-16 12:50:30 -08:00

README.md

Product Fields

Product Fields are used within the WooCommerce Admin product editor, for rendering new fields using PHP.

Example

// product-field.js
( function ( element ) {
	const el = element.createElement;

	registerProductField( 'number', {
		name: 'number',
		render: () => {
			return <InputControl type="number" />;
		},
	} );
} )( window.wp.element );

API

registerProductField

Registers a new product field provided a unique name and an object defining its behavior.

Usage

import { __ } from '@wordpress/i18n';
import { registerProductField } from '@woocommerce/components';

registerProductField( 'number', {
	name: 'number',
	render: () => {
		return <InputControl type="number" />;
	},
} );

Parameters

  • fieldName string: Field name.
  • settings Object: Field settings.
    • render ComponentType: React functional component to be rendered.