Esempio n. 1
0
def show_cart(request):
	template = 'cart/cart.html'

	if request.method == 'POST':
		postdata = request.POST.copy()
		
		if 'remove' in postdata:
			cart.remove_from_cart(request) 

		if 'update' in postdata:
			cart.update_cart(request) 

		if 'Checkout' in postdata:
			checkout_url = checkout.get_checkout_url(request)
			return HttpResponseRedirect(checkout_url)
	
	cart_items = cart.get_cart_items(request)
	page_title = 'Shopping Cart'
	cart_subtotal = cart.cart_subtotal(request)
	
	context = {
			  'cart_items': cart_items,
			  'page_title': page_title,
			  'cart_subtotal': cart_subtotal,
			  }
	return render(request, template, context) 
Esempio n. 2
0
def show_cart(request):
    if request.method == 'POST':
        post_data = request.POST.copy()
        if 'submit_remove.x' in post_data:
            cart.remove_from_cart(request)
        if 'submit_update.x' in post_data:
            cart.update_cart(request)
    cart_item_count = cart.cart_distinct_item_count(request)
    cart_items = cart.get_cart_items(request)
    # mostrar el panel amarillo con infos muy importantes(1 de solo 2)
    if request.user.is_authenticated():
        try:
            promo4 = Promo4.objects.get(winner_user=request.user, active=True)
            small_text = "Ud. ha sido el ganador de una rifa, y ahora puede comprar estos productos<br/>"
            big_text = "Por un descuento del %d%%" % promo4.discount
        except Promo4.DoesNotExist:
            code, discount_ = get_discount_code(request)
            small_text = u"Puedes usar tu código de descuento aquí. %s%%" % discount_
            big_text = code

    total, discount, promotions, cart_subtotal, shipping_tax, shipping_tax_promotions = promo(
        request, cart_item_count, cart_items)
    page_title = 'Shopping Cart'
    return render_to_response('cart/show_cart.html',
                              locals(),
                              context_instance=RequestContext(request))
Esempio n. 3
0
def show_cart(request, template_name="cart/cart.html"): 
    if request.method == 'POST': 
        postdata = request.POST.copy() 
        if postdata['submit'] == 'Remove': 
            cart.remove_from_cart(request) 
        if postdata['submit'] == 'Update': 
            cart.update_cart(request) 
    cart_items = cart.get_cart_items(request) 
    page_title = 'Shopping Cart' 
    cart_subtotal = cart.cart_subtotal(request) 
    return render_to_response(template_name, locals(),context_instance=RequestContext(request))
Esempio n. 4
0
def show_cart(request, template_name='cart/cart.html'):
    if request.method == "POST":
        postdata = request.POST.copy()
        if postdata['submit'] == "Remove":
            cart.remove_from_cart(request)
        if postdata['submit'] == "Update":
            cart.update_cart(request)
    cart_items = cart.get_cart_items(request)
    page_title = "Shopping Cart"
    cart_subtotal = cart.cart_subtotal(request)
    return render_to_response(template_name, locals(), RequestContext(request))
Esempio n. 5
0
def show_cart(request):
    cart_items = cart.get_cart_items(request)

    if request.method == 'POST':
        postdata = request.POST.copy()
        if 'update' in postdata.keys():
            cart.update_cart(request)
        if 'remove' in postdata.keys():
            cart.remove_from_cart(request)
            
    cart_subtotal = cart.get_cart_subtotal(request)
    total = cart_subtotal
    return render_to_response('irteerak/cart.html',locals(),context_instance=RequestContext(request))
Esempio n. 6
0
def update_cart(request):
    if request.method == 'POST':
        postdata = request.POST.copy()
        giltzak = [a for a in postdata.keys() if a.startswith('item_')]
        idak=[]
        for giltza in giltzak:
           id =giltza.split('_')[1]
           if not id in idak:
              idak.append(id)
              item_id=int(id)
              quantity=request.POST.get('item_%d_quantity'%(item_id),0)
              cart.update_cart(request, item_id, quantity)
    return HttpResponseRedirect(reverse('csirteerak_show_cart'))
Esempio n. 7
0
def show_cart(request, template_name = 'cart/cart.html'):
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit']=='Remove':
            cart.remove_from_cart(request)
        if postdata['submit']=='Update':
            cart.update_cart(request)
    cart_item = cart.get_cart_items(request)
    cart_id = cart._cart_id(request)
    page_title = 'Корзина'
    cart_subtotal = cart.cart_subtotal(request)
    context = {'cart_item': cart_item, 'cart_id': cart_id, 'cart_subtotal': cart_subtotal}
    return render(request, template_name, context)
