handle orders with no products
This commit is contained in:
parent
fc077a43df
commit
7d679beae6
|
@ -90,13 +90,16 @@ class Order(CreatedUpdatedModel):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total(self):
|
def total(self):
|
||||||
return Decimal(self.products.aggregate(
|
if self.products.all():
|
||||||
sum=Sum(
|
return Decimal(self.products.aggregate(
|
||||||
models.F('orderproductrelation__product__price') *
|
sum=Sum(
|
||||||
models.F('orderproductrelation__quantity'),
|
models.F('orderproductrelation__product__price') *
|
||||||
output_field=models.IntegerField()
|
models.F('orderproductrelation__quantity'),
|
||||||
)
|
output_field=models.IntegerField()
|
||||||
)['sum'])
|
)
|
||||||
|
)['sum'])
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def get_coinify_callback_url(self, request):
|
def get_coinify_callback_url(self, request):
|
||||||
return 'https://' + request.get_host() + str(reverse_lazy('shop:coinify_callback', kwargs={'pk': self.pk}))
|
return 'https://' + request.get_host() + str(reverse_lazy('shop:coinify_callback', kwargs={'pk': self.pk}))
|
||||||
|
|
Loading…
Reference in a new issue