|
|
@@ -18,6 +18,8 @@ class Order_Status_Manager {
|
|
|
add_action('init', array($this, 'register_custom_order_statuses'));
|
|
|
add_filter('wc_order_statuses', array($this, 'add_custom_order_statuses_to_list'));
|
|
|
add_action('woocommerce_order_status_changed', array($this, 'handle_status_transitions'), 10, 3);
|
|
|
+ add_action('woocommerce_payment_complete', array($this, 'set_order_processing_status'));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function register_custom_order_statuses() {
|
|
|
@@ -53,13 +55,25 @@ class Order_Status_Manager {
|
|
|
public function handle_status_transitions($order_id, $old_status, $new_status) {
|
|
|
// Handle status transitions here
|
|
|
// For example:
|
|
|
- if ($new_status === 'wc-to-print') {
|
|
|
+ UtilsLog::log('Order #' . $order_id . ' status change ' . $old_status . ' -> ' . $new_status);
|
|
|
+ if ($new_status === 'to-print') {
|
|
|
update_post_meta($order_id, 'to-print-date', current_time('mysql'));
|
|
|
- } elseif ($new_status === 'wc-in-print') {
|
|
|
+ } elseif ($new_status === 'in-print') {
|
|
|
update_post_meta($order_id, 'in-print-date', current_time('mysql'));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function set_order_processing_status($order_id) {
|
|
|
+ UtilsLog::log('Order #' . $order_id . ' payment complete');
|
|
|
+ $order = wc_get_order($order_id);
|
|
|
+ if ($order && !$order->has_status('completed')) {
|
|
|
+ UtilsLog::log('Order #' . $order_id . ' will be move to processing');
|
|
|
+ $order->update_status('processing', __('Payment received, order is now processing.', 'studiou-wc-ord-print-statuses'));
|
|
|
+ // Add a note to the order
|
|
|
+ $order->add_order_note(__('Order automatically set to processing by Studiou WC Order Print Statuses plugin.', 'studiou-wc-ord-print-statuses'));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
public function get_custom_statuses() {
|
|
|
return $this->custom_statuses;
|
|
|
}
|