Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Checkout and Order Processing: the User Si...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
RUBY-ON-RAILS

Checkout and Order Processing: the User Side
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2010-07-22

    Table of Contents:
  • Checkout and Order Processing: the User Side
  • Calculating Shipping Costs and Taxes
  • Calculating Taxes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Checkout and Order Processing: the User Side


    (Page 1 of 3 )

    In this conclusion to a five-part article series on adding checkout and order processing capabilities to an ecommerce website with Ruby on Rails, you will learn how to add the close order user story, which involves adding the ability to calculate shipping costs and other details. This article is excerpted from chapter nine of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

    Implementing the Close Order User Story

    The Close Order user story is the last one we’ll implement in this sprint. It is used by George (after he has shipped the order) to set the order status to closed. The user story requires that we change thecloseaction inorder_controller.rbas follows: 

      def close
        order = Order.find(params[:id])
        order.close
       
    flash[:notice] = "Order #{order.id} has been closed"
        redirect_to :action => 'index', :id => 'closed'
      end

    The code finds the specified order and calls theclosemethod on theOrdermodel (app/models/order.rb):

      def close
       
    self.status = 'closed'
       
    save!
      end

    This method sets the status toclosedand saves the order. After this, the action sets a flash message and redirects to the Closed section of the view orders page.

    Test the Close Order user story by closing an order. View the details of a processed order (click the View button for the transaction on the view orders page), and you should see the Close Order button at the bottom of the order details page, as shown in Figure 9-16.

    Click the Close Order button, and you are redirected to the page shown in Figure 9-17.

    This ends our implementation of the checkout and order-processing functionality. However, you still need to take into account two other items when processing orders: shipping costs and taxes. We’ll take a brief look at those calculations next.


    Figure 9-16.  The order details page displaying the Close Order button


    Figure 9-17.  The view orders page displaying a message after closing an order

    More Ruby-on-Rails Articles
    More By Apress Publishing


     

    RUBY-ON-RAILS ARTICLES

    - Application Deployment with Capistrano
    - Deploying an Application to the Server
    - Secure Application Deployment with Ruby on R...
    - Installing the Database for Application Depl...
    - Application Deployment
    - Recording Acceptance Tests
    - Commands for Acceptance Testing
    - Acceptance Testing
    - Checkout and Order Processing: the User Side
    - Checkout and Order Processing: the Administr...
    - Online Order Processing: Using PayPal
    - Order and Payment Handling for an Ecommerce ...
    - Checkout and Order Processing for an Ecommer...
    - Getting Text and Currency Working for Multip...
    - Translating a Site for Multiple Language Sup...





     


     


    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek