Modifying Your Storefront

The Commerce Cloud Endless Aisle app server code includes the following cartridges:

The following combinations are possible:

Note: Salesforce recommends using controllers unless you are on a compatibility mode earlier than 15.5.
Before performing the following steps, you should have:
  1. Add cartridge code to your Commerce Cloud server by importing it into Eclipse and adding it as a project reference on your server:
    • If you are using pipelines, add int_ocapi_ext_core and int_ocapi_ext_pipelines.
    • If you are using controllers, add int_ocapi_ext_core and int_ocapi_ext_controllers.
  2. In int_ocapi_ext_core, update script import references by searching for "ea_sitegenesis_storefront" in cartridge/scripts/actions/GetCoreCartridgePath.ds and replacing it with the name of the core cartridge.
  3. In your storefront cartridge, add the function calculateNonGiftCertificateAmount to cartridge/scripts/checkout/Utils.ds.

    The function is available in the package of server files available from Salesforce. Copy and then paste the function from the file ea_sitegenesis_storefront/cartridge/scripts/checkout/utils.ds.

  4. If you are using ValidateCartForCheckout.js, change any existing references in the code to ValidateCartForCheckout.js, instead of referring to ValidateCartForCheckout.ds.
  5. Ensure that the following functions are included in CalculateCart.ds or calculate.js by copying the functions from ea_sitegenesis_storefront/cartridge/scripts/cart/CalculateCart.ds or ea_sitegenesis_storefront/cartridge/scripts/cart/calculate.js, whichever matches what you are using in your storefront:
    • CalculateCart
    • calculateProductPrices
    • calculateGiftCertificates
    • calculateTax
    • updateTotals(basket: Basket)
    • overrideProductPrice
    • overrideShippingPrice(basket : Basket)
    • addCustomAttributesToBasket(basket : Basket)
    • addProductItemCustomAttributes(basket : Basket)
    • calculateAvailabilityMessage(pli: ProductLineItem)
    • addShippingMethodCustomAttributes(basket: Basket)
    • addBasketCustomAttributes(basket : Basket)
    • calculateProductTotals(basket : Basket, obj : Object)
    • calculateShippingPrices(basket : Basket, obj : Object)
    • calculateApproachingPromotions(basket : Basket, obj : Object)
    • calculateCoupons(basket : Basket, obj: Object)
    Note: If your storefront is based on a newer version of SiteGenesis, CalculateCart.ds has been replaced by calculate.js. In that case, you need to change calculate.js (using new hooks).
  6. In CalculateCart.ds or calculate.js, call the function overrideProductPrice from within the calculateProductPrices function by adding the line:
    productPrices = overrideProductPrice(basket, productPrices);

    after

    for each(var product : Product in productQuantities.keySet())
        {
            var quantity : Quantity = productQuantities.get(product);
            productPrices.put(product, product.priceModel.getPrice(quantity));
        }
  7. Call the function overrideShippingPrice from within the CalculateCart function in CalculateCart.js or the calculate function in calculate.js after ShippingMgr.applyShippingCost(basket) and before PromotionMgr.applyDiscounts(basket).
  8. If you want to enable multi-currency, in calculateCart.ds, replace dw.system.Site.current.currencyCode to be session.getCurrency().getCurrencyCode() throughout the file.
  9. To use multi-currency with Site Genesis Global, in calculate.js, replace dw.system.Site.current.currencyCode to be session.getCurrency().getCurrencyCode() throughout the file.
  10. Copy the function calculatePaymentInstrumentBalanceAmount from ea_sitegenesis_storefront/cartridge/scripts/checkout/Utils.ds to app_storefront_core/cartridge/scripts/checkout/Utils.ds or mystorefront_storefront_core/cartridge/scripts/checkout/Utils.ds.
  11. Include:
    module.exports={
    execute:execute
    }

    in the files:

    • GetApplicableShippingMethods.ds
    • PrecalculateShipping.ds
    • UpdateShipmentShippingMethod.ds
  12. If you are using Endless Aisle pipelines with app_storefront_pipelines or using Endless Aisle controllers with app_storefront_pipelines:
    1. In countries.isml, change states.stateUS.options to states.state.options. Add .toUpperCase() in the if condition when checking for the country value.
    2. Add a line in easearchcustomerjson.isml:
      <isset name="countryObj" value="${addressObj.countryCode.displayValue.toUpperCase()}" scope="page"/>

      after

      <isif condition="${!empty(addressObj)}">

      and replace addressObj.countryCode with countryObj.

  13. If you are using Endless Aisle controllers:
    1. Upload app_storefront_controllers and be on a compatibility mode of 15.5 or later.
    2. Ensure that you have changed the cartridge path from int_ocapi_ext_pipelines to int_ocapi_ext_controllers.
  14. If you are using Endless Aisle controllers with app_storefront_controllers:
    1. Include:
      module.exports={
      execute:execute
      }

      in the files:

      • GetCustomerCreditCard.ds
      • SetOrderStatus.ds
    2. In EAUtils.js set the variable useControllers, which is false by default, to true if you want to use storefront controllers.
    3. In app_storefront_controllers/cartridge/scripts/payment/processor/BASIC_CREDIT.js, replace the line:
      var paymentProcessor = PaymentMgr.getPaymentMethod(paymentInstrument.getPaymentMethod()).getPaymentProcessor(); 

      with

      var paymentProcessor = PaymentMgr.getPaymentMethod(paymentInstrument.getPaymentMethod().split(" ")[0]).getPaymentProcessor();

The following files are changed:

In app_storefront_core/cartridge/scripts/  
cart/calculate.js or CalculateCart.ds Ensure functions match what is required for Endless Aisle

Add functions overrideProductPrice(basket, productPrices) and overrideShippingPrice

checkout/GetApplicableShippingMethods.ds

checkout/PrecalculateShipping.ds

checkout/ UpdateShipmentShippingMethod.ds

Include:
module.exports={
execute:execute
}
checkout/GetCustomerCreditCard.ds

checkout/SetOrderStatus.ds

Include:
module.exports={
execute:execute
}
Note: Only change these files if you are using If Endless Aisle controllers with app_storefront_pipelines.
checkout/Utils.ds Copy the function calculatePaymentInstrumentBalanceAmount from ea_sitegenesis_storefront/cartridge/scripts/checkout/Utils.ds Add the function calculateNonGiftCertificateAmount from ea_sitegenesis_storefront/cartridge/scripts/checkout/utils.ds in the package of server files.
In int_ocapi_ext_core/cartridge/
scripts/actions/GetCoreCartridgePath.ds Update script import references by searching for "ea_sitegenesis_storefront" replacing it with the name of the core cartridge
templates/default/responses/countries.isml Change states.stateUS.options to states.state.options. Add .toUpperCase() in the if condition when checking for the country value.
Note: Only make this change if you are using Endless Aisle pipelines with app_storefront_pipelines or using Endless Aisle controllers with app_storefront_pipelines.
templates/default/responses/easearchcustomerjson.isml Add a line:
<isset name="countryObj" value="${addressObj.countryCode.displayValue.toUpperCase()}" scope="page"/>

after

<isif condition="${!empty(addressObj)}">

and replace addressObj.countryCode with countryObj

Note: Only make this change if you are using Endless Aisle pipelines with app_storefront_pipelines or using Endless Aisle controllers with app_storefront_pipelines.
In int_ocapi_ext_pipelines/cartridge/pipelines/
EACheckout.xml

EACreditCard.xml

Change all references for the cartridge path to the one you are using. (ea_sitegenesis_storefront or app_storefront_core)
Note: Only change if you are using app_storefront_pipelines.

The next step is importing metadata.

Related Links

Downloading Endless Aisle Source Code

Endless Aisle App Source Code

Endless Aisle API Source Code

Importing the Endless Aisle Project

Updating the Cartridge Path

Adding Endless Aisle Module to Administration Role

Generate Site Import Data

Import Site

Enabling Endless Aisle CalculateCart Hooks

Enabling Multi-Currency in Endless Aisle

Updating GetImage On Server Side