Changes in controllers

  1. In YOUR_CARTRIDGE_controllers/cartridge/controllers/COBilling.js

    1. Put the following row to the function returnToForm() in line 93:

      if (params && !Object.hasOwnProperty.call(params, 'error')) {
      
    2. Put the following rows to the function returnToForm() in line 100:

      error: params.error,
      errorMessage: params.errorMessage || Resource.msg('confirm.error.technical', 'checkout', null),
      

    3. Put the following rows to the function resetPaymentForms() in line 371:

      } else if (app.getForm('billing').object.paymentMethods.selectedPaymentMethodID.value.equals('Catch')) {
          var paymentInstruments = cart.object.paymentInstruments.toArray();
      
      
          paymentInstruments.forEach(function (paymentInstrument) {
              var paymentMethod = paymentInstrument.paymentMethod;
              if (paymentMethod !== 'Catch') {
                  cart.removePaymentInstruments(cart.getPaymentInstruments(paymentMethod));
              }
          });
      }
      

    4. Put the following rows to the function save() in line 548:

      cart.removePaymentInstruments(cart.getPaymentInstruments('Catch'));
      
    5. Modify the initial code to the following rows in line 549:

      var handlePaymentSelectionResult = handlePaymentSelection(cart);
      if (!resetPaymentForms() || !validateBilling() || !handleBillingAddress(cart) || 
          handlePaymentSelectionResult.error) {                    
      returnToForm(cart, handlePaymentSelectionResult);
      
    6. Modify COSummary controller call rows in line 564:

      var handlePaymentSelectionResult = handlePaymentSelection(cart);
      if (!resetPaymentForms() || !validateBilling() || !handleBillingAddress(cart) || 
          handlePaymentSelectionResult.error) {                    
      returnToForm(cart, handlePaymentSelectionResult);
      

  2. In YOUR_CARTRIDGE_controllers/cartridge/controllers/COPlaceOrder.js, put the following row to the function returnToForm() in line 143:

    // ---- Catch code start ----
    var catchCheckoutHelper = require('*/cartridge/scripts/catch/helper/catchCheckoutHelper');
    var catchIsEnabled = require('*/cartridge/scripts/catch/helper/catchHelper').getPreference('enable');
    
    
    var paymentInstruments = cart.getPaymentInstruments();
    if (catchIsEnabled && paymentInstruments) {
        for (var i = 0; i < paymentInstruments.length; i++) {
            if (paymentInstruments[i].paymentMethod === 'Catch') {
                if (!catchCheckoutHelper.basketStateIsValid(cart.object)) {
                    return {
                        error: true,
                        PlaceOrderError: new Status(Status.ERROR, 'error.cart.invalid')
                    };
                }
                break;
            }
        }
    }
    // ---- Catch code end ----
    

Changes in templates

  1. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/minisummary.isml, put the following rows in line 44:

    <iscomment>Catch Code</iscomment>
    <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'checkout')}" />
    <iscomment>Catch Code</iscomment>
    

  2. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/pt_checkout_UI.isml, add Catch styles to the end of the file:

    <link rel="stylesheet" type="text/css" href="${dw.web.URLUtils.staticURL("/css/catch/catch.css")}">
    

  3. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/pt_checkout_VARS.isml, add Catch scripts to the end of the file:

    <script src="${dw.web.URLUtils.staticURL("/js/catch/catch-checkout.js")}"></script>
    <script src="${dw.web.URLUtils.staticURL("/js/catch/catch-callout.js")}"></script>
    

  4. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/billing/billing.isml, put the following rows in line 31:

    <isif condition="${pdict.error === true}">
            <div class="error-message catch-checkout-error">
                ${pdict.errorMessage}
    </div>
    </isif>
    

  5. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/billing/paymentmethods.isml

    1. Extend <div> tag with class="payment-method-options" in line 12:

      <div class="payment-method-options form-indent catch-flex">
      
    2. Put the following row in line 13:

      <isset name="catchHelper" value="${require('*/cartridge/scripts/catch/helper/catchHelper.js')}" scope="page"/>
      
    3. Put the following row in line 20:

      <isif condition="${paymentMethodType.value.equals('Catch') && !catchHelper.getPreference('enable')}"><iscontinue/></isif>
      
    4. Extend <div> tag with id="checkout-main" in line 22:

      <div class="form-row label-inline <isif condition="${paymentMethodType.value.equals('Catch')}">label-hidden</isif>">
      
    5. Extend <div> tag with class="field-wrapper" in line 24:

      <div class="field-wrapper catch-flex">
      
    6. Put the following row in line 26:

      <isif condition="${radioID === 'Catch'}">
          <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'payment')}" />
      </isif>
      
    7. Extend tag in line 30:

      <label for="is-${radioID}">
          <isif condition="${radioID !== 'Catch'}">
              <isprint value="${Resource.msg(paymentMethodType.label,'forms',null)}"/>
          </isif>
      </label>
      

    8. Put the following row in line 148:

      <isinclude template="catchPaymentMethod">
      

  6. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/cart/cart.isml, put the following rows in line 821:

    <iscomment>Catch Code</iscomment>
    <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'cart')}" />
    <iscomment>Catch Code</iscomment>
    

  7. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/cart/minicart.isml, put the following rows in line 61:

    <div class="callout-mini-cart-wrapper">
      <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'minicart')}" />
    </div>
    

  8. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/summary/pt_cart_VARS.isml, put the following row to the end if the file:

    <script src="${dw.web.URLUtils.staticURL("/js/catch/catch-callout.js")}"></script>
    

  9. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/summary/pt_cart_UI.isml, add Catch styles to the end of the file:

    <link rel="stylesheet" type="text/css" href="${dw.web.URLUtils.staticURL("/css/catch/catch.css")}">
    

  10. In YOUR_CARTRIDGE_core/cartridge/templates/default/checkout/summary/summary.isml, wrap the <button> tag of the ‘PlaceOrder’ in ‘if’ statement in line 220:

    <isif condition="${pdict.Basket.paymentInstrument.paymentMethod === 'Catch'}">
        <isinclude template="catch/catchpay"/>
    <iselse/>
        … ‘placeOrder' <button> tag
    </isif>
    

  11. In YOUR_CARTRIDGE_core/cartridge/templates/default/components/header/htmlhead.isml, put the following row in line 80:

    <isinclude template="catch/catchInit" />
    

  12. In YOUR_CARTRIDGE_core/cartridge/templates/default/components/header/htmlhead_UI.isml, put the following row in line 11:

    <link rel="stylesheet" type="text/css" href="${dw.web.URLUtils.staticURL("/css/catch/catch.css")}">
    

  13. In YOUR_CARTRIDGE_core/cartridge/templates/default/components/order/orderdetails.isml, put the following rows in line 222:

    <isloop items="${pdict.order.paymentInstruments}" var="payment">
        <isif condition="${payment.paymentMethod === 'Catch' && Order.custom.catch_earned !== 0}">
            <isset name="paidWithCatch" value="${true}" scope="page" />
            <isif condition="${!pdict.orderstatus}">
                <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'purchase', 'pdictOrderNo', pdict.order.orderNo, 'pdictOrderToken', pdict.order.orderToken)}" />
            </isif>
        </isif>
    </isloop>
    
    
    <isset name="catchHelper" value="${require('*/cartridge/scripts/catch/helper/catchHelper')}" scope="page" />
    <isif condition="${catchHelper.getPreference('enable')
        && catchHelper.getPreference('campaignLinkWidgetEnable')
        && catchHelper.getPreference('campaignName')
        && typeof paidWithCatch === 'undefined'
        && !pdict.orderstatus}">
        <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'campaign')}" />
    </isif>
    

  14. In YOUR_CARTRIDGE_core/cartridge/templates/default/product/productcontent.isml, put the following row in line 78:

    <iscomment> Catch Code </iscomment>
    <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'product', 'productId', pdict.Product.ID)}" />
    <iscomment> Catch Code </iscomment>
    

  15. In YOUR_CARTRIDGE_core/cartridge/templates/default/product/producttopcontentPS.isml, put the following rows in line 122:

    <iscomment> Catch Code </iscomment>
    <isif condition="${pdict.isBundle}">
    <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'product', 'productId', pdict.Product.ID)}" />
    </isif>
    <iscomment> Catch Code </iscomment>
    

  16. In YOUR_CARTRIDGE_core/cartridge/templates/default/product/pt_productdetails_UI.isml, put the following row to the end if the file:

    <link rel="stylesheet" type="text/css" href="${dw.web.URLUtils.staticURL("/css/catch/catch.css")}">
    

  17. In YOUR_CARTRIDGE_core/cartridge/templates/default/product/pt_productdetails_VARS.isml, put the following row to the end if the file:

    <script src="${dw.web.URLUtils.staticURL("/js/catch/catch-callout.js")}"></script>
    

  18. In YOUR_CARTRIDGE_core/cartridge/templates/default/product/components/productsetproduct.isml, put the following rows in line 24:

    <iscomment> Catch Code </iscomment>
      <isif condition="${pdict.isSet}">
        <isinclude url="${URLUtils.url('Catch-IncludeWidget', 'widgetName', 'callout', 'page', 'product', 'productId', pdict.Product.ID)}" />
      </isif>
    <iscomment> Catch Code </iscomment>
    

  19. In YOUR_CARTRIDGE_core/cartridge/templates/default/components/header/header.isml, put the following rows at the beginning:

    <isset name="catchHelper" value="${require('*/cartridge/scripts/catch/helper/catchHelper')}" scope="page" />
    <isif condition="${catchHelper.getPreference('enable')}">
        <span class="catch-data" data-key="<isprint value="${catchHelper.getPreference('publicKey')}" encoding="htmldoublequote"/>"></span>
    </isif>
    

Changes in resources

  1. In YOUR_CARTRIDGE_core/cartridge/templates/resources/checkout.properties, put the following row in line 221:

    error.cart.invalid=Your order total has changed. refresh your cart and try again
    

Next Steps

Continue to SFCC Catch Configuration