Esempio n. 8
0
def show_cart(request):
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    return render(request, 'cart/cart.html', locals())
Esempio n. 9
0
def show_cart(request, template_name="cart/cart.html"):
    if request.method == "POST":
        postdata = request.POST.copy()
        if postdata['submit'] == "Remove":
            cart.remove_from_cart(request)
        if postdata['submit'] == "Update":
            cart.update_cart(request)
            
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)

    return render_to_response(template_name, locals(),
                              context_instance=RequestContext(request))
Esempio n. 10
0
def show_cart_page(request):
	categories = Product.objects.values_list('category_name', flat = True ).distinct()
	if request.method == 'POST':
		postdata = request.POST.copy()
		if postdata['submit'] == 'Update':
			update_cart(request)
			orders = request.session.get('cart', '')
			cart_sum = cart_total(request)
			return render(request, "frontend/shoppingcart.html", locals())
		if postdata['submit'] == 'Delete':
			remove_from_cart(request)

	orders = request.session.get('cart', '')
	cart_sum = cart_total(request)
	return render(request, "frontend/shoppingcart.html", locals())
Esempio n. 11
0
def show_cart(request, template_name="cart/show_cart.html"):
    page_title = 'Musical Instruments and Sheet Music for Musicians'
    if request.method == 'POST':
        post_data = request.POST.copy()
        if post_data['submit'] == "Update":
            cart.update_cart(request)
        if post_data['submit'] == 'Remove':
            cart.remove_from_cart(request)

    cart_subtotal = cart.cart_subtotal(request)    
    cart_items =  cart.get_cart_items(request)
    
    
    return render_to_response(template_name, locals(),
                              context_instance=RequestContext(request))
Esempio n. 12
0
def show_cart(request, template_name="cart/cart.html"):
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    # need for Google Checkout button
    #merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name, locals(),context_instance=RequestContext(request))
Esempio n. 13
0
def show_cart(request, template_name="cart/cart.html"):
    categories = Category.objects.all()
    if request.method == "POST":
        postdata = request.POST.copy()
        if postdata["submit"] == "Remove":
            cart.remove_from_cart(request)
        if postdata["submit"] == "Update":
            cart.update_cart(request)
        if postdata["submit"] == "Checkout":
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = "Shopping Cart"
    cart_subtotal = cart.cart_subtotal(request)
    # for Google Checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Esempio n. 14
0
def show_cart(request, template_name="cart/cart.html"):
  """Displays the shopping cart page
  """
  context = set_context(request, Context({
    'page_title': 'Shopping Cart',
  }))

  if request.method == 'POST':
    postdata = request.POST.copy()
    if postdata['submit'] == 'Remove':
      cart.remove_from_cart(request)
    if postdata['submit'] == 'Update':
      cart.update_cart(request)

  context['cart_items'] = cart.get_cart_items(request)
  context['cart_subtotal'] = cart.cart_subtotal(request)

  return render(request, template_name, context)
Esempio n. 15
0
def show_cart(request, template_name="cart/cart.html"):
    categories = Category.objects.all()
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    # for Google Checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Esempio n. 16
0
def show_cart(request, template_name="cart.html"):
    if request.method == 'POST':
        postdata = request.POST.copy()
        s = postdata['submit']
        c = u'\uf021'
        r = u'\uf00d'

        if postdata['submit'] == r:
            cart.remove_from_cart(request)

        if postdata['submit'] == c:
            cart.update_cart(request)

    cart_items = cart.get_cart_items(request)
    page_title = "Ваш Заказ"
    cart_subtotal = cart.cart_subtotal(request)
    cart_distinct = cart.cart_distinct_item_count(request)

    categories = Category.objects.filter(is_active=True)
    brands = Brand.objects.filter(is_active=True)

    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Esempio n. 17
0
def show_cart(request, template_name="cart/cart.html"):
    cart_item_count = cart.cart_item_count(request)
    if request.method == 'POST':
        postdata = request.POST.copy()
        print postdata
        if postdata['submit'] == u'Удалить':
            cart.remove_from_cart(request)
            message = u'Товар удален из корзины.'
            messages.success(request, message)
        if postdata['submit'] == u'Сохранить':
            cart.update_cart(request)
            message = u'Изменения приняты.'
            messages.success(request, message)
        return redirect('show_cart')
    cart_items = cart.get_cart_items(request)
    page_title = u'Корзина'
    cart_total = cart.cart_total(request)
    torgpred = False
    user = request.user
    if user.groups.filter(name=u'Торговые представители').exists():
        torgpred = True
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Esempio n. 18
0
def get_cart(bot, update, products, access_token):
    query = update.callback_query

    if query.data == 'Меню':
        del_old_message(bot, update)
        keyboard = start_keyboard(products)
        reply_markup = InlineKeyboardMarkup(keyboard)
        bot.send_message(chat_id=query.message.chat_id,
                         text='Please choose:',
                         reply_markup=reply_markup)
        return 'HANDLE_MENU'

    elif query.data == 'Оплатить':
        bot.send_message(chat_id=query.message.chat_id,
                         text='Введите вашу почту для связи:')
        return "WAITING_EMAIL"

    elif query.data:
        moltin.delete_product_in_cart(access_token, query.message.chat_id,
                                      query.data)
        cart.update_cart(bot, update, access_token)
        return "HANDLE_CART"
