1. Home
  2. WC Vendors Pro
  3. How To
  4. Adding a Custom Field for Products

Adding a Custom Field for Products

This code will add a custom field to WC Vendor Pro’s add/edit form. Copy the template /plugins/wc-vendors-pro/templates/dashboard/product-edit.php to /themes/your-theme/wc-vendors/dashboard/product-edit.php and then add this code, including the opening/closing php tags anywhere on the form you want your custom field to be entered.

The sample code below will add a field called “Ingredients” with a text area to input the custom field. The field is then saved as “wcv_custom_product_ingredients” and will show up on the product page in the custom fields meta box.

You can change the wcv_custom_product_ingredients to be anything you like, as long as the meta key starts with wcv_custom _product or _wcv_custom_product_ — If you don’t start the meta key with that, it will be ignored. If the meta key has an underscore _ before it, it will be hidden on the product page in wp-admin, no underscore it will be shown in the Custom Fields meta box.

The code below goes in your product-edit.php template as outlined in the WCVendors Pro Setup Guide and you can override the template using the following guide : changing vendor templates. 

Alternatively, instead of a text area, you can have a single line for text:

Display Custom Field on Single Product Page

This code will display the values on the single product page. Add this code to your theme’s functions.php file:

Please Note

A list of available field types can be found in the Form Helper documentation


Updated on February 27, 2018

Was this article helpful?