Example #1
0
    def make_order(self, request):
        cart = get_cart(request)
        self.handle_user(request)
        self.handle_amount(request)

        # self.total_price = cart.total_price
        total_price = cart.get_price(price_type='total_price')
        # total_price = Decimal.from_float(total_price)
        # print("total_price:", total_price)
        # print("total_price:", type(total_price))
        self.total_price = total_price

        self.ordered = True
        self.save()
        cart.order = self
        cart.ordered = True
        cart.save()
        from sw_utils.helpers import get_admin_url
        from django.contrib.sites.models import Site
        site = Site.objects.get_current().domain
        order_admin_url = site + get_admin_url(self)
        cart_items = CartItem.objects.filter(cart=cart)
        context = {
            'cart_items': cart_items,
            'order_admin_url': order_admin_url,
        }
        box_send_mail(
            subject=_(f'Отримано замовлення товарів # {self.id}'),
            template='sw_order/mail.html',
            email_config=OrderRecipientEmail,
            model=self,
            fail_silently=True,
            # fail_silently= False,
            context=context,
        )
Example #2
0
 def get_admin_url(self):
     return get_admin_url(self)