Commit d1daafc0 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Make sure the order numbers config section comes before all payment gateways; some small cleanup

parent 8c00ea49
......@@ -16,6 +16,7 @@ WC tested up to: 2.3
/**
* The structure of this plugin originally followed the tutorial, although much of the plugin has been rewritten since then:
* http://www.yaconiello.com/blog/how-to-write-wordpress-plugin/
* A lot of coding ideas were also taken directly from the way things are implemented in WooCommerce itself.
*/
if ( ! defined( 'ABSPATH' ) ) {
......@@ -111,11 +112,11 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
// register actions
add_filter( 'woocommerce_get_sections_checkout', array($this, 'add_admin_section'));
// The checkout settings page assumes all subpages are payment gateways, so we have to override this and manually pass our settings:
add_action( 'woocommerce_settings_checkout', array( $this, 'settings_output' ) );
add_action( 'woocommerce_settings_save_checkout', array( $this, 'settings_save' ) );
// Add the ordernumber post meta to the search in the backend
add_filter( 'woocommerce_shop_order_search_fields', array($this, 'order_search_fields'));
// The checkout page assumes all subpages are payment gateways, so we have to override this:
add_action( 'woocommerce_settings_checkout', array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_checkout', array( $this, 'save' ) );
// Sort the order list in the backend by order number rather than ID, make sure this is called LAST so we modify the defaults passed as arguments
add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'modify_order_column_sortkey' ), 9999 );
......@@ -131,12 +132,22 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
// Deactivate the plugin
public static function deactivate() {}
/**
* Insert our own section in the checkout setting page. Rearrange the sections array to make sure our settings
* come second place, directly after the default page with the '' key and before all the payment gateways
*/
function add_admin_section($sections) {
$sections['ordernumber'] = __( 'Order Numbers', 'woocommerce-advanced-ordernumbers');
return $sections;
$newsections = array();
foreach ($sections as $sec => $name ) {
$newsections[$sec] = $name;
if ($sec == '') {
$newsections['ordernumber'] = __( 'Order Numbers', 'woocommerce-advanced-ordernumbers');
}
}
return $newsections;
}
public function output() {
public function settings_output() {
global $current_section;
if ($current_section == 'ordernumber') {
$settings = $this->settings;
......@@ -144,7 +155,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
}
}
public function save() {
public function settings_save() {
global $current_section;
if ($current_section == 'ordernumber') {
$settings = $this->settings;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment