当前位置: 首页>>代码示例>>Python>>正文


Python Cart.add方法代码示例

本文整理汇总了Python中carton.cart.Cart.add方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.add方法的具体用法?Python Cart.add怎么用?Python Cart.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在carton.cart.Cart的用法示例。


在下文中一共展示了Cart.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:9,代码来源:views.py

示例2: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:10,代码来源:views.py

示例3: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:10,代码来源:views.py

示例4: update_cart

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:11,代码来源:views.py

示例5: carrinho_adicionar

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:11,代码来源:views.py

示例6: add_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
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,代码行数:11,代码来源:views.py

示例7: add_product

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add_product(request, product_id):
    cart = Cart(request.session)
    product = Product.objects.get(pk=product_id)
    cart.add(product, price=product.price_ukr())

    result = {'products_in_cart': len(cart.items),
              'cart_total_sum': int(cart.total)}

    json_response = json.dumps(result)
    return HttpResponse(json_response, content_type="application/json")
开发者ID:Riliam,项目名称:test-shop,代码行数:12,代码来源:views.py

示例8: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add(request):
    cart = Cart(request.session)
    product = Product.objects.get(id=request.POST.get('id'))
    cart.add(product, price=product.price, quantity=request.POST.get('qty'))
    recent_product = dict(name=product.productName, image=product.image.url, price=product.price, total=cart.total,
                          items=cart.count)
    return HttpResponse(
        json.dumps(recent_product, use_decimal=True),
        content_type="application/json"
    )
开发者ID:saifulazad,项目名称:Delijango,代码行数:12,代码来源:views.py

示例9: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add(request, product_id):
    cart = Cart(request.session)
    if Item2.objects.filter(product_id=product_id):
        product = Item2.objects.get(product_id=product_id)
    elif Item3.objects.filter(product_id=product_id):
        product = Item3.objects.get(product_id=product_id)
    else:
        product = Item4.objects.get(product_id=product_id)
    
    cart.add(product, price=product.price)
    return HttpResponseRedirect('/tohfa/show')
开发者ID:ritz1302,项目名称:giftwebsite,代码行数:13,代码来源:views.py

示例10: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add(request):
	"""
	向购物车内增加商品
	"""
	print request.GET
	print request.POST

	cart = Cart(request.session)
	product = Product.objects.get(id=request.GET['id'])
	quantity = request.POST['quantity']
	cart.add(product, price=product.price, quantity=quantity)
	return HttpResponseRedirect('/cart/')
开发者ID:NirvanaStar,项目名称:woodsam,代码行数:14,代码来源:views.py

示例11: post

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
    def post(self, request):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        cart = Cart(request.session)
        product = get_object_or_404(Product, id=serializer.data['product_id'])
        cart.add(product, price=product.price)

        response_data = {
            'detail': 'Product was added to cart.'
        }
        response_status = status.HTTP_201_CREATED

        return Response(response_data, status=response_status)
开发者ID:scentrade,项目名称:website,代码行数:16,代码来源:views.py

示例12: add_to_cart

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add_to_cart(request, slug):
    if request.is_ajax():
        cart = Cart(request.session)
        product = get_object_or_404(Product, slug=slug)
        cart.add(product, price=product.price)
        return render_to_response('mcat_order/cart.html',
                                   {'product' : product},
                                   context_instance=RequestContext(request),
                                   content_type="application/xhtml+xml"
                                   )
    else:
        if settings.DEBUG:
            print("Not ajax request")
        raise Http404
开发者ID:synw,项目名称:django-mcat-order,代码行数:16,代码来源:views.py

示例13: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add(request):
	cart = Cart(request.session)
	product = Product.objects.get(id=request.GET.get('id'))
	try:
		product_stock = ProductStock.objects.get(product=product)
	except ObjectDoesNotExist:
		product_stock = None
	####ir buscar preco correcto
	cart.add(product, price=2)

	html = new_cart_html(request,0)
	cart_contents_qty = cart_contents_payload(request)
	payload = update_cart_status_and_prepare_payload(request, html, cart_contents_qty, True)

	return HttpResponse(json.dumps(payload), content_type="application/json")
开发者ID:vlameiras,项目名称:cdkeyswholesale,代码行数:17,代码来源:views.py

示例14: inventory

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def inventory(request):
    if request.method == 'GET':
        i = Item.objects.all()
        items = []
        for item in i:
            print item.name, item.description
            items.append(item)
        return HttpResponse(render_template(request, 'SecuCart/inventory.html', { 'items': items }))

    elif request.method == 'POST':
        print 'item_number:', request.POST.get('item_number')
        for i in request.POST:
            if i != 'item_number':
                item = Item.objects.get(name=i)
                print 'item:', i, item.name, item.quantity, item.price
                item.quantity = item.quantity - int(request.POST.get('item_number'))
                item.save()
                cart = Cart(request.session)
                cart.add(item, price=1.0, quantity=request.POST.get('item_number'))           
                return HttpResponse(render_template(request, 'SecuCart/shopping_cart.html', {}))
开发者ID:overdrivemachines,项目名称:SecuCart,代码行数:22,代码来源:views.py

示例15: add

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import add [as 别名]
def add(request, product_id):

    product = Product.objects.get(id=product_id)
    if request.method == "POST":
        cart = Cart(request.session)
        form = CartItemForm(request.POST or None)
        if form.is_valid():
            item = form.save()
            item.final_cost = item.calculateFinalCost()
            c = item.final_cost
            print "Final "+str(item.final_cost)
            if item.rounded:
                if product.rounded_cost is None:
                    item.final_cost = c + product.category.rounded_cost
                else:
                    item.final_cost = c + product.rounded_cost
            cart.add(item, price=item.final_cost)
            return HttpResponseRedirect("/shopping/cart/")
        else:
            print form.errors
    else:
        form = CartItemForm(initial={'id':product_id})
    token = {}
    token['form'] = form
    token['quantities'] = product.quantities.all
    token['colors'] = product.colors.all
    token['finishes'] = product.finishes.all
    token['product'] = product
    if product.category.rounded and product.rounded:
        token['can_be_round'] = True
        token['rounded_cost'] = product.rounded_cost
        if product.rounded_cost is None:
            token['rounded_cost'] = product.category.rounded_cost
    else:
        token['can_be_round'] = False

    token.update(csrf(request))
    return render_to_response('tinbox/order.html', token)
开发者ID:ehorvat,项目名称:tinbox-webapp,代码行数:40,代码来源:views.py


注:本文中的carton.cart.Cart.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。