Defining a Shopping Cart

This section describes how to use the Shopping Cart framework as a base to create a shopping cart specific to a Campus Solutions application. The section uses the delivered enrollment shopping cart to show an example of how this is done.

This section discusses how to:

  • Create application class.

  • Set up entity registry.

  • Generate code for application classes.

  • Configure shopping cart.

  • Generate a common XSD for the shopping carts.

Create feature-specific shopping cart application classes to customize the business logic specific to the Campus Solutions application. At this stage, create only the application classes inside the proper application package. Add the PeopleCode at a later step.

Typically, any shopping cart feature would include XXXShoppingCart & XXXShoppingCartItem classes where XXX points to the specific feature for which the shopping cart is created (for example, Course and Student Financials). These are the application class names that you associate with the corresponding entities on the Entity Registry page in the next step.

The XXXShoppingCart class extends the core ShoppingCart class and contains the implementation code for the purchase() method. The SCC_SC_CHECKOUT service operation uses the purchase() method and the SCC_SC_VALIDATE service operation uses the validateCart() method. The system has defined the purchase() method and validateCart() method as abstract in the ShoppingCart base class. The XXXShoppingCart class can also override any other class provided by the base class for providing customized implementation specific to the Campus Solutions application.

The XXXShoppingCartItem class must point to the record where the system stores the shopping cart items.

For example, for the enrollment shopping cart we created the following two classes (APIs):

  • CourseShoppingCart.

  • CourseShoppingCartItem.

The following diagram shows that we have included both the classes inside the SSR_COURSE application package. This package is specific to the Campus Solutions Student Records application. The CourseShoppingCartItem class points to the SSR_REGFORM record. The system stores the cart items (academic classes in the case of enrollment shopping cart) in the SSR_REGFORM record.

This example illustrates the fields and controls on the Example of how you can create the classes for a shopping cart. You can find definitions for the fields and controls later on this page.

Example of how you can create the classes for a shopping cart

Access the Entity Registry page (Set Up SACR > System Administration > Entity > Entity Registry).

The Shopping Cart framework uses the Entity Registry component for processing shopping cart requests specific to the Campus Solutions application. Use the Entity Registry component to define entity registries for each application-specific cart.

See Setting Up Entity Registry.

In the previous subsection (Creating Application Classes), we created two application classes: CourseShoppingCart and CourseShoppingCartItem. We now attach each of these classes to an entity. Access the Entity Registry component to create a parent and at least one child entity. Any entity structure for an application-specific shopping cart should include a parent class that extends the base ShoppingCart class. This parent class provides implementation for all of the service operations. The child class is needed because it points to the actual application-specific cart item table. If the application-specific feature has multiple child item tables, then you should create entities for all children and also define the parent-child relationship in the Entity Registry component.

Create the parent entity with the following configuration:

  • Specify the entity name as XXXShoppingCart.

    This is similar to how you named the application class in the previous subsection. XXX refers to the feature for which you are creating a shopping cart.

  • Select a value of Shopping Cart in the Entity Type field.

  • For the AppClass field, select the application class you created in the previous subsection for XXXShoppingCart.

  • For the Prod Record field, select the work record SCC_SHOPCRT_WRK because the entity has nothing to save.

This example shows the parent entity, named CourseShoppingCart, which we created for the enrollment shopping cart:

This example illustrates the fields and controls on the Configuration example of a parent entity (CourseShoppingCart). You can find definitions for the fields and controls later on this page.

Configuration example of a parent entity (CourseShoppingCart)

Create the child entity with the following configuration:

  • Specify the entity name as XXXShoppingCartItem.

    This is similar to how you named the application class in the previous subsection. XXX refers to the feature for which you are creating a shopping cart.

  • Select a value of Shopping Cart Item in the Entity Type field.

  • For the AppClass field, select the application class you created in the previous subsection for XXXShoppingCartItem.

  • For the Prod Record field, select the application-specific item table that holds the cart items.

This example shows the child entity, named CourseShoppingCartItem, which we created for the enrollment shopping cart:

This example illustrates the fields and controls on the Configuration example of a child entity (CourseShoppingCartItem). You can find definitions for the fields and controls later on this page.

Configuration example of a child entity (CourseShoppingCartItem)

