Shopping Cart Service Operations

This section discusses the shopping cart service operations.

This service operation adds a single or multiple items to a user's shopping cart. The operation adds the items to the item table specific to the Campus Solutions application implementing the shopping cart.

The service operation first checks if the item, which the user wants to add, already exists in the cart. If the item already exists, the operation deletes the item from the cart and then adds the item as a new item to the cart. Therefore, a user interface can also use this operation to update an existing cart item.

Once the item is added to the cart, the service operation retrieves all the cart items for the user and sends them back in the response message.

Example: Suppose your institution has an enrollment shopping cart. A student can use this enrollment shopping cart to add the classes in which he or she wants to enroll. The enrollment shopping cart uses the SCC_SC_ADDITEM operation to add a class to the enrollment shopping cart item table.

Example when a shopping cart can use SCC_SC_ADDITEM to modify an existing item: Suppose a student wants to change an enrollment option. For example, the student wants to change the Units for an item that has already been added to the enrollment shopping cart. The student can add the same item with a changed value for Units. In this case, SCC_SC_ADDITEM deletes the existing item and adds it again with the new value for Units.

This service operation deletes all the items from the cart for a user. The operation deletes the items from the item table specific to the Campus Solutions application implementing the shopping cart.

Example: A student deletes all the classes that he or she added previously to the enrollment shopping cart. In such a case, the enrollment shopping cart uses the SCC_SC_CLEARCART operation to delete all the classes added by the student.

This service operation retrieves all the items added to the shopping cart for a user. The operation retrieves the items from the item table specific to the Campus Solutions application implementing the shopping cart.

Example: A student accesses the enrollment shopping cart to make additional changes. The shopping cart displays all the classes that the student had previously entered. In such a case, the enrollment shopping cart uses the SCC_SC_GETCART operation to retrieve all the classes that the user had previously added to the enrollment shopping cart.

This service operation retrieves a particular item from the shopping cart for a user, based on an index number. The index number is a numeric value that represents the position of an item in the cart.

A user interface can send the index number as a request parameter to this service operation. The service operation then uses the index number to retrieve the appropriate item from the cart. The operation first validates the index number and then retrieves the item only if it is a valid index number. If index number is not valid, the operation sends back an error message to the user interface stating that the index number is invalid.

For instance, if the index number in the request message passed to this service operation is greater than the number of items in the cart, then an error message is sent back to the user interface.

Example: A student wants to review details of a specific class that he or she had previously added to the enrollment shopping cart. To review the class details, the student clicks the class number link. In such a case, the enrollment shopping cart feature uses the SCC_SC_GETITEM operation to retrieve the details of the particular class.

The user interface could initially use the SCC_SC_GETCART operation to display only the basic information (for example, Class Nbr) for all the cart items (academic classes). To get more information about the classes, the student can click any class number. When the student clicks a class number, the user interface can use the SCC_SC_GETITEM operation to retrieve and display the complete information for that item.

This service operation removes a single or multiple items from the shopping cart for a user.

Once the item is removed from the cart, the service operation retrieves all the remaining cart items for the user and sends them back in the response message. In other words, the response message contains the remaining cart items. However, the response message is blank if the cart is empty after the removal of an item.

Example: A student deletes one or more classes from the enrollment shopping cart. In such a case, the enrollment shopping cart uses the SCC_SC_REMOVEITEM operation to remove a class from the enrollment shopping cart.

This service operation saves a single or multiple items to the cart for a user. The service operation first deletes all the items in the cart for the user and then adds the new items to the cart.

Once the items are saved to the cart, the service operation retrieves all the cart items for the user and sends them back in the response message. In other words, if an error does not occur, the response message contains all the cart items.

There is a difference between SCC_SC_ADDITEM and SCC_SC_SAVECART. If an item already exists in the cart and the user adds it again, SCC_SC_ADDITEM first removes the item from the table and then adds the item again. SCC_SC_SAVECART first deletes all the existing cart items and then adds all the items that are in the request message.

Example: A student uses the enrollment shopping cart to clear all the existing cart items and then adds the new classes in which he or she wants to enroll. After adding the new classes, the student clicks the save link. In such a case, the enrollment shopping cart uses the SCC_SC_SAVECART operation to first remove the existing cart items and then add the new classes to the enrollment shopping cart item table.

This service operation validates the items in the cart for a user. A user interface can use this operation to validate a single or multiple items in the cart. The validation results of all the items indicating a success or failure is sent back in the response message.

Example: A student adds three classes to the enrollment shopping cart. Before the student checks out these classes, the user interface validates the class choices. After validation, the user interface determines that the student is eligible to enroll only in one specific class. The enrollment shopping cart uses the SCC_SC_VALIDATE operation to perform such a pre enrollment validation.

The SCC_SC_VALIDATE operation enables a user interface to first validate the classes that exist in the enrollment shopping cart, before the user interface invokes the SCC_SC_CHECKOUT operation to enroll the student in the classes. On successful validation of the class, the SCC_SC_VALIDATE operation sends back a response message: OK to Add. If any error occurs during validation, the response message contains the appropriate error message.

Note: The validation code should be specific to the shopping cart feature that you are implementing. Therefore, whoever implements a shopping cart needs to create feature-specific validation logic as part of the adopting feature's application class. In the preceding example, the enrollment validation logic is not part of the Shopping Cart framework. We have incorporated this enrollment validation logic in the CourseShoppingCart application class, validateCart method (part of SSR_COURSE application package). This class and method are specific to the enrollment shopping cart. The validateCart method executes when the enrollment shopping cart user interface invokes the SCC_SC_VALIDATE service operation.

This service operation checks out the items that the user has added to the cart. A user interface can use this operation for a single or multiple cart items. The service operation sends back a response message indicating success or failure.

Example: After adding all the desired classes to the enrollment shopping cart, the student confirms his or her choices by checking out the items. The enrollment shopping cart uses the SCC_SC_CHECKOUT operation to check out (enroll) the classes added to the enrollment shopping cart. On successful enrollment, the response message returns the following message to the student: The class has been added to your schedule. If any error occurs during enrollment, the response message contains the appropriate error message.

Note: The checkout code should be specific to the shopping cart feature that you are implementing. Therefore, whoever implements a shopping cart needs to create feature-specific checkout logic as part of the adopting feature's application class. In the preceding example, the enrollment checkout logic is not part of the Shopping Cart framework. We have incorporated this enrollment checkout logic in the CourseShoppingCart application class, purchase method (part of SSR_COURSE application package). This class and method are specific to the enrollment shopping cart. The purchase method executes when the enrollment shopping cart user interface invokes the SCC_SC_CHECKOUT service operation.

This section discusses the classes that you can use for implementing a shopping cart.

The Shopping Cart framework supports a set of Application Programming Interfaces (APIs) that comprise the functionality common to all shopping carts. These APIs are application classes. These APIs exist in the SCC_COMMON application package as shown in the following diagram:

This example illustrates the fields and controls on the Shopping cart APIs in the SCC_COMMON application package. You can find definitions for the fields and controls later on this page.

Shopping cart APIs in the SCC_COMMON application package

The following diagram shows the delivered enrollment shopping cart implementation. This implementation uses the Shopping Cart framework, and the delivered CourseShoppingCart and CourseShoppingCartItem entities.

This example illustrates the fields and controls on the Example of a delivered shopping cart implementation. You can find definitions for the fields and controls later on this page.

Example of a delivered shopping cart implementation

The following table describes the delivered classes that are shown in the preceding diagram.

Classes/Tables

Description

CartConfigurationTable

This table contains details about the available carts and the implementation classes that support these carts. The database table for CartConfigurationTable is SCC_SHOPCART.

ShoppingCartHandler

This class is the only web service handler that the system needs to drive the shopping cart. To access the Shopping Cart framework, all the web services will use this web service handler. This class is part of the SCC_COMMON application package.

ShoppingCartManager

The generic handler class uses the ShoppingCartManager core class to create and return the appropriate entity specific to the Campus Solutions application. Additionally, a user interface can use the ShoppingCartManager class to retrieve the items from a cart specific to the Campus Solutions application. This class is part of the SCC_COMMON application package.

ShoppingCart

This core class contains the common functions available to all carts. Note that we have modeled this class as a WorkEntity and therefore, this class does not require real database persistence (table). The feature, adopting the Shopping Cart framework, must extend this class. This class is part of the SCC_COMMON package.

Note: The purchase() & validateCart() methods, which are used by the SCC_SC_CHECKOUT and SCC_SC_VALIDATE service operations respectively, are defined as abstract in the ShoppingCart class. Therefore, you must provide the implementation code in the adopting class.

ShoppingCartItem

The adopting feature must extend this core class to hold any items in the cart. Note that we have modeled this class as a BasicEntity having a real underlying database table that contains the cart items. This class is part of the SCC_COMMON package.

BasicEntity

You must create the adopting feature entity with an entity type set to ShoppingCartItem. We have defined this type with the base application class called SCC:COMMON:SHOPCART:ShoppingCartItem. This base class extends the SCC_COMMON:ENTITY:BasicEntity application class. Therefore, when creating a shopping cart, you create an application class that extends the BasicEntity class. The BasicEntity class is part of the SCC_COMMON package.

CommonSubRecord

This is a table that contains the Shopping Cart framework's common fields that any adopting feature's item table should include. This enables the cart to track the common system data, with no effort from the adopting feature. The database table for CommonSubRecord is SCC_SHOPCRT_SBR.

CourseShoppingCart

This class pertains to the implementation for enrollment shopping cart. This class is part of the SSR_COURSE application package.

The CourseShoppingCart class extends the core ShoppingCart class. The CourseShoppingCart class contains the implementation for the purchase() & validateCart() methods that are abstract in the core ShoppingCart class.

Note that the CourseShoppingCart class is attached to a work entity (SCC_SHOPCRT_WRK) because the class has nothing to save and therefore does not require a real database table.

CourseShoppingCartItem

This class pertains to the implementation for enrollment shopping cart (which is specific to the Student Records Campus Solutions application). This class is part of the SSR_COURSE application package. This class handles the storage of the enrollment shopping cart items (academic classes). The CourseShoppingCartItem entity is attached to the enrollment shopping cart item table (SSR_REGFORM) that holds the enrollment shopping cart items (academic classes).

WorkEntity

This class is extended by entities that have nothing to save, meaning they do not have a real underlying database table. The core ShoppingCart class extends WorkEntity. The WorkEntity class is part of the SCC_COMMON package.