Skip to content

Commit

Permalink
Merge pull request #52 from subscribepro/7-billing-address-is-not-saved
Browse files Browse the repository at this point in the history
Support saving billing address attached directly to subscription
  • Loading branch information
garthbrantley authored Dec 5, 2023
2 parents cfb5509 + 83e6dfe commit 86f5bed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SubscribePro/Service/Subscription/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function getFormData()
$formData[self::SHIPPING_ADDRESS] = $this->getShippingAddress()->getAsChildFormData($this->isNew());
}

if ($this->getBillingAddress() instanceof AddressInterface) {
$formData[self::BILLING_ADDRESS] = $this->getBillingAddress()->getAsChildFormData($this->isNew());
}

if (!empty($formData[self::SHIPPING_ADDRESS_ID])) {
unset($formData[self::SHIPPING_ADDRESS]);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/SubscribePro/Service/Subscription/SubscriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function create(array $data = [])
$addressData = $this->getFieldData($data, SubscriptionInterface::SHIPPING_ADDRESS);
$data[SubscriptionInterface::SHIPPING_ADDRESS] = $this->addressFactory->create($addressData);

$addressData = $this->getFieldData($data, SubscriptionInterface::BILLING_ADDRESS);
$data[SubscriptionInterface::BILLING_ADDRESS] = $this->addressFactory->create($addressData);

$paymentProfileData = $this->getFieldData($data, SubscriptionInterface::PAYMENT_PROFILE);
$data[SubscriptionInterface::PAYMENT_PROFILE] = $this->paymentProfileFactory->create($paymentProfileData);

Expand Down

0 comments on commit 86f5bed

Please sign in to comment.