Note: The record you enter in the Prod Record field for the child entity must contain the SCC_SHOPCRT_SBR (CommonSubRecord) sub record. That is, you must include SCC_SHOPCRT_SBR in the application-specific item table. This enables the common system data to be tracked by the Shopping Cart framework without any effort from the adopting feature. The SCC_SHOPCRT_SBR sub record contains the Shopping Cart framework's common fields that an adopting feature should include.

The following example shows how you should create the production record for the child entity:

This example illustrates the fields and controls on the Example of a production record for a child entity. You can find definitions for the fields and controls later on this page.

Example of a production record for a child entity

In the previous subsection (Setting Up Entity Registry), we created two entities and assigned the application classes to the entities. We now click the Generate Code button on the Entity Registry page to generate the code that can be pasted inside the PeopleCode of the application class.

To generate the code:

  1. Access the Entity Registry page for the XXXShoppingCart and the XXXShoppingCartItem entities.

  2. Click the Generate Code button.

  3. Select the desired options and generate the code.

You can paste the generated code directly inside the application classes. You can also use the generated code as a template to add more logic as needed.

To register the application-specific shopping cart, access the Shopping Cart Configuration page (Set Up SACR, System Administration, Utilities, Shopping Carts, Shopping Cart).

This example illustrates the fields and controls on the Shopping Cart Configuration page. You can find definitions for the fields and controls later on this page.

Shopping Cart Configuration page

Field or Control

Description

Owner ID

Because the Shopping Cart framework can be used by any Campus Solutions application, select the Campus Solutions application that owns the shopping cart you are creating.

Entity ID

Select the Entity ID of the parent entity that you created on the Entity Registry page.

On the Shopping Cart Configuration page, you attach the entity ID of an application-specific shopping cart to an application-specific shopping cart type. The shopping cart type represents the type of the application-specific shopping cart, and the entity ID represents the application-specific entity defined on the Entity Registry page.

Purpose of this configuration:

Because the Shopping Cart framework is generic, the service operation must know which application-specific shopping cart sent the request so that it can proceed with first building the appropriate entities that are specified on the Shopping Cart Configuration page and then start processing the request.

Each shopping cart request must contain a <SCC_SHOP_CART_TYPE> tag. The value of the tag indicates the shopping cart type that you have defined on the Shopping Cart Configuration page. Any shopping cart service operation upon receiving a request first reads the shopping cart type from the request. Once the service operation identifies the cart type, it then identifies the appropriate entities attached to this cart type from the Shopping Cart Configuration page to perform the application-specific shopping cart processing.

Example for how the framework uses SCC_SHOP_CART_TYPE:

The enrollment shopping cart involves two entities: CourseShoppingCart and CourseShoppingCartItem. We have defined these entities on the Entity Registry page with CourseShoppingCart as the parent entity and CourseShoppingCartItem as the child entity. The shopping cart configuration for the enrollment shopping cart would therefore look as shown in the preceding screen shot titled Shopping Cart Configuration page.

Note that the shopping cart is Course in the screen shot for the enrollment shopping cart. Therefore, for example, when the enrollment shopping cart sends a request to add an item (academic class) to the enrollment shopping cart, the request must include the shopping cart type Course. The following is an example of a request XML code to add an item to the enrollment shopping cart:

This example illustrates the fields and controls on the Sample SCC_SC_ADDITEM_REQ.xml from the Enrollment shopping cart. You can find definitions for the fields and controls later on this page.

Sample SCC_SC_ADDITEM_REQ.xml from the Enrollment shopping cart

Note that in the code example, the SCC_SHOP_CART_TYPE tag contains the COURSE value. The SCC_SC_ADDITEM service operation reads the cart type value of Course from the request. The operation then queries the Shopping Cart Configuration page to identify the entity appropriate for this cart type (which is CourseShoppingCart for this example) and then proceeds with building the entity hierarchy for processing the enrollment shopping cart request.

Suppose if the <SCC_SHOP_CART_TYPE> had a value of StudentFinance. In such a case, the service operation builds the StudentFinanceShopCart entity and uses this entity for processing the Student Financials shopping cart request to add an item.

Therefore, depending on the <SCC_SHOP_CART_TYPE> value (for example, Course or StudentFinance) with which you have registered the application-specific entities on the Shopping Cart Configuration page, the service operation handler code builds the appropriate entities and uses these entities for further processing.

The Shopping Cart framework uses a common schema that includes elements of all the entities that are defined in the shopping cart configuration table. The name of the common schema is SCC_ENTITY_SHOP_CART.xsd.

To generate the common schema for all the shopping carts:

  1. Access the Entity Registry page for any parent entity of a shopping cart (Set Up SACR > System Administration > Entity > Entity Registry).

  2. Click the Generate XSD button to generate the XSD.

  3. Use the PeopleTools Schema page to access SCC_ENTITY_SHOP_CART.xsd (PeopleTools > Integration Broker > Integration Setup > Messages > Schema).

  4. Paste the generated XSD into SCC_ENTITY_SHOP_CART.xsd.

For example, the enrollment shopping cart has two entities: CourseShoppingCart (parent) and CourseShoppingCartItem (child). Click the Generate XSD button on the Entity Registry page for the CourseShoppingCart entity. When you click this button, the system generates an XSD that contains elements of all the available shopping cart entities that you have defined on the Shopping Cart Configuration page.

Any shopping cart parent entity (for example, CourseShoppingCart) extends the ShoppingCart framework class. The ShoppingCart class overrides the base class generateXSD() method to generate a common XSD for all the available carts. You then need to replace the XSD in SCC_ENTITY_SHOP_CART.xsd with the XSD generated by clicking the Generate XSD button. Note that it is this common XSD that the system references in all the generic XSDs of the messages that are attached to the service operations.

Another example: We will use the message SCC_SC_ADDITEM_REQ.xsd that is attached to SCC_SC_ADDITEM service operation. Suppose you have used the Shopping Cart Configuration page to define two shopping carts. One is an enrollment shopping cart and another is Student Financials shopping cart.

You defined the entity registry setups for the enrollment and Student Financials shopping carts. The following is an example of the Entity Hierarchy Display page for the CourseShoppingCart entity:

This example illustrates the fields and controls on the Entity hierarchy for Enrollment shopping cart . You can find definitions for the fields and controls later on this page.

Entity hierarchy for Enrollment shopping cart

Note: We have registered CourseShoppingCart on the Shopping Cart Configuration page with Shopping Cart Type as COURSE.

The following is an example of the Entity Hierarchy Display page for the StudentFinanceShopCart entity:

This example illustrates the fields and controls on the Entity hierarchy for Student Finance shopping cart. You can find definitions for the fields and controls later on this page.

Entity hierarchy for Student Finance shopping cart

Note: Assume that you have registered StudentFinanceShopCart on the Shopping Cart Configuration page with Shopping Cart Type as StudentFinance.

Click the Generate XSD button for one of the parent entities, for example, CourseShoppingCart. Doing so generates an XSD that contains the elements from CourseShoppingCart entity hierarchy as well as from StudentFinanceShopCart entity hierarchy.

Replace the content of SCC_ENTITY_SHOP_CART.xsd with the generated XSD. To do so, select PeopleTools > Integration Broker > Integration Setup > Messages > Schema to access the SCC_ENTITY_SHOP_CART message. On the Schema page, paste the newly-generated XSD.

The following is a graphical representation of the SCC_ENTITY_SHOP_CART.xsd:

This example illustrates the fields and controls on the Example of a common schema for Enrollment and Student Financials shopping carts. You can find definitions for the fields and controls later on this page.

Example of a common schema for Enrollment and Student Financials shopping carts

Note that the XSD contains the Course Shopping Cart (COURSE_SHOP_CART) entity as well as the Student Financials Shopping Cart (SF_SHOP_CART) entity, each entity pointing to its appropriate items.

Note: When creating a new shopping cart, generating the XSD for the newly-created parent entity and then updating the SCC_ENTITY_SHOP_CART.xsd with this newly-created XSD has no impact on the existing shopping carts.

The following is the request XSD of generic SCC_SC_ADDITEM_REQ.xsd.

This example illustrates the fields and controls on the Example of a Schema page for SCC_SC_ADDITEM_REQ.xsd. You can find definitions for the fields and controls later on this page.

Example of a Schema page for SCC_SC_ADDITEM_REQ.xsd

Note that this SCC_SC_ADDITEM_REQ.xsd schema includes the SCC_ENTITY_SHOP_CART.xsd schema that you generated for the CourseShoppingCart entity.