Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Advanced Order Numbers for WooCommerce
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WooCommerce
Advanced Order Numbers for WooCommerce
Commits
d1daafc0
Commit
d1daafc0
authored
10 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Make sure the order numbers config section comes before all payment gateways; some small cleanup
parent
8c00ea49
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
woocommerce-advanced-ordernumbers.php
+18
-7
18 additions, 7 deletions
woocommerce-advanced-ordernumbers.php
with
18 additions
and
7 deletions
woocommerce-advanced-ordernumbers.php
+
18
−
7
View file @
d1daafc0
...
@@ -16,6 +16,7 @@ WC tested up to: 2.3
...
@@ -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:
* 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/
* 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'
)
)
{
if
(
!
defined
(
'ABSPATH'
)
)
{
...
@@ -111,11 +112,11 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
...
@@ -111,11 +112,11 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
// register actions
// register actions
add_filter
(
'woocommerce_get_sections_checkout'
,
array
(
$this
,
'add_admin_section'
));
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 the ordernumber post meta to the search in the backend
add_filter
(
'woocommerce_shop_order_search_fields'
,
array
(
$this
,
'order_search_fields'
));
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
// 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
);
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
...
@@ -131,12 +132,22 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
// Deactivate the plugin
// Deactivate the plugin
public
static
function
deactivate
()
{}
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
)
{
function
add_admin_section
(
$sections
)
{
$sections
[
'ordernumber'
]
=
__
(
'Order Numbers'
,
'woocommerce-advanced-ordernumbers'
);
$newsections
=
array
();
return
$sections
;
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
;
global
$current_section
;
if
(
$current_section
==
'ordernumber'
)
{
if
(
$current_section
==
'ordernumber'
)
{
$settings
=
$this
->
settings
;
$settings
=
$this
->
settings
;
...
@@ -144,7 +155,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
...
@@ -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
;
global
$current_section
;
if
(
$current_section
==
'ordernumber'
)
{
if
(
$current_section
==
'ordernumber'
)
{
$settings
=
$this
->
settings
;
$settings
=
$this
->
settings
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment