Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian". upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian". upgrade now! [56] (what's this?)
Hotfix release available: 2024-02-06b "Kaos". upgrade now! [55.2] (what's this?)
Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
Hotfix release available: 2023-04-04b "Jack Jackrum". upgrade now! [54.2] (what's this?)
Hotfix release available: 2023-04-04a "Jack Jackrum". upgrade now! [54.1] (what's this?)
New release available: 2023-04-04 "Jack Jackrum". upgrade now! [54] (what's this?)
Hotfix release available: 2022-07-31b "Igor". upgrade now! [53.1] (what's this?)
Hotfix release available: 2022-07-31a "Igor". upgrade now! [53] (what's this?)
New release available: 2022-07-31 "Igor". upgrade now! [52.2] (what's this?)
New release candidate 2 available: rc2022-06-26 "Igor". upgrade now! [52.1] (what's this?)
New release candidate available: 2022-06-26 "Igor". upgrade now! [52] (what's this?)
Hotfix release available: 2020-07-29a "Hogfather". upgrade now! [51.4] (what's this?)
New release available: 2020-07-29 "Hogfather". upgrade now! [51.3] (what's this?)
New release candidate 3 available: 2020-06-09 "Hogfather". upgrade now! [51.2] (what's this?)
New release candidate 2 available: 2020-06-01 "Hogfather". upgrade now! [51.1] (what's this?)
New release candidate available: 2020-06-01 "Hogfather". upgrade now! [51] (what's this?)
Hotfix release available: 2018-04-22c "Greebo". upgrade now! [50.3] (what's this?)
Hotfix release available: 2018-04-22b "Greebo". upgrade now! [50.2] (what's this?)
cart_and_order_processing

Cart and Order Processing

Requirement

  • The users should be able to enroll themselves for paid courses by purchasing them and making the payment through paypal or trust commerce gateways.
  • To enable this, we should have a shopping cart functionality and the orders should be integrated with the payment processing that is already available.

Implementation

Shopping Cart

The cart is maintained per session. session[:cart_id] will have the id of the cart object in that session.

All the paid courses have an add_to_cart link, clicking on which a request is sent to carts_controller create action which adds the course to cart.

 add_to_cart_link(item, link_text) 

Adding course to cart will insert entries in cart_items table. Duplicate courses are not added to cart.

All the courses in cart preview will have a remove_from_cart link, clicking on which a request is sent to carts_controller destroy action which removes the course from cart.

 remove_from_cart_link(item, link_text) 

Note - Right now, only courses can be purchased. So, cart_items will save course_id. This can be made polymorphic if we need to purchase more types.

Order Processing

All the orders are processed in orders_controller. orders table saves the billing information and cart id where as the payment information is saved in payments table. Each payment belongs to an order.

Payment Options Available

The buyer can pay with one of the following ways -

  • Credit card (In this case the seller account can be either paypal account/trustcommerce account. This is already implemented as a part of payment integration).
  • Pay pal account (In this case the seller should have a paypal express account. If we need this option we should only show it to the items of a seller who has registered with paypal express account. This requires the order processing flow to be modified so that the buyer is redirected to paypal and then back to our app. We also need to add one more gateway to existing gateways mentioned in the payment integration. This is not yet implemented).

Table Design

Table name - cart

This groups all cart items added in a single session.

Column_name type Description
id integer primary key
created_at date_time created date
updated_at date_timeupdated date

Table name - cart_items

Column_name type Description
id integer primary key
course_id integer foreign key to the courses table. Course which is added to the cart
cart_id integer foreign key to the carts table. Cart for the current session
price float The price of the course.
created_at date_time created date
updated_at date_timeupdated date

Table name - orders

Column_name type Description
id integer primary key
user_id integer foreign key to the users table. User who has placed this order
cart_id integer foreign key to the carts table. Cart whose items are ordered
account_name text
country text
address_1 text
address_2 text
town text
state text
zip text
phone_number text
created_at date_time created date
updated_at date_timeupdated date

Note :

Based on the way we are going to handle the tax , the tables carts and orders might need to save the tax information.

cart_and_order_processing.txt · Last modified: 2018/08/31 16:16 (external edit)