Skip to content

Commit

Permalink
HOTFIX - non re-orderable statuses to be editable
Browse files Browse the repository at this point in the history
  • Loading branch information
jpham93 committed Feb 15, 2023
1 parent 4f72179 commit fcc6f65
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions classes/VTAWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function __construct( string $plugin_name, string $plugin_version, VTACos

// Add Re-orderable statuses
add_filter('woocommerce_valid_order_statuses_for_order_again', [ $this, 'add_reorderable_statuses' ], 9, 1);
add_filter('wc_order_is_editable', [ $this, 'add_editable_statuses' ], 10, 2);
}

// POST STATUS / ORDER STATUS REGISTRATION CALLBACKS //
Expand Down Expand Up @@ -285,6 +286,22 @@ public function add_reorderable_statuses( array $order_statuses ): array {
return $order_statuses;
}

/**
* Filter CB that allows non-finished orders to be editable.
* @param bool $is_editable
* @param WC_Order $order current order
* @return bool order statuses that should be allowed to re-order
*/
public function add_editable_statuses( bool $is_editable, WC_Order $order ): bool {
$status = $order->get_status();
foreach ( $this->settings->get_reorderable_statuses() as $vta_cos ) {
if ($status === $vta_cos->get_cos_key()) {
return false;
}
}
return true;
}

// PRIVATE METHODS //

/**
Expand Down

0 comments on commit fcc6f65

Please sign in to comment.