Exemple #1
0
def display(request, cart=None, error_message='', default_view_tax=None):
    """Display the items in the cart."""

    if default_view_tax is None:
        default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')

    if not cart:
        cart = Cart.objects.from_request(request)

    if cart.numItems > 0:
        products = [item.product for item in cart.cartitem_set.all()]
        sale = find_best_auto_discount(products)
    else:
        sale = None

    satchmo_cart_view.send(cart,
                           cart=cart,
                           request=request)

    context = RequestContext(request, {
        'cart': cart,
        'error_message': error_message,
        'default_view_tax' : default_view_tax,
        'sale' : sale,
        })
    return render_to_response('shop/cart.html', context_instance=context)
Exemple #2
0
def display(request, cart=None, error_message='', default_view_tax=None):
    """Display the items in the cart."""

    if default_view_tax is None:
        default_view_tax = config_value('TAX', 'DEFAULT_VIEW_TAX')

    if not cart:
        cart = Cart.objects.from_request(request)

    if cart.numItems > 0:
        products = [item.product for item in cart.cartitem_set.all()]
        sale = find_best_auto_discount(products)
    else:
        sale = None

    satchmo_cart_view.send(cart,
                           cart=cart,
                           request=request)

    context = {
        'cart': cart,
        'error_message': error_message,
        'default_view_tax' : default_view_tax,
        'sale' : sale,
        }
    return render(request, 'shop/cart.html', context)
Exemple #3
0
 def get_context_data(self, **kwargs):
     context = super(DisplayView, self).get_context_data(**kwargs)
     if self.object.numItems > 0:
         products = [item.product for item in self.object.cartitem_set.all()]
         context['sale'] = find_best_auto_discount(products)
     context['error_message'] = self.get_error_message()
     context['default_view_tax'] = self.get_default_view_tax()
     satchmo_cart_view.send(self.object, cart=self.object, request=self.request)
     return context