From af2cdc45448db075707ad08742a8f28f549796ab Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 6 Feb 2024 07:09:46 +0100 Subject: [PATCH] Disable payment status column for automatic payments --- src/MerchantCapture/MerchantCaptureModule.php | 2 +- src/MerchantCapture/OrderListPaymentColumn.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index a3177f88..be048776 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -246,7 +246,7 @@ static function ($disableShipAndCapture, WC_Order $order) use ($container) { 10, 2 ); - new OrderListPaymentColumn(); + new OrderListPaymentColumn($container); new ManualCapture($container); new StateChangeCapture($container); }); diff --git a/src/MerchantCapture/OrderListPaymentColumn.php b/src/MerchantCapture/OrderListPaymentColumn.php index d74a9173..427ab7c9 100644 --- a/src/MerchantCapture/OrderListPaymentColumn.php +++ b/src/MerchantCapture/OrderListPaymentColumn.php @@ -6,11 +6,15 @@ use Automattic\WooCommerce\Admin\Overrides\Order; use Mollie\WooCommerce\MerchantCapture\UI\StatusRenderer; +use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; class OrderListPaymentColumn { - public function __construct() + /** @var ContainerInterface $container */ + private $container; + public function __construct($container) { + $this->container = $container; add_filter('manage_edit-shop_order_columns', [$this, 'renderColumn']); add_action('manage_shop_order_posts_custom_column', [$this, 'renderColumnValue'], 10, 2); @@ -23,6 +27,10 @@ public function __construct() public function renderColumn(array $columns): array { + if (!$this->container->get('merchant.manual_capture.enabled')) { + return $columns; + } + $newColumns = []; $mollieColumnAdded = false;