The rich cart displays any free gifts currently in the cart. These gifts may be any of the following:

The JSP that renders the cart items portion of the rich cart is located in store.war/cart/json/cartItems.jsp. This JSP makes two calls to the /atg/commerce/promotion/GiftwithPurchaseSelectionsDroplet. The first call is used when rendering gifts that are not placeholders (the first three cases in the list above). The second call is used when rendering gift placeholders.

To render gifts that are not placeholders, cartItems.jsp iterates through all the CommerceItem objects in the current cart, passing each CommerceItem to the GiftWithPurchaseSelectionsDroplet. The droplet determines if there is any free gift quantity within each CommerceItem by looking for a gift with purchase marker. Because a CommerceItem can contain a quantity greater than one, it is possible that a portion of the CommerceItem is free while the rest of it is not. For example, a CommerceItem may contain three Cowgirl Bags, with two of the bags qualifying as free gifts while the third bag is priced as a regular item.

Note: See the ATG Commerce Programming Guide for information about gift with purchase markers.

If GiftWithPurchaseSelectionsDroplet determines that any portion of the current CommerceItem is a gift, cartItems.jsp calculates the portion of the CommerceItem that is free. cartItems.jsp does this using the GiftWithPurchaseSelection bean that the GiftWithPurchaseSelectionsDroplet generates for the free portion of the item. This bean has properties that represent the quantity of the CommerceItem that:

  • Was automatically added to the cart (automaticQuantity)

  • Is the result of re-pricing items that already existed in the cart (targetedQuantity)

  • Was explicitly selected by the customer in the free gift picker (selectedQuantity)

Adding these quantities together results in a total gift quantity for this CommerceItem. Subtracting the total gift quantity from the CommerceItem’s total quantity provides the quantity of the CommerceItem that is not a gift.

Next, cartItems.jsp includes the cartItem.jsp page to render the non-gift portion of the CommerceItem on a line in the rich cart. For this include, the gift with purchase promotionID is passed in the excludeModelId parameter. Passing the promotionID in this way tells cartItem.jsp to not render any price information for items associated with the gift with purchase promotion. This avoids rendering a zero price on this line of the rich cart. (Price information is only rendered for items that are not free.)

The next call to the cartItem.jsp page renders the gift portion of the CommerceItem on another line in the rich cart. For this call, the isGift parameter is passed so that cartItem.jsp will render the price as FREE in the rich cart.

For an example of how the splitting of a CommerceItem into free and non-free items looks, consider the following illustration:

This illustration is described in the surrounding text.

To create the situation depicted in this illustration, the following happened:

  • The customer added the Suede Blazer to her cart, qualifying her for two free gifts from the Handbags & Wallets category.

  • The customer chose the Cowgirl Bag for both of her free gifts and, because she wants to give them as gifts to three friends, she added a third bag to her cart. This third bag is priced normally.

  • The rich cart shows two line items, one for the regularly priced Cowgirl Bag and a second for the two free Cowgirl Bags. The first line item considers only the price for the Cowgirl Bag that is not free. The second line item marks the Cowgirl Bag as FREE instead of rendering the zero price.

The final task cartItems.jsp must do is render any gift placeholders. To do this, cartItems.jsp calls the GiftWithPurchaseSelectionsDroplet again. This call passes the current order without a specific CommerceItem, so the GiftWithPurchaseSelectionsDroplet returns GiftWithPurchaseSelection beans for any gifts in the entire order. cartItems.jsp further refines what GiftWithPurchaseSelectionsDroplet returns by passing in the onlyOutputAvailableSelections parameter. This parameter tells the GiftWithPurchaseSelectionsDroplet to return only those GiftWithPurchaseSelection beans whose quantityAvailableForSelection is not zero. These are the beans for which gift placeholders need to be rendered. Each bean is then passed to the store.war/cart/json/giftPlaceholder.jsp page for rendering. This illustration shows what a gift placeholder looks like in the rich cart. Note that the two free gifts are rendered as one line in the rich cart (as opposed to the shopping cart, which renders a separate line for each free gift, as described in Gift with Purchase and the Shopping Cart).

This illustration is described in the preceding text.