Skip to content

Commit

Permalink
Merge pull request #46 from czettnersandor/bugfix/virtual-product-no-…
Browse files Browse the repository at this point in the history
…address

Fix virtual products where there's no address for the order
  • Loading branch information
garthbrantley authored Aug 25, 2023
2 parents f90f01b + 67841e8 commit 5f53ac6
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5f53ac6

Please sign in to comment.