Intoduction
Fields Factory allows you to create and assign fields for woocommerce product admin page, product variable admin page, order admin page and product category admin page.
This allows store admin, the ability to add more configuration (fields with pre value, external links and additional messages) for products, variations, orders and categories.
The value entered in these fields will be stored as custom post meta. which can be retrived using wordpress’s standard get_post_meta()
function.
Yes there are many plugins that can do the same, but the main advantage using WC Fields Factory to create custom fields for product admin is that the same fields can also be enabled to displayed on the front end products page with the pre value set by the admin.
Just like Product & Variation Fields, this admin fields also can be forwarded to Cart -> Checkout -> Order & Email
.
Can also be configured as intenal fields, which means only visible to store admin not to the customers, even though it is stored as order meta & order line item meta.
Also these admin fields value can be added directly as Order Line Item Meta, without showing it on Product, Cart or Checkout pages.
Supported Field Types
- Image Upload
- Date Picker
- Color Picker
- Radio Button
- Check Box
- Select Box
- Text Box
- Text Area
- Number Field
- Email Field
- URL Field
Creating Admin Fields Group
In the wp-admin page go to Fields Factory -> Admin Fields
this will gets you the Admin Fields List View.
There click the Add New
button, this will bring you to the Admin Fields create view.
This process is same like the Product Fields & Variation Fields.
Adding Fields to the Group
- Use the
Add Title
text box to give a title to the admin fields group. - Now drag whatever field you need from
Fields Type
widget from top right corner and drop in to theDrop Zone
of Fields Factory View. - As soon as the field is droped inside the
Drop Zone
, the field will be added to group. Now you will be shown field meta editor. Using the meta editor we can configure the field’s label, validation and various other aspects. Same way you can add as many fields as you needed.
for more details pls refer Product Fields
Admin Fields Location
Once necessary fields were added to the group, it’s time to decide were to inject these fields. Admin Fields can be inserted into the following locations.
- Product Tabs
- Product View
- Order View
- Product Category View
1. Product Tabs :
This location allows you to place the admin fiels inside any the following product tabs.
- General Tab
- Inventory Tab
- Shipping Tab
- Attributes Tab
- Related Tab
- Advanced Tab
- Variable Tab – Use this option to put the admin fields for every product variation config.
Use the following snippet to use these fields in your code
/* * * @product_id - Product ID * @field_key - corresponding admin field's key * ***/ $value = get_post_meta($product_id, $field_key, true);
/* * * If the admin field location is Variable Tab, then use variation id instead of product id * @variation_id - Variation ID * @field_key - corresponding admin field's key * ***/ $value = get_post_meta($variation_id, $field_key, true);
2. Product View :
If you don’t want to put the admin fields in any of the product data tabs, then use this location, which will place the admin fields in a meta box. By default it will be on the bottom of the product admin, which can be configured to be moved around.
Use the following snippet to use these fields in your code
/* * * Same as product data tab * @product_id - Product ID * @field_key - corresponding admin field's key * ***/ $value = get_post_meta($product_id, $field_key, true);
3. Order View
This location allows you to put admin fields on order view. This is useful for adding additonal data when updating order status. These fields also be included in the subsequent customer emails (which can be configured otherwise).
Use the following snippet to use these fields in your code
/* * * @order_id - Order ID * @field_key - corresponding admin field's key * ***/ $value = get_post_meta($order_id, $field_key, true);
4. Product Category View
This location allows you to put admin fields on product category create & edit form. Allows to add additonal option for Product Categories. Here the data entered in the fields will be stored as option with special key combination.
Use the following snippet to use these fields in your code
/* * * $term_id - Terms ID * @field_key - corresponding admin field's key * ***/ $value = get_option("taxonomy_product_cat_". $term_id . $field_key);
Mapping Fields Group to Products
Once necessory fields were added, it’s time to map this fields group to products, variations, product category, product tag or product type. Using the Target Products
widget. By creating one or more rules, we can assign this fields to particular Target.
By default there is one rule, which maps this fields group to All Products (which can be changed). Additional rules can be created by using and
& Add condition group
buttons.
There are two types rules, in the case of more than one rule. either you can combine it via AND
& OR
logic. All these rules will be evoluated at the time of product admin rendering stage, when the outcome of all rules is TRUE
then the fields will be embedded on the product admin page (or other locations).
- Products : Assign this fields group to either All Products or to Particular Products
- Product Category : Assign this fields group to either All Categories or to Particular Categories
- Product Tag : Assign this fields group to either All Tags or to Particular Tags
- Product Type : Assign this fields group to either All Products Types or to Particular Product Types
- Product Variation : Assign this fields group to either All Products Variations or to Particular Product Variations.
Preferences
This group level preference comes into play when any of the field opted to show on front end product page. Other than that it has nothing to do with Admin Fields.
Fields Location
This group level fields location comes into play when any of the field opted to show on front end product page. Other than that it has nothing to do with Admin Fields.