menu

SiteGenesis / Server-side JS / Module: controllers/GiftCert

Controller for gift certificate purchases.

Source:

Members

(static) AddToBasket

Adds a gift certificate to the basket.

Source:
See:

(static) CheckBalance

Displays the details of a gift certificate to check the current balance.

Source:
See:

(static) Edit

Updates and renders the gift certificate purchase page.

Source:
See:

(static) Purchase

Renders the page to purchase a gift certificate.

Source:
See:

(static) ShowMiniCart

Renders the minicart.

Source:
See:

(static) Update

Updates the gift certificate in the basket.

Source:
See:

Methods

(inner) addToBasket()

Adds a gift certificate to the basket. This is called when the giftcert.purchase form is posted in the giftcertpurchase.isml template.

Source:

(inner) checkBalance()

Displays the details of a gift certificate as a JSON object in order to check the current balance. If an error occurs, renders an error message.

Source:

(inner) createGiftCert(cart) → {dw.order.GiftCertificateLineItem}

Creates a gift certificate in the customer basket using form input values. If a gift certificate is added to a product list, a ProductListItem is added, otherwise a GiftCertificateLineItem is added. Note: the form must be validated before this function is called.

Parameters:
Name Type Description
cart module:models/CartModel~CartModel

A CartModel wrapping the current Basket.

Source:
Returns:

gift certificate line item added to the current basket or product list.

Type
dw.order.GiftCertificateLineItem

(inner) edit()

Updates and renders the gift certificate purchase page. Clears the giftcert form and assigns values to the giftcert.purchase form from the gift certificate line item. Sets ContinueURL to GiftCert-Update and renders the gift certificate purchase page (checkout/giftcert/giftcertpurchase template). If there is no existing cart or no gift certificate line item, calls the purchase function.

Source:

(inner) processAddToBasket(action)

Internal helper function that creates/updates the gift certificate. Validates the giftcert.purchase form and handles any errors. Gets or creates a CartModel and creates or updates the gift certificate line item. It then recalculates the cart. For ajax requests, renders the checkout/giftcert/giftcertaddtobasketjson template. For all other requests, calls the Cart controller show function.

Parameters:
Name Type Description
action function

The gift certificate function to execute.

Source:

(inner) purchase()

Clears the giftcert form and calls the showPurchase function to render the page to purchase a gift certificate.

Source:

(inner) showError(args)

Internal helper to show errors on the purchase page. For an ajax request, renders a JSON object (checkout/giftcert/giftcertaddtobasketjson template). Otherwise, calls the showPurchase function.

Parameters:
Name Type Description
args Object
Properties
Name Type Description
FormErrors dw.util.Map

Errors from the form.

GeneralError String

Errors from the page.

Source:

(inner) showMiniCart()

Gets the gift certificate line item and renders the minicart (checkout/cart/minicart) template.

Source:
To Do:
  • Check why normal minicart cannot be used

(inner) showPurchase()

Internal helper function that prepares and shows the purchase page without clearing the form. Populates the giftcert.purchase with information from the httpParameterMap and the customer profile. Sets the ContinueURL to GiftCert-AddToBasket and renders the purchase page (checkout/giftcert/giftcertpurchase template).

Source:

(inner) update()

Updates the gift certificate in the basket. This is called when the giftcert.purchase is posted in the giftcertpurchase.isml template.

Source:

(inner) updateGiftCert(cart) → {dw.order.GiftCertificateLineItem}

Updates a gift certificate in the customer basket using form input values. Gets the input values from the purchase form and assigns them to the gift certificate line item. Note: the form must be validated before calling this function.

Parameters:
Name Type Description
cart module:models/CartModel~CartModel

CartModel that wraps the current Basket.

Source:
Returns:

gift certificate line item.

Type
dw.order.GiftCertificateLineItem