Esempio n. 19
0
def show_cart(request, template_name="cart/cart.html"):
    if request.method == 'POST':
        subtotal_class = cart.Subtotal(request)
        cart_items = cart.get_cart_items(request)
#        cart_subtotal = subtotal_class.subtotal()
        discount = subtotal_class.discount
        postdata = request.POST.copy()
        form = OrderForm(request.POST)

        if 'Remove' in postdata:
            cart.remove_from_cart(request)
        if 'Update' in postdata:
            cart.update_cart(request)
        if form.is_valid():
            # Пишу клиента в базу
            cart.save_client(request, form)
            # Удаляю сессию у клиента
            del request.session['cart_id']
            is_order = 1
            # Отправляем админу смс
            if SEND_SMS:
                cart.send_sms(cart_items, form)
            # Отправляем админу email
            if SEND_EMAIL:
                cart.send_admin_email(request, cart_items, form)
                if form.cleaned_data['email']:
                    # Отправляем email клиенту
                    cart.send_client_email(cart_items, form)
    else:
        form = OrderForm()

    cart_items = cart.get_cart_items(request)
#    if cart_items:
#        subtotal_class = cart.Subtotal(request)
#        cart_subtotal = subtotal_class.subtotal()
#        discount = subtotal_class.discount
    page_title = 'Корзина'
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Esempio n. 20
0
def cart_view(request, template_name="cart/cart.html"):
    """Представление для отображения корзины"""

    postdata = request.POST.copy()

    if request.method == 'POST':

        if postdata.has_key('add'):
            cart.add_to_cart(request)
            order = cart.get_cart(request)
            # res = {'order': order, }
            # html = render_to_string('cart/summary.html', res, context_instance=RequestContext(request))
            # return JsonResponse({
            #     'success': True,
            #     'action_add': True,
            #     'panel_html': html,
            # })
        if postdata.has_key('remove'):
            cart.remove_from_cart(request)

        if postdata.has_key('update'):
            cart.update_cart(request)

        if postdata.has_key('update') or postdata.has_key('remove') or postdata.has_key('add'):
            order = cart.get_cart(request)
            formset = OrderFormset(instance=order)
            res = {
                'order_form': DefaultOrderForm(request.POST),
                'formset': formset,
                'order': order,
                'keep': BASKET_OPTIONS_USE_KEEP,
                'delete': True,
            }
            html = render_to_string('cart/cart_table.html', res, context_instance=RequestContext(request))
            panel_html = render_to_string('cart/summary.html', res, context_instance=RequestContext(request))
            return JsonResponse({
                'success': True,
                # 'action_remove': True,
                'html': html,
                'panel_html': panel_html,
            })

        # if postdata.has_key('checkout'):
        #     checkout_url = checkout.get_checkout_url(request)
        #     return HttpResponseRedirect(checkout_url)
    # Получаем список всех товаров в корзине из cookies
    #cart_item_count = cart.cart_item_count(request)
    # cart_items = cart.get_cart_items(request)
    # cart_subtotal = cart.cart_subtotal(request)
    # return render_to_response(template_name, locals(),
    #                           context_instance=RequestContext(request))

    form = DefaultOrderForm(postdata or None)
    order = cart.get_cart(request)

    if form.is_valid() and order.goods > 0:
        contact = form.save(commit=False)
        contact.order = order
        contact.save()

        remote_address = request.META.get('REMOTE_ADDR')
        order.ip_address=remote_address
        order.status = 2
        order.save()

        return HttpResponseRedirect(reverse('cart:cart_confirm'))

    # else:
    #     return HttpResponseRedirect(reverse('cart:show_cart'))

    # order = cart.get_cart(request)
    formset = OrderFormset(instance=order)
    # form = DefaultOrderForm(postdata or None)
    return {
        'order_form': form,
        'formset': formset,
        'order': order,
        'keep': BASKET_OPTIONS_USE_KEEP,
        'delete': True,
    }
Esempio n. 21
0
def update_cart(request):
    cart.update_cart(request)
    return HttpResponseRedirect('/cart/')