joanrodas / custom-product-fields
Add custom fields to WooCommerce products, CPT, terms, users and more, programatically and with ease.
v0.1.10
2024-09-19 17:40 UTC
Requires
- php: >=7.4
- dev-main
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-renovate/sass-1.x
- dev-repeatable
- dev-dependabot/npm_and_yarn/webpack-5.76.1
- dev-dependabot/npm_and_yarn/sideway/formula-3.0.1
- dev-file-field
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dev
- dev-dependabot/npm_and_yarn/loader-utils-2.0.4
This package is auto-updated.
Last update: 2025-03-13 14:45:52 UTC
README
Product fields library for WooCommerce developers.
✔️ Custom fields integrated with WooCommerce fields
✔️ Easily extendable with hooks
Getting started
composer require joanrodas/custom-code-fields
You can also install Custom Product Fields as a standalone WordPress plugin, simply downloading the zip and placing it in the plugins folder.
Examples
use CCF\Section\ProductSection; use CCF\Field\Field; use CCF\Field\RepeatableField; add_action('ccf_register_fields', function () { ProductSection::create('section_slug', 'Section name', [ Field::create('text', 'text_field', 'Text Field') ->default_value('default') Field::create('textarea', 'textarea_field', 'Textarea Field'), Field::create('switch', 'switch_field', 'Switch Field'), Field::create('checkbox', 'checkbox_field', 'Checkbox Field'), Field::create('number', 'number_field', 'Number Field') ->min(3) ->max(23.5) ->step(0.1) ->set_datalist([1,2,5,10,15]), Field::create('html', 'html_inside', 'Inside html') ->html('<b>Bold text</b>'), Field::create('select', 'select_field', 'Select Field')->set_options('add_select_options'), Field::create('rich_text', 'rich_text_field', 'Rich Text Field'), RepeatableField::create('repeatable_field', 'Repeatable Field', [ Field::create('password', 'password_inside', 'Inside password'), Field::create('url', 'url_inside', 'Inside url') ->set_datalist(['https://plubo.dev']), Field::create('time', 'time_inside', 'Inside time') ->set_datalist(['10:20']), Field::create('date', 'date_inside', 'Inside date') ->set_datalist(['2023-02-02', '2023-02-01']), Field::create('color', 'color_field', 'Color Field') ->set_datalist(['#ffdede', '#f3d4de']), ]), ]) ->if_tab('general') // ->if_product_type(['simple', 'variable']) // ->if_checked('virtual') ; }); function add_select_options() { return [ 'option_1' => 'Option 1', 'option_2' => 'Option 2', 'option_3' => 'Option 3', 'option_4' => 'Option 4' ]; }
Contributions
Feel free to contribute to the project, suggesting improvements, reporting bugs and coding.