Use the latest billing address as the default one

This commit is contained in:
PCoder 2019-12-26 18:54:17 +05:30
parent 9e87fa76c3
commit cbf2f05d70
2 changed files with 2 additions and 2 deletions

View file

@ -254,7 +254,7 @@ class PaymentOrderView(FormView):
) )
else: else:
billing_address_form = BillingAddressForm( billing_address_form = BillingAddressForm(
instance=self.request.user.billing_addresses.first() instance=self.request.user.billing_addresses.order_by('-id').first()
) )
user = self.request.user user = self.request.user
if hasattr(user, 'stripecustomer'): if hasattr(user, 'stripecustomer'):

View file

@ -626,7 +626,7 @@ class SettingsView(LoginRequiredMixin, FormView):
'user': self.request.user.id 'user': self.request.user.id
}) })
billing_address_user_form = UserBillingAddressForm( billing_address_user_form = UserBillingAddressForm(
instance=self.request.user.billing_addresses.first(), instance=self.request.user.billing_addresses.order_by('-id').first(),
data=billing_address_data) data=billing_address_data)
billing_address = billing_address_user_form.save() billing_address = billing_address_user_form.save()
billing_address.stripe_tax_id = '' billing_address.stripe_tax_id = ''