WP eCommerce includes several core sales statuses that can be used to manage the orders in your shop.
- Incomplete sale: customer added items to the cart but didn’t finish the purchase
- Order received: order created but awaiting payment (i.e., a check payment)
- Accepted payment: payment successful (i.e., credit card payment received)
- Job dispatched: up to you – used for ‘order shipped’ typically
- Closed order: order completed
- Payment declined: transaction unsuccessful
These can be changed when viewing all sales under Dashboard > Store Sales by selecting a different status from the dropdown:
However, you may have a different fulfillment workflow, and could need extra statuses available to manage your store. This tutorial walks through how to add a custom sales status to WP eCommerce.
We can add new statuses to this dropdown by using the wpsc_set_purchlog_statuses filter. This will let us push our own options into the set of purchase statuses, which is used to create this dropdown.
You’ll need to use the Code Snippets to add this to your site, as adding this to your theme’s functions.php
won’t work (the filter is run before your theme loads). You could also use a custom plugin if needed.
Note that there are 4 values that can be set: 'internalname'
, 'label'
, 'is_transaction'
, and 'order'
. The internal name should be a “slug” of the status, while the label is what’s printed in the dropdown. The 'order'
is a value that represents this status. This won’t affect where it’s displayed in your dropdown (it will be at the end), but it will be used to set the status. Choose any number 7 or higher, and make sure it’s unique for your status (if you’re adding multiple statuses).
The final value here is is_transaction
. This should be used and set to true
if this status is part a successful transaction lifecycle, i.e., anywhere in between when the order is paid and completed. Notice that I’ve set the “refund” status to 'is_transaction' => true
, as this would be after the order is paid and during the “payment lifecycle”, but that’s not necessary for the “Invoice sent” status since the order isn’t paid yet.
Once you’ve edited this snippet, activate it and you’ll now be able to set the status in your order list.
If you’re okay with these statuses not being in the bulk actions menu, then you can stop now and you’re done.
If you’d like to add them to the bulk actions, then I’ve created a plugin template that could be used instead. If you’re not sure how to edit the plugin, you could check out this tutorial on adding custom code to your site. I’d recommend using this on a testing site first in case something gets messed up.
The benefit to this template is that I’ve included the code to add these statuses to the bulk actions menu, but you’ll have to edit the functions to add your own status instead.
Here are the basic changes you’d need to make to the main plugin file:
- Edit the
sww_add_wpec_sales_status
function to add your custom statuses (same as tutorial above). Replace the current statuses, and add any others you need. Pay attention to the “order” value you add. - Edit the
sww_add_order_bulk_actions
function jQuery. Replace the.append
functions with the correct order values and names for your new sales statuses. You can add more options as needed if you have more statuses. - Edit the
sww_process_order_bulk_actions
function. You’ll need to change the first check here that ensures we’re only adding this if the right status is selected:
if ( 7 != $current_action && 8 != $current_action ) { return; }
You can continue to add to this statement with more &&
statements; for example, it could look like:
if ( 7 != $current_action && 8 != $current_action && 9 != $current_action )
Use your “order” values that you set set in the first function.
Once you’ve customized the main plugin file, upload it to your site your new statuses will be added and ready to use 🙂 .
Now go forth and manage orders!