1
votes

I am new to wordpress and woocommerce development and I am just wondering, how to manipulate an admin-screen in a clean, updateable way.

For example, I want to add a custom field to a product edit page (see screen):

enter image description here

I know, that I have to write a custom extension, but is it possible, to manipulate admin-screens of other extensions? I couldn't find any suitable tutorial? Maybe someone has a hint, where to start?

2

2 Answers

5
votes

The feature of creating custom fields for products is baked right into WooCommerce, whether to implement it directly in functions.php or do the same via a plugin is left to one's sole discretion.

Remi Corson has written an excellent article detailing the same.

Here's the gist :

1.Create the fields using the woocommerce_product_options_general_product_data hook

add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );

function woo_add_custom_general_fields() {
     // Define your fields here. 
     // You can create text, textarea, select, checkbox and custom fields
}

2.When product is saved save the value entered in your custom field using woocommerce_process_product_meta hook

add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );

function woo_add_custom_general_fields_save( $_post_id ) {
    //save field values
}
0
votes

WooCommerce is a WordPress plugin that will help you to turn your website into an eCommerce store.

Yes, you can write an Extension ( or ADD-On) for this plugin, in fact there are already hundreds of Extension ( free and Paid ) have been made for it.

In order to create an Extension ( or ADD-ON ) for this plugin, you need to understand 2 things:

  1. WooCommerce API http://docs.woothemes.com/document/create-a-plugin/
  2. WordPress API https://codex.wordpress.org/Writing_a_Plugin