5

I am trying to add a dynamic field on WooCommerce -> Settings -> Products -> My Settings page

I follow this tutorial but its does not help in what I want to achieve.

http://docs.woothemes.com/document/adding-a-section-to-a-settings-tab/

I want to achieve something like this.

My Custom Setting interface

Tahir Yasin
  • 11,489
  • 5
  • 42
  • 59

1 Answers1

9

Because I have the time, I have created you an example...

you can find it here: woocommerce-woorei-dynamic-section-fields.php

just upload it on your plugins folder then activate to test. You can edit it for your needs.

for reference or to give you a hint, you can look for this files.

in my plugin line 58, take note of the type and id. actually id here can be anything other than empty string.

$settings_slider[] = array( 
   'type' => 'woorei_dynamic_field_table', 
   'id' => 'woorei_dynamic_field_table' 
);

take note also on the functions that comes next to it. Look at the names to get the idea.

then at woocommerce folder, take a look at this.

woocommerce\includes\admin\class-wc-admin-settings.php line 618 woocommerce\includes\admin\class-wc-admin-settings.php line 712

Reigel Gallarde
  • 64,198
  • 21
  • 121
  • 139
  • Thanks for the detailed response. Can we create interface exactly how it is shown in my screenshot? This is because I want to match it with other fields. Current is looking a bit OFF because other fields shows Label at left and Field on right. Please update the code. – Tahir Yasin Jan 20 '15 at 11:32
  • I inspected the code using firebug and I see the actual table is empty and custom table is injected beneath it.
    ....
    – Tahir Yasin Jan 20 '15 at 11:53
  • I think
    shouldn't be empty. It should have a and a , th for field label and td should contain the custom table, please have a look.
    – Tahir Yasin Jan 20 '15 at 11:54
  • no, copy how the way my code is done if you already have one.. don't activate my plugin.... copy it and change the name and id of the inputs to correspond to your needs. – Reigel Gallarde Jan 20 '15 at 12:04
  • Thank you very much for your help! I am accepting the answer. – Tahir Yasin Jan 20 '15 at 13:26