Skip to content

Instantly share code, notes, and snippets.

@bekarice
Created October 27, 2015 19:29
Show Gist options
  • Save bekarice/3190b3e1aead2ee23d69 to your computer and use it in GitHub Desktop.
Save bekarice/3190b3e1aead2ee23d69 to your computer and use it in GitHub Desktop.
<?php
// This is just a form sample
// Add a new section to WooCommerce > Settings > Products
function add_my_products_section( $sections ) {
$sections['tshirt_designer'] = __( 'T-Shirt Designer', 'my-textdomain' );
return $sections;
}
add_filter( 'woocommerce_get_sections_products', 'add_my_products_section' );
// Add Settings for new section
function add_my_products_settings( $settings, $current_section ) {
// make sure we're looking only at our section
if ( 'tshirt_designer' === $current_section ) {
$my_settings = array(
array(
'title' => __( 'My Settings Section', 'my-textdomain' ),
'type' => 'title',
'id' => 'my_settings_section',
),
array(
'id' => 'my_settings_radio',
'type' => 'radio',
'title' => __( 'A Radio input', 'my-textdomain' ),
'options' => array(
'uno' => __( 'The first option', 'my-textdomain' ),
'dos' => __( 'The second option', 'my-textdomain' ),
),
'default' => 'uno',
'desc' => __( 'What this radio does.', 'my-textdomain' ),
'desc_tip' => true,
),
array(
'type' => 'sectionend',
'id' => 'my_settings_section',
),
);
return $my_settings;
} else {
// otherwise give us back the other settings
return $settings;
}
}
add_filter( 'woocommerce_get_settings_products', 'add_my_products_settings', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment