From 08e916aab554106b087276b5f4a91306d063ac6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20N=C3=BCrnberger?= Date: Tue, 21 Nov 2023 14:15:13 +0100 Subject: [PATCH 1/2] Add filter `mollie_shipment_tracking_data` Allow external code to provide shipment tracking data before calling `shipAll()` on mollie order --- src/Payment/PaymentModule.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index d7c92734..1e539fa9 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -384,7 +384,8 @@ public function shipAndCaptureOrderAtMollie($order_id) } if ($mollie_order->isPaid() || $mollie_order->isAuthorized()) { - $this->apiHelper->getApiClient($apiKey)->orders->get($mollie_order_id)->shipAll(); + $shipmentTrackingData = apply_filters('mollie_shipment_tracking_data', null, $order); + $this->apiHelper->getApiClient($apiKey)->orders->get($mollie_order_id)->shipAll($shipmentTrackingData); $message = _x('Order successfully updated to shipped at Mollie, capture of funds underway.', 'Order note info', 'mollie-payments-for-woocommerce'); $order->add_order_note($message); $this->logger->debug(__METHOD__ . ' - ' . $order_id . ' - Order successfully updated to shipped at Mollie, capture of funds underway.'); From de4a6d4de8c34a71ab84aa7a76a306a84d5b8e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20N=C3=BCrnberger?= Date: Wed, 22 Nov 2023 17:57:40 +0100 Subject: [PATCH 2/2] Fixed default value for `mollie_shipment_tracking_data` filter --- src/Payment/PaymentModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index 1e539fa9..d4d0badc 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -384,7 +384,7 @@ public function shipAndCaptureOrderAtMollie($order_id) } if ($mollie_order->isPaid() || $mollie_order->isAuthorized()) { - $shipmentTrackingData = apply_filters('mollie_shipment_tracking_data', null, $order); + $shipmentTrackingData = apply_filters('mollie_shipment_tracking_data', [], $order); $this->apiHelper->getApiClient($apiKey)->orders->get($mollie_order_id)->shipAll($shipmentTrackingData); $message = _x('Order successfully updated to shipped at Mollie, capture of funds underway.', 'Order note info', 'mollie-payments-for-woocommerce'); $order->add_order_note($message);