Shopping Cart

Important

This content is archived and is not being updated. For the latest documentation, see Microsoft Dynamics 365 product documentation. For the latest release plans, see Dynamics 365 and Microsoft Power Platform release plans.

Applies To: Microsoft Dynamics AX 2012 R3

The shopping cart control in the Retail in Microsoft Dynamics AX 2012 R3 online sample stores supports the collection and display of the items that a customer has selected to buy. A copy of the shopping cart is created when the customer begins the checkout process. The mini shopping cart icon displays the number of items in the shopping cart at the top of most of the store pages and optionally displays a list of items and prices as well as buttons that enable the user to view the full cart contents and start checking out.

When an authenticated customer clicks the Add to cart button for any product, a shopping cart is created in the channel database or the existing cart for the customer is retrieved. For more information about the channel database, see Architecture of the Microsoft Dynamics AX Retail online store.

For an anonymous user, a temporary shopping cart is created. For more information about anonymous users and authentication, see Authenticating users in Retail online sample stores.

From the shopping cart page, customers can do the following:

  • View the items they have selected to buy.

  • Add items, change quantities or remove items from the cart.

The shopping cart control also supports checkout actions when users purchase items.

Shopping Cart

Source code for the shopping cart pages is found in the Storefront.sln solution. This solution is available in the following folder after you install the Retail SDK:

\Retail SDK\Online Channel\Storefront

All shopping cart operations use AJAX-enabled Windows Communication Foundation (WCF) services are used for all shopping cart operations. Shopping cart entities are mapped from the channel database to the controllers for store pages. The data is converted to the storefront view model representation for use by client-side scripts. Web controls, the ShoppingCart web part, and Cascading Style Sheets (CSS) support the page display.

Dn741462.collapse_all(en-us,AX.60).gifData elements

Shopping cart data is not stored in the Microsoft Dynamics AX 2012 database. The shopping cart entity maintains the following data in the channel database:

  • Shopping cart identity: name and ID number

  • Last modified date and time

  • Collection of items in the cart

    • Item line ID

    • Product ID

    • Quantity

    • Product URL

    • Product image URL

    • Color

    • Size

    • Style

    • Configuration

    • Kit components

    • Price

  • Collection of promotions in the cart

Dn741462.collapse_all(en-us,AX.60).gifServices

In the Storefront.sln solution, the SharePoint.Web.Services project contains the ISAPI\shoppingCartSvc which contains the source code for shopping cart operations exposed as AJAX-enabled WCF services. The following table lists the classes that support the services.

Name

Description

Link to documentation

\ObjectModel\ ShoppingCartController.cs

The controller consists of functions which are used by the shopping cart services. These functions make calls to the server to get shopping cart data from the channel database. The functions include: GetShoppingCart, AddItems, RemoveItems, UpdateItems, ApplyPromotion.

ShoppingCartController

\ObjectModel\ ShoppingCartMapper.cs

The ShoppingCartMapper class manages the mappings between the Shopping Cart view model and Commerce Runtime (CRT) entities.

ShoppingCartMapper

\ViewModel\ShoppingCart.cs

This class represents the shopping cart in storefront. It has following properties : cart ID, name, type, ShoppingCart item collection, and last modified date.

ShoppingCart

\ViewModel\ShoppingCartItem.cs

This class represents the shopping cart item in storefront. It has following properties: the product ID, product name, product URL, image URL, color, size, style, configuration.

ShoppingCartItem

Dn741462.collapse_all(en-us,AX.60).gifControls

In the Storefront.sln solution, the SharePoint.Web.Controls project contains source code for web controls. The shopping cart is implemented as a set of columns with rows for text in a header and a footer. Columns can contain items, kits, or information about promotions. The shopping cart also displays discounts, tax, subtotals, and grand total. The following table lists the web controls that support the shopping cart.

Name

Description

Link to documentation

Shopping cart control

Generates the template used to render the markup for the shopping cart and its columns

ShoppingCart

ShoppingCartElement

Enumeration of all the allowed shopping cart display elements within a column.

ShoppingCartElement

MiniShoppingCart.cs

The mini shopping cart represents a compact link to the full shopping cart view with an optional shopping cart items count.

MiniShoppingCart

Dn741462.collapse_all(en-us,AX.60).gifWeb part

In the Storefront.sln solution, the SharePoint.Web.WebParts project contains source code for web parts. The following table lists the elements of the ShoppingCart web part.

Name

Description

Link to documentation

ShoppingCartElements.xml

Defines the elements in the shopping cart web part.

n/a

ShoppingCart

The shopping cart web part provides the ability to view the contents of products that were added.

ShoppingCart

ShoppingCartColumn

Data class used in the deserialization of a column's definition for a shopping cart or a derivative (for example, a mini-cart or summary cart).

ShoppingCartColumn

ShoppingCartHelper

Helper class for deserializing shopping cart columns.

ShoppingCartHelper

AddToCart

Functionality for button that adds products to the shopping cart.

AddToCart

MiniShoppingCart

Link to the full shopping cart with an optional shopping cart items count.

MiniShoppingCart

Dn741462.collapse_all(en-us,AX.60).gifPage layout and style sheets

You can map a network drive to view the page layout for the shopping cart in the file ShoppingCart.Layout.aspx. For more information, see Map a network drive to the SharePoint 2013 files for online stores.

In the Storefront.sln solution, the Share.PointWeb.Storefront project contains source code that supports page display. The following table lists the CSS files in the \Styles folder that support the shopping cart.

File Name

Description

ShoppingCart.css

Styles that support the shopping cart page.

MobileShoppingCart.css

Styles that support the mobile shopping cart page.

See also

Getting started with customizing the Retail online sample store

Creating WCF Services for ASP.NET AJAX