close

Filter

loading table of contents...

Frontend Developer Manual / Version 2301

Table Of Contents

6.4.3 Example Cart

The brick provides templates, CSS styles and JavaScript for to handle a cart.

Using the Brick
Rendering a cart

First of all you need to have a cart. The most simple way to achieve this is by using cm.substitute.

  <#assign cart=cm.substitute("cart") />
  

You can also utilize a CMAction and use cart as its id.

After retrieving the cart it can be rendered using the "asCart" view:

  <@cm.include self=cart view="asCart"/>
  
Add-To-Cart Button

An add-to-cart button can be added via the provided FreeMarker library cart.ftl. You need to provide a com.coremedia.livecontext.ecommerce.catalog.Product as the macro needs some information from this bean.

<#-- @ftlvariable name="self" type="com.coremedia.livecontext.ecommerce.catalog.Product" -->

<#import "*/node_modules/@coremedia-examples/brick-cart/src/freemarkerLibs/cart.ftl" as cart />

<@cart.addToCartButton product=self.product!cm.UNDEFINED
                       enableShopNow=true />
  

Please check the FreeMarker library for information about the different parameters.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.