def show_order(request, venue_id, template_name="checkout/show_order.html"):
    postdata = request.POST.copy()
    postdata.__setitem__('venue', venue_id)
    success=True
    form_message='Overview of pending, accepted, and processed orders.'
    form_title='My Orders'

    if postdata['submit'] == 'order_accepted':
        form_message='Order accepted by merchant.'
        form_title='Order Accepted'
        if cart.get_cart_items2_1(request, venue_id):
            response = checkout.merchant_order_accepted(request, venue_id)
        if cart.get_cart_items2_2(request, venue_id):
            response = checkout.merchant_order_finalized(request, venue_id)
        if cart.get_cart_items2_3(request, venue_id):
            response = checkout.merchant_order_paid(request, venue_id)
        skip_refresh = False

    if postdata['submit'] == 'cash':
        request.session['billing_name'] = request.POST.get('billing_name')
        request.session['email'] = request.POST.get('email')
        request.session['phone'] = request.POST.get('phone')
        request.session['payment_method'] = request.POST.get('cash')

        form = CheckoutFormCash(postdata)
        if form.is_valid():
            form_message='Order sent.'
            form_title='Order Sent'
            response = checkout.process(request, venue_id)
            order_number = response.get('order_number',0)
            error_message = response.get('message','')
            skip_refresh = False
            if order_number:
                request.session['order_number'] = order_number
        else:
            form_message='Error: incomplete info.'
            form_title='Info Error'
            success=False
            ferrors=form.errors
            skip_refresh = True
    if postdata['submit'] == 'Remove':
        cart.remove_from_cart(request, venue_id)
        form_message='Order cancelled. Thank you for shopping'
        form_title='Order Cancelled'
        skip_refresh = False
    if postdata['submit'] == 'Update':
        cart.update_cart(request, venue_id)
        form_message='Order updated.'
        form_title='Order Updated'
        skip_refresh = False
    if postdata['submit'] == 'New':
        skip_refresh = True
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
def create_order_cash(request, venue_id):
    order = Order()
    postdata = request.POST.copy()
    postdata.__setitem__('venue', venue_id)

    postdata.__setitem__('billing_name', request.session['billing_name'])
    postdata.__setitem__('email', request.session['email'])
    postdata.__setitem__('phone', request.session['phone'])

    checkout_form = CheckoutFormCash(postdata, instance=order)
    if checkout_form.is_valid():
        order = checkout_form.save(commit=False)
        
        order.billing_zip = '10000'
        order.transaction_id = '0'
        order.ip_address = request.META.get('REMOTE_ADDR')
        order.user = None
        if request.user.is_authenticated():
            order.user = request.user
        order.status = Order.SUBMITTED
        order.save()
        
        if order.pk:
            cart_items = cart.get_cart_items2_3(request, venue_id)
            for ci in cart_items:
                oi = OrderItem()
                oi.order = order
                oi.quantity = ci.quantity
                oi.price = ci.price  # now using @property
                oi.product = ci.product
                oi.save()
            # all set, clear the cart
            cart.empty_cart3(request, venue_id)
            """
            # save profile info for future orders
            if request.user.is_authenticated():
                from speeqeweb.accounts import profile
                profile.set(request)
            """
        
        ferror = 1
    else:
        ferror = checkout_form.errors.as_ul()

    return ferror