Skip to content

Instantly share code, notes, and snippets.

@xafarali
Last active November 6, 2015 01:38
Show Gist options
  • Save xafarali/b618ea391d420b5ad487 to your computer and use it in GitHub Desktop.
Save xafarali/b618ea391d420b5ad487 to your computer and use it in GitHub Desktop.
Add Options to Woocomm Setting Page
add_filter( 'woocommerce_general_settings', 'add_order_number_start_setting' );
/*
woocommerce_general_settings
woocommerce_catalog_settings
woocommerce_page_settings
woocommerce_inventory_settings
woocommerce_tax_settings
woocommerce_shipping_settings
woocommerce_payment_gateways_settings
woocommerce_email_settings
*/
function add_order_number_start_setting( $settings ) {
$updated_settings = array();
foreach ( $settings as $section ) {
// at the bottom of the General Options section
if ( isset( $section['id'] ) && 'general_options' == $section['id'] &&
isset( $section['type'] ) && 'sectionend' == $section['type'] ) {
$updated_settings[] = array(
'name' => __( 'Order Number Start', 'wc_seq_order_numbers' ),
'desc_tip' => __( 'The starting number for the incrementing portion of the order numbers, unless there is an existing order with a higher number.', 'wc_seq_order_numbers' ),
'id' => 'woocommerce_order_number_start',
'type' => 'text',
'css' => 'min-width:300px;',
'std' => '1', // WC < 2.0
'default' => '1', // WC >= 2.0
'desc' => __( 'Sample order number: AA-20130219-000-ZZ', 'wc_seq_order_numbers' ),
);
}
$updated_settings[] = $section;
}
return $updated_settings;
}
$order_number_start = get_option( 'woocommerce_order_number_start', 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment