Thursday, May 16, 2013

Setting Up The Promotion via an URL : ATG


You can set a promotion to site visitors in a variety of ways, such as via a scenario or coupon. The preceding sections describe how to create promotions and use these delivery methods. This section provides information on another way to deliver a promotion to site visitors – via a URL on a JSP. You embed the ID of the promotion you want to offer in the URL. When a site visitor clicks that URL, the promotion is added to the visitor’s activePromotions Profile property.

To deliver a promotion via a URL, do the following:


Enable the /atg/commerce/promotion/PromotionServlet by setting its enabled property to true in its .properties file. By default, ATG Commerce inserts PromotionServlet in the request-handling pipeline, but you must enable it for use.

Include a URL on the desired JSP using an anchor tag like the following:


<dsp:a href="../../samplepage.jsp" encode="true">
<dsp:param value="promo1000001" name="PROMO"/>
Click here to get a 40% discount on shirts.
</dsp:a>


where ../../samplepage.jsp is the page to which you want to link, and the value of the PROMO request parameter is the ID of the promotion in the /atg/commerce/pricing/Promotions repository.


Note that encode=true is required in the anchor tag. This causes the PROMO parameter subtag to be encoded into the URL as a URL parameter and not a query parameter. In turn, PromotionServlet calls getURLParameter() on the request to retrieve the PROMO parameter value.

Also Note that the item descriptor of the promotion must be one of the item descriptors in PromotionServlet.promotionItemDescriptorNames.

When a request is passed into PromotionServlet, if the servlet is disabled, it simply passes the request to the next servlet in the pipeline. If it is enabled, it looks for a PROMO parameter in the URL parameters of the request and retrieves the associated promotion ID. Next, the servlet looks for a promotion in the Promotions repository whose ID is the given ID and whose item descriptor is included in PromotionServlet.promotionItemDescriptorNames. If the promotion exists, then PromotionServlet checks that either the profile is persistent or the promotion’s Give To Anonymous Customers (giveToAnonymousProfiles) property is set to true. If either condition is true, the promotion is added to the user’s activePromotions Profile property.




No comments:

Popular Posts