def show_checkout(request, template_name='checkout/checkout.html'):
    """ checkout form page to collect user shipping and billing information """
    if cart.is_empty(request):
        cart_url = urlresolvers.reverse('show_cart')
        return HttpResponseRedirect(cart_url)

    if request.method == 'POST':
        postdata = request.POST.copy()
        form = CheckoutForm(postdata)
        if form.is_valid():
            response = checkout.process(request)
            order_number = response.get('order_number',0)
            error_message = response.get('message','')
            if order_number:
                request.session['order_number'] = order_number
                receipt_url = urlresolvers.reverse('checkout_receipt')
                return HttpResponseRedirect(receipt_url)
        else:
            error_message = u'Some required fields were not filled in. Please review your form to make sure all required information is present.'
    else:
            if request.user.is_authenticated():
                 user_profile = profile.retrieve(request)
                 form = CheckoutForm(instance=user_profile)
            else:
                 form = CheckoutForm()

    page_title = 'Checkout'
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Exemple #2
0
def show_checkout(request, template_name='checkout/checkout.html'):
    """ checkout form page to collect user shipping and billing information """
    if cart.is_empty(request):
        cart_url = urlresolvers.reverse('show_cart')
        return HttpResponseRedirect(cart_url)

    if request.method == 'POST':
        postdata = request.POST.copy()
        form = CheckoutForm(postdata)
        if form.is_valid():
            response = checkout.process(request)
            order_number = response.get('order_number', 0)
            error_message = response.get('message', '')
            if order_number:
                request.session['order_number'] = order_number
                receipt_url = urlresolvers.reverse('checkout_receipt')
                return HttpResponseRedirect(receipt_url)
        else:
            error_message = u'Correct the errors below'
    else:
        if request.user.is_authenticated():
            user_profile = profile.retrieve(request)
            form = CheckoutForm(instance=user_profile)
        else:
            form = CheckoutForm()

    page_title = 'Checkout'
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Exemple #3
0
def show_checkout(request, template_name='checkout/checkout.html'):
    if cart.is_empty(request):
        cart_url = urlresolvers.reverse('show_cart')
        return HttpResponseRedirect(cart_url)
    if request.method == 'POST':
        postdata = request.POST.copy()
        form = CheckoutForm(postdata)
        if form.is_valid():
            response = checkout.process(request)
            order_number = response.get('order_number', 0)
            error_message = response.get('message', '')
            if order_number:
                request.session['order_number'] = order_number
                receipt_url = urlresolvers.reverse('checkout_receipt')
                return HttpResponseRedirect(receipt_url)
        else:
            error_message = 'Correct the errors below'
    else:
        if request.user.is_authenticated():
            from ecomstore.accounts import profile
            user_profile = profile.retrieve(request)
            form = CheckoutForm(instance=user_profile)
        else:
            form = CheckoutForm()
    page_title = 'Checkout'
    return render_to_response(template_name, locals(),
                              context_instance=RequestContext(request))
Exemple #4
0
def show_checkout(request, template_name='checkout/checkout.html'):
    c = {}
    c.update(csrf(request))
    if cart.is_empty(request):
        cart_url = urlresolvers.reverse('show_cart')
        return HttpResponseRedirect(cart_url)
    if request.method == 'POST':
        postdata = request.POST.copy()
        form = CheckoutForm(postdata)
        if form.is_valid():
            #process the credit card with the data that's posted to the server - billing information
            response = checkout.process(request)
            order_number = response.get('order_number', 0)
            print 'this is the order number: ' + str(order_number)
            error_message = response.get('message', '')
            if order_number:
                request.session['order_number'] = order_number
                receipt_url = urlresolvers.reverse('checkout_receipt')
                print request.session['order_number']
                return HttpResponseRedirect(receipt_url)
        else:
            error_message = 'Correct the errors below'

    else:
        if request.user.is_authenticated():
            user_profile = profile.retrieve(request)
            form = CheckoutForm(instance=user_profile)
        else:
            form = CheckoutForm()

    page_title = 'Checkout'
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Exemple #5
0
def show_checkout(request, template_name='checkout/checkout.html'):
    c = {}
    c.update(csrf(request))
    if cart.is_empty(request):
        cart_url = urlresolvers.reverse('show_cart')
        return HttpResponseRedirect(cart_url)
    if request.method == 'POST':
        postdata = request.POST.copy()
        form = CheckoutForm(postdata)
        if form.is_valid():
            #process the credit card with the data that's posted to the server - billing information
            response = checkout.process(request)
            order_number = response.get('order_number',0)
            print 'this is the order number: ' + str(order_number)
            error_message = response.get('message','')
            if order_number:
                request.session['order_number'] = order_number
                receipt_url = urlresolvers.reverse('checkout_receipt')
                print request.session['order_number']
                return HttpResponseRedirect(receipt_url)
        else:
            error_message='Correct the errors below'

    else:
        if request.user.is_authenticated():
            user_profile = profile.retrieve(request)
            form = CheckoutForm(instance=user_profile)
        else:
            form = CheckoutForm()
                
    page_title = 'Checkout'
    return render_to_response(template_name, locals(), context_instance= RequestContext(request))
def order_info(request, template_name="registration/order_info.html"):
    if request.method == "POST":
        postdata = request.POST.copy()
        form = UserProfileForm(postdata)
        if form.is_valid():
            profile.set(request)
            url = urlresolvers.reverse("my_account")
            return HttpResponseRedirect(url)
    else:
        user_profile = profile.retrieve(request)
        form = UserProfileForm(instance=user_profile)
    page_title = "Edit Order Information"
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
def order_info(request, template_name="registration/order_info.html"):
       if request.method == 'POST':
                postdata = request.POST.copy()
                form = UserProfileForm(postdata)
                if form.is_valid():
                        profile.set(request)
                        url = urlresolvers.reverse('my_account')
                        return HttpResponseRedirect(url)
       else:
         user_profile = profile.retrieve(request)
         form = UserProfileForm(instance=user_profile)
       page_title = 'Edit Order Information'
       return render_to_response(template_name, locals(),context_instance=RequestContext(request))
Exemple #8
0
def order_info(request, template_name="registration/order_info.html"):
    """ page containing a form that allows a customer to edit their billing and shipping information that
    will be displayed in the order form next time they are logged in and go to check out """
    if request.method == 'POST':
        postdata = request.POST.copy()
        form = UserProfileForm(postdata)
        if form.is_valid():
            profile.set(request)
            url = urlresolvers.reverse('my_account')
            return HttpResponseRedirect(url)
    else:
        user_profile = profile.retrieve(request)
        form = UserProfileForm(instance=user_profile)
    page_title = 'Edit Order Information'
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
Exemple #9
0
def order_info(request, template_name="registration/order_info.html"):
    """ page containing a form that allows a customer to edit their billing and shipping information that
    will be displayed in the order form next time they are logged in and go to check out """
    if request.method == 'POST':
        postdata = request.POST.copy()
        form = UserProfileForm(postdata)
        if form.is_valid():
            profile.set(request)
            url = urlresolvers.reverse('my_account')
            return HttpResponseRedirect(url)
    else:
        user_profile = profile.retrieve(request)
        form = UserProfileForm(instance=user_profile)
    page_title = 'Edit Order Information'
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))