def get(self, request, *args, **kwargs): seo, _ = SitePageSeo.objects.get_or_create(page_name='Корзина') service = SessionObjectService('cart') cart = service.get_or_create(request) context = { 'seo': seo, 'cart': service.serialize(cart), 'quick_buy_form': QuickBuyForm() } return render(request, 'cart.html', context)
def get_context_data(self, request): order_service = SessionObjectService('order') cart_service = SessionObjectService('cart') cart = cart_service.get_or_create(request) order = order_service.get_or_create(request) seo, _ = SitePageSeo.objects.get_or_create(page_name=self.page_name) delivery_method = DeliveryMethod.objects.get(id=order.get('delivery_method')) form = forms.OrderForm() context = { 'seo': seo, 'form': form, 'order': order, 'payment_method': PaymentMethod.objects.get(id=order.get('payment_method')), 'delivery_method': delivery_method, 'order_total_price': cart.get_total_price() + delivery_method.price, 'cart': cart_service.serialize(cart) } return context
def get_context_data(self, request): service = SessionObjectService('order') cart_service = SessionObjectService('cart') cart = cart_service.get_or_create(request) order_data = service.get_or_create(request) initial = { 'first_name': order_data.get('first_name', None), 'second_name': order_data.get('second_name', None), 'email': order_data.get('email', None), 'phone_number': order_data.get('phone_number', None), } seo, _ = SitePageSeo.objects.get_or_create(page_name=self.page_name) form = forms.OrderPersonalInformationForm(initial=initial, ) context = { 'seo': seo, 'form': form, 'order': order_data, 'cart': cart_service.serialize(cart) } return context
def get_context_data(self, request): service = SessionObjectService('order') order_data = service.get_or_create(request) cart_service = SessionObjectService('cart') cart = cart_service.get_or_create(request) initial = { 'delivery_method': order_data.get('delivery_method', None), 'index': order_data.get('index', None), 'city': order_data.get('city', None), 'street': order_data.get('street', None), 'building_number': order_data.get('building_number', None), 'apartment': order_data.get('apartment', None), 'order': order_data, } seo, _ = SitePageSeo.objects.get_or_create(page_name=self.page_name) form = forms.OrderDeliveryForm(initial=initial) context = { 'seo': seo, 'form': form, 'cart': cart_service.serialize(cart) } return context