Working with the MiniCart Web Part

The Mini Cart Web Part applies an XSLT template to render a short summary of the shopping cart, including line item count and subtotals.

Architecture

The Mini Cart Web Part contains the following components:

  • MiniCartWebPart/SPMiniCartWebPart. Applies the XSLT template to render the Mini Cart Web Part HTML code. This component uses the SiteContext class to read and write the subtotal and line items count to the session (which uses an HTTP cookie). If the session does not contain this information, the ShoppingController is called to retrieve the basket. The XML source is a root node called "Basket". The subtotal and line items are passed into the XSLT as arguments.

  • ShoppingController. Encapsulates all Commerce Foundation calls relating to putting items in a cart and checking out-related operations. When a basket is loaded or retrieved, the ShoppingController class updates the subtotal and line item count in the session.

Properties

The following table lists and describes the MiniCart Web Part properties.

Property

Type

Maps to

Description

Default

Template To Display

String

Not applicable

Template file name.

Blank

Commerce "Basket" to use

String

BasketName

Sets the name of the Commerce Foundation "Basket" that this web part will use. The default and recommended value is empty, indicating the default Basket.

Blank

Customization

You can customize the Mini Cart Web Part by modifying the XSLT template.

Configuration can be done through the Web Part's custom editor part, called XsltTemplateEditorPart. This part is accessed through the Modify Web Part selection in the Edit menu of the Web Part when logged in as administrator to the site.

Clicking the XSL Transform button displays an editor where you can edit the XSL transform directly.

The following table lists the XSLT parameters that you can use to create your template.

XSLT parameter

Description

ClientId

Generated ID of the Web Part.

ItemCount

Count of items in the cart.

ItemQuantitySum

Sum of the total item quantity.

SubTotal

Subtotal of the items in the cart.

SiteCollectionUrl

URL of the site collection (SPSite.Url).

HomeUrl

URL of the site home page.

CurrencyCode

The currency code for the current catalog.

To add custom XSLT parameters, you use the Extensibility Kit to modify the Web Part.

Error Handling

There is no design-time error handing required for this Web Part.

Run Time Validation

No run time validation is performed on this Web Part.

In addition, the Mini Cart Web Part handles the following scenarios:

  • Lets a shopper add a product to the shopping cart with a quantity set to zero (0) or a negative number.

Note

Although the Mini Cart Web Part accepts negative and zero (0) values for quantity properties, other Web Parts such as the Product Query Web Part and the Add to Cart do not support such values.

  • Does not let a shopper add a product to the cart that is out of stock.

API Dependencies

The Retrieve Basket API is a dependency for this Web Part.

See Also

Other Resources

Developing with SharePoint Commerce Services

Developing with Orders Web Parts

MiniCart Web Part