Add a shopping cart button to the product page


Make sure you have ATG running with your Application 
module.
We are adding a jsp page fragment called addcart.jsp.
This fragment will use two parameters passed from other jsp,
skuInfo.jsp - skuId and productId.

Add the form and inputs required to add an item to the order, 
as shown in the sample code below:

<dsp:input type="hidden"
bean="CartModifierFormHandler.catalogRefIds" paramvalue="skuId"/>
<dsp:input type="hidden" bean="CartModifierFormHandler.productId"
paramvalue="productId"/>
<dsp:input type="text" size="5"
bean="CartModifierFormHandler.quantity" value="1"/>
<dsp:input type="hidden"
bean="CartModifierFormHandler.addItemToOrderSuccessURL"
value="cart.jsp"/>
<dsp:input type="submit"
bean="CartModifierFormHandler.addItemToOrder" value="Add to Cart"/>

Don't forget to import the
/atg/commerce/order/purchase/CartModifierFormHandler component.

Make sure you pass the following parameters to the cart page:
skuId=sku.repositoryId
productId=product.repositoryId

Test the cart button by clicking it from a product page.

To verify that the sku was added to the current order object, navigate 
to /atg/dynamo/servlet/sessiontracking/SessionManager. Find your browser
session and expand it to navigate to and open your session-scoped copy of /atg/commerce/ShoppingCart. Click to select the ShoppingCart's current
property. Click the ellipsis button to open the current order object. 
Check that the totalCommerceItemCount matches the number of items you 
added to the cart.

Tip: You could also use the order number shown here to look up the 
     information saved about this order in the Orders Repository.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...