From 67841e84d5c9c6a8b60d9460289807ff0e69f995 Mon Sep 17 00:00:00 2001 From: Sandor Czettner Date: Thu, 24 Aug 2023 13:05:39 +0100 Subject: [PATCH] Fix virtual products where there's no address for the order --- .../Service/Subscription/SubscriptionService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SubscribePro/Service/Subscription/SubscriptionService.php b/src/SubscribePro/Service/Subscription/SubscriptionService.php index ceae84c..7fc7878 100644 --- a/src/SubscribePro/Service/Subscription/SubscriptionService.php +++ b/src/SubscribePro/Service/Subscription/SubscriptionService.php @@ -50,7 +50,14 @@ public function createSubscription(array $subscriptionData = []) public function saveSubscription(SubscriptionInterface $subscription, array $metadata = null) { $url = $subscription->isNew() ? '/services/v2/subscription.json' : "/services/v2/subscriptions/{$subscription->getId()}.json"; - $payload = [self::API_NAME_SUBSCRIPTION => $subscription->getFormData()]; + $formData = $subscription->getFormData(); + $formData = array_filter($formData, function($data) { + if (is_array($data)&& count($data) == 0) { + return false; + } + return true; + }); + $payload = [self::API_NAME_SUBSCRIPTION => $formData]; if (!empty($metadata)) { $payload[self::API_NAME_META] = $metadata; }