Skip to content
Snippets Groups Projects
Commit 9d2047da authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Code cleanup (remove commented code)

parent cdae04ef
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ WC tested up to: 2.3
*/
/**
* The structure of this plugin follows the tutorial:
* 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/
*/
......@@ -108,17 +108,10 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
add_option ('ordernumber_step', '1');
// register actions
// add_action( 'admin_init', array(&$this, 'admin_init'));
// add_action( 'admin_menu', array(&$this, 'add_menu'));
// TODO: Find the proper action hooks to hook into:
add_filter( 'woocommerce_get_sections_checkout', array($this, 'add_admin_section'),1);
// add_filter( 'woocommerce_get_settings_checkout', array( $this, 'admin_settings' ), 20, 2);
// 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' ) );
add_action( 'woocommerce_update_options_catalog', array( $this, 'save_admin_settings' ) ); // < 2.1
add_action( 'woocommerce_update_options_products', array( $this, 'save_admin_settings' ) ); // 2.1 +
// register filters
add_filter("plugin_action_links_$plugin", array(&$this, 'plugin_settings_link'));
......@@ -152,73 +145,8 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
}
}
// // Save the settings
// function save_admin_settings() {
// woocommerce_update_options( $this->settings );
// }
// /**
// * hook into WP's admin_init action hook
// */
// public function admin_init()
// {
// // Set up the settings for this plugin
// $this->init_settings();
// // Possibly do additional admin_init tasks
// }
// /**
// * Initialize some custom settings
// */
// public function init_settings()
// {
// // register the settings for this plugin
// // TODO: Properly design the set of options needed
// register_setting('opentools-ordernumbers-group', 'customize_ordernumbers');
// register_setting('opentools-ordernumbers-group', 'ordernumber_format');
// register_setting('opentools-ordernumbers-group', 'ordernumber_counter_scope');
// }
// /**
// * add a menu
// */
// public function add_menu()
// {
// // TODO: Move this inside the WooCommerce configuration!
// add_options_page(
// 'Advanced Ordernumber Plugin Settings', // The title to be displayed in the browser window for this page.
// 'OpenTools Advanced Ordernumbers', // The text to be displayed for this menu item
// 'manage_options', // Which type of users can see this menu item
// 'opentools-ordernumbers', // The unique ID - that is, the slug - for this menu item
// array(&$this, 'plugin_settings_page') // The name of the function to call when rendering this menu's page
// );
// }
// function plugin_settings_link($links)
// {
// $settings_link = '<a href="options-general.php?page=opentools-ordernumbers">Settings</a>';
// array_unshift($links, $settings_link);
// return $links;
// }
// /**
// * Menu Callback
// */
// public function plugin_settings_page()
// {
// if(!current_user_can('manage_options'))
// {
// wp_die(__('You do not have sufficient permissions to access this page.'));
// }
//
// // Render the settings template
// include(sprintf("%s/templates/settings.php", dirname(__FILE__)));
// }
/**
* Counter handling (simple loading/storing counters)
* Counter handling (simple loading/storing counters), storing them as options
*/
function _getCounter($type, $format, $start=1) {
$count = get_option ('ordernumber-counter-'.$type.'-'.$format, $start);
......@@ -264,17 +192,8 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
return self::randomString ($alphabet, $len);
}
/* Extract the country information from the given ID */
// static function getCountryFromID ($country_id) {
// $db = JFactory::getDBO();
// $query = 'SELECT * FROM `#__virtuemart_countries` WHERE `virtuemart_country_id` = ' . (int)$country_id;
// $db->setQuery($query);
// return $db->loadObject();
// }
/* Type 0 means order number, type 1 means invoice number, type 2 means customer number, 3 means order password */
/* replace the variables in the given format. $type indicates the type of number, currently only 'ordernumber', because WooCommerce does not support invoices or customer numbers. We might allow the shop owner to customize the order password, though. */
function replace_fields ($fmt, $type, $order) {
// First, replace all randomXXX[n] fields. This needs to be done with a regexp and a callback:
$fmt = preg_replace_callback ('/\[(random)(.*?)([0-9]*?)\]/', array($this, 'replaceRandom'), $fmt);
......@@ -292,7 +211,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
"[orderid]" => $order->id,
"[userid]" => $order->get_user_id(),
);
// if (isset($order->virtuemart_vendor_id)) $reps["[vendorid]"] = $order->virtuemart_vendor_id;
$reps["[ipaddress]"] = $order->customer_ip_address;
$reps["[orderstatus]"] = $order->get_status();
$reps["[email]"] = $order->billing_email;
......@@ -333,7 +252,6 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
}
// Allow customization via plugins: filter function($reps, $order, $type, $fmt)
$reps = apply_filters( 'opentools_ordernumber_replacements', $reps, $order, $type, $fmt);
// return print_r($reps,1);
return str_ireplace (array_keys($reps), array_values($reps), $fmt);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment