當前位置: 首頁>>代碼示例>>Python>>正文


Python cart.Cart類代碼示例

本文整理匯總了Python中carton.cart.Cart的典型用法代碼示例。如果您正苦於以下問題:Python Cart類的具體用法?Python Cart怎麽用?Python Cart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Cart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add

def add(request):
    cart = Cart(request.session)
    selitem_id = request.GET.get('id')
    selitem_qty = request.GET.get('quantity')
    selitem = Item.objects.get(id=selitem_id)
    cart.add(selitem, selitem_qty, price=selitem.price)
    return redirect(reverse('store') + "#No{}Card".format(selitem.product.id))
開發者ID:YuMingChang,項目名稱:MMCB,代碼行數:7,代碼來源:views.py

示例2: pago

def pago(request):
	if request.method == "POST":
		cart = Cart(request.session)
		if not cart.is_empty:
			#
			#	Guardo el pedido
			# ===========================
			
			# creo un pedido con los datos del cliente y el restaurante
			restaurante =cart.items[0].product.restaurante
			cliente = Cliente.objects.get(user=request.user) #falta el cliente
			pedido = Pedido (restaurante=restaurante, cliente=cliente)
			pedido.save()
			
			#aado platos al pedido
			for item in cart.items:
				plato = item.product
				Detalle_pedido(plato=plato, pedido=pedido, cantidad=item.quantity).save()
						
			

			if request.POST.get('pago') == "Paypal":
				return paypal_create(request)
			elif request.POST.get('pago') == "Efectivo":
				cart.clear() #Se vacia el carrito
				return HttpResponseRedirect(reverse('pago_exitoso'))
開發者ID:gamezinfantes,項目名稱:UFood,代碼行數:26,代碼來源:views.py

示例3: empty_cart

def empty_cart(request):
	cart = Cart(request.session)
	cart.clear()
	html = new_cart_html(request,1)
	cart_contents_qty = cart_contents_empty(request)
	payload = update_cart_status_and_prepare_payload(request, html, cart_contents_qty)
	return HttpResponse(json.dumps(payload), content_type="application/json")
開發者ID:vlameiras,項目名稱:cdkeyswholesale,代碼行數:7,代碼來源:views.py

示例4: charge

def charge(request):
    cart = Cart(request.session)
    if cart.unique_count > 0:
        if request.method == "POST":
            form = SalePaymentForm(request.POST or None)
            if form.is_valid(): # charges the card
                template = get_template('tinbox/order-response-email.html')
                context = Context({'cart': cart, 'total': cart.total, 'shipping_cost': form.cleaned_data.get("shipping"), 'name' : form.cleaned_data.get("name") })
                content = template.render(context)
                cart.clear()
                form_email = form.cleaned_data.get("email")
                form_name = form.cleaned_data.get("name")
                subject = 'Tinbox Solutions - Order Successfully Processed'
                from_email = settings.EMAIL_HOST_USER
                to_email = [form_email]
                msg = EmailMultiAlternatives(subject, "", from_email, to=to_email)
                msg.attach_alternative(content, "text/html")
                msg.send()
                return HttpResponseRedirect('/shopping/thank-you')
            else:
                t = form.determineShippingFormField(1, cart.total)
                return render_to_response("tinbox/charge.html", RequestContext( request, {'form': form, 'turnaround_cost' : t.turnaround_cost, 'turnaround' : t.turnaround} ) )
        else:
            form = SalePaymentForm()
            t = form.determineShippingFormField(1, cart.total)
        return render_to_response("tinbox/charge.html", RequestContext( request, {'form': form, 'turnaround_cost' : t.turnaround_cost, 'turnaround' : t.turnaround} ) )

    else:
        return render(request, 'tinbox/show-cart.html', {"empty": True})
開發者ID:ehorvat,項目名稱:tinbox-webapp,代碼行數:29,代碼來源:views.py

示例5: add

def add(request):
    cart = Cart(request.session)
    event = Event.objects.get(id=request.GET.get('id'))
    cart.add(event, price=event.price)

    messages.success(request, "Event added to basket")

    return render(request, 'ticket/cart/basket.html')
開發者ID:mohsin-mulla,項目名稱:bandpunch,代碼行數:8,代碼來源:views.py

示例6: remove

def remove(request):
    cart = Cart(request.session)
    event = Event.objects.get(id=request.GET.get('id'))
    cart.remove_single(event)

    messages.success(request, "Event removed from basket")

    return render(request, 'ticket/cart/basket.html')
開發者ID:mohsin-mulla,項目名稱:bandpunch,代碼行數:8,代碼來源:views.py

示例7: add

def add(request):
    cart = Cart(request.session)
    product = Product.objects.get(pk=request.POST.get('product_id'))
    quantity = request.POST.get('quantity', 1)
    discount = request.POST.get('discount', 0)
    price = product.price - float(discount)
    cart.add(product, price, quantity)
    return HttpResponse()
開發者ID:50c10,項目名稱:django-carton,代碼行數:8,代碼來源:views.py

示例8: remove_single

def remove_single(request):
    cart = Cart(request.session)
    initial_count = cart.count
    product = products[int(request.POST.get('product_id'))]
    cart.remove_single(product)
    after_rmv_count = cart.count
    assert initial_count == after_rmv_count + 1
    return HttpResponse()
開發者ID:jongabriel,項目名稱:django-carton,代碼行數:8,代碼來源:views.py

示例9: remove

def remove(request):
	"""
	刪除一個商品
	"""
	cart = Cart(request.session)
	product = Product.objects.get(id=request.GET['id'])
	cart.remove(product)
	return HttpResponseRedirect('/cart/')
開發者ID:NirvanaStar,項目名稱:woodsam,代碼行數:8,代碼來源:views.py

示例10: show

def show(request):
    cart = Cart(request.session)
    if request.method == 'POST':
        quantitylist = request.POST.getlist('quantity[]')
        for idx, item in enumerate(cart.products):
            item = Item.objects.get(id=item.id)
            cart.set_quantity(item, quantitylist[idx])
        return redirect(reverse('checkout:page'))
    return render(request, 'shopping/show-cart.html')
開發者ID:YuMingChang,項目名稱:MMCB,代碼行數:9,代碼來源:views.py

示例11: update_cart

def update_cart(request):
    cart = Cart(request.session)
    for product in cart.products:
        print product.name
        qty = int(request.POST.get("product_" + str(product.id)))
        if qty > 0 and qty < 100:
            cart.remove(product)
            cart.add(product, price=product.price, quantity=qty)
    return redirect("pos:cart")
開發者ID:ektowett,項目名稱:shoppingcart,代碼行數:9,代碼來源:views.py

示例12: decrementar_quantidade

def decrementar_quantidade(request):
    produto_id = request.POST['produto']
    quantidade = request.POST['quantidade']
    carrinho = Cart(request.session)
    produto = Produto.objects.get(pk=produto_id)
    carrinho.set_quantity(produto, quantity=quantidade)
    template = loader.get_template('loja/carrinho.html')
    context = RequestContext(request)
    return HttpResponse(template.render(context))
開發者ID:pydawan,項目名稱:protetores_bucais,代碼行數:9,代碼來源:views.py

示例13: carrinho_adicionar

def carrinho_adicionar(request):
    if request.method == 'POST':
        carrinho = Cart(request.session)
        produto = Produto.objects.get(pk=request.POST.get('id'))
        carrinho.add(produto, price=produto.preco, quantity=request.POST.get('quantidade'))
        data = json.dumps({'itens': str(len(carrinho.items)), 'total': str(carrinho.total)})
        return HttpResponse(data, content_type='application/json')
    else:
        return HttpResponse('404')
開發者ID:pydawan,項目名稱:protetores_bucais,代碼行數:9,代碼來源:views.py

示例14: add_single

def add_single(request):
	cart = Cart(request.session)
	plato = Plato.objects.get(id=request.GET.get('product_id'))

	if cart.products:
		if plato.restaurante.id != cart.products[0].restaurante.id:
			cart.clear()		
	cart.add(plato, price=plato.precio)
	return platilla_cesta(request);
開發者ID:gamezinfantes,項目名稱:UFood,代碼行數:9,代碼來源:views.py

示例15: show

def show(request):
	cart = Cart(request.session)	
	if request.method == 'POST':
		print 'mpike mesa sto post'
		isbn = request.POST.get("book_isbn",'')
		quant = request.POST.get("book_new_quant",'')
		product = Book.objects.get(isbn=isbn)
		cart.set_quantity(product, quantity=quant)
	return render(request, 'shopping/show-cart.html')
開發者ID:NickLont,項目名稱:bookstore,代碼行數:9,代碼來源:views.py


注:本文中的carton.cart.Cart類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。