Commerce Reference Store extends several core Commerce gift with purchase components.
StoreGiftWithPurchaseFormHandler
In Commerce Reference Store, the /atg/commerce/promotion/GiftWithPurchaseFormHandler
component is of class atg.projects.store.promotion.StoreGiftWithPurchaseFormHandler
. This class extends the core Commerce atg.commerce.promotion.GiftWithPurchaseFormHandler
class to handle gift selection requests through AJAX. This allows the application to perform better when validation errors occur because the whole page does not need to be reloaded, only the error messages do. StoreGiftWithPurchaseFormHandler
extends the handleMakeGiftSelection()
method to redirect to different success and error URLs, depending on whether or not the request was made through AJAX. StoreGiftWithPurchaseFormHandler
also extends the preMakeGiftSelection()
method so that the application displays different error messages for each SKU attribute (color, size, wood finish).
StoreGWPManager
In Commerce Reference Store, the /atg/commerce/promotion/GWPManager
component is of class atg.projects.store.promotion.StoreGWPManager
. This class extends the core Commerce atg.commerce.promotion.GWPManager
class. StoreGWPManager
modifies the processAutoAdd()
method in order to check the inventory level of an item before adding it as a gift to the order. Also, this class adds these helper methods:
getQuantityToBeSelected()
determines the gift quantity that is still available for selection in the order.getItemGiftQuantity()
determines gift quantity in the currentCommerceItem
.validateGiftItem()
applies theCollectionObjectValidator
components listed in thevalidators
property to the gift item to validate it. ThepreMakeGiftSelection()
method ofStoreGiftWithPurchaseFormHandler
calls this method. By default, thevalidators
property is set to the/atg/store/collections/validator/StartEndDateValidator
component.
StoreGiftWithPurchaseSelectionsDroplet
In Commerce Reference Store, the /atg/commerce/promotion/GiftWithPurchaseSelectionsDroplet
component is of class atg.projects.store.droplet.StoreGiftWithPurchaseSelectionsDroplet
. This class extends the core Commerce atg.commerce.promotion.GiftWithPurchaseSelectionsDroplet
class by adding an additional quantityToBeSelected
output parameter that represents the gift quantity in the order that has not been selected yet.