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
99ed5f31
Commit
99ed5f31
authored
10 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
Make it work in the FE, too
parent
6327cf30
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
TODO
+1
-1
1 addition, 1 deletion
TODO
woocommerce-advanced-ordernumbers.php
+16
-2
16 additions, 2 deletions
woocommerce-advanced-ordernumbers.php
with
17 additions
and
3 deletions
TODO
+
1
−
1
View file @
99ed5f31
OpenTools Advanced Ordernumbers for WooCommerce - Open TODOs
OpenTools Advanced Ordernumbers for WooCommerce - Open TODOs
============================================================
============================================================
- Make sure the numbers are generated only for new orders, not for ex
s
iting ones
- Make sure the numbers are generated only for new orders, not for exi
s
ting ones
- Check REST API
- Check REST API
- Would it make sense to configure the order password format?
- Would it make sense to configure the order password format?
- Find out how multisite works and make the plugin work with it
- Find out how multisite works and make the plugin work with it
...
...
This diff is collapsed.
Click to expand it.
woocommerce-advanced-ordernumbers.php
+
16
−
2
View file @
99ed5f31
...
@@ -192,7 +192,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
...
@@ -192,7 +192,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
// When a new order is created, we immediately assign the order number:
// When a new order is created, we immediately assign the order number:
add_action
(
'wp_insert_post'
,
array
(
&
$this
,
'check_create_ordernumber'
),
10
,
3
);
add_action
(
'wp_insert_post'
,
array
(
&
$this
,
'check_create_ordernumber'
),
10
,
3
);
add_action
(
'save_post'
,
array
(
&
$this
,
'check_create_ordernumber'
),
10
,
3
);
//
add_action( 'save_post', array(&$this, 'check_create_ordernumber'), 10, 3);
// The filter to actually return the order number for the given order
// The filter to actually return the order number for the given order
add_filter
(
'woocommerce_order_number'
,
array
(
&
$this
,
'get_ordernumber'
),
10
,
2
/*<= Also get the order object! */
);
add_filter
(
'woocommerce_order_number'
,
array
(
&
$this
,
'get_ordernumber'
),
10
,
2
/*<= Also get the order object! */
);
}
}
...
@@ -533,6 +533,20 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
...
@@ -533,6 +533,20 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
return
wp_parse_args
(
$custom
,
$columns
);
return
wp_parse_args
(
$custom
,
$columns
);
}
}
/**
* Add the "create new order number" action to the edit order page in the Backend
*/
public
function
add_order_action_new_number
(
$actions
)
{
$actions
[
'assign_new_ordernumber'
]
=
self
::
__
(
'Assign a new order number'
);
}
/**
* Handle the "Assign a new order number" action from the edit order page in the backend
*/
public
function
order_action_assign_new_ordernumber
(
$order
)
{
$number
=
$this
->
create_ordernumber
(
$order
->
id
,
$order
,
'ordernumber'
);
}
/**
/**
* Handle new posts created in the frontend. This action will be called for all posts,
* Handle new posts created in the frontend. This action will be called for all posts,
* not only for orders, so we need to check explicitly. Also, this function will be called
* not only for orders, so we need to check explicitly. Also, this function will be called
...
@@ -884,7 +898,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
...
@@ -884,7 +898,7 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
* The hook to assign a customized order number (unless the order already has one assigned)
* The hook to assign a customized order number (unless the order already has one assigned)
*/
*/
function
assign_new_ordernumber
(
$orderid
,
$order
,
$update
=
true
)
{
function
assign_new_ordernumber
(
$orderid
,
$order
,
$update
=
true
)
{
if
((
!
$update
)
&&
(
$order
->
post_status
==
'auto-draft'
))
{
if
((
!
$update
)
/*
&& ($order->post_status == 'auto-draft')
*/
)
{
// New order => assign placeholder, which will later be overwritten the real order number
// New order => assign placeholder, which will later be overwritten the real order number
update_post_meta
(
$orderid
,
$this
->
ordernumber_meta
,
$this
->
ordernumber_new_placeholder
);
update_post_meta
(
$orderid
,
$this
->
ordernumber_meta
,
$this
->
ordernumber_new_placeholder
);
}
}
...
...
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