1. Home
  2. Docs
  3. Sfcc
  4. Custom Code
Log a Case

Custom Code

In order to implement some of the features of the Zenkraft LINK Integration cartridge, some custom code changes need to be done. Below are the changes that need to be made, separated by available feature.

NOTE: Actual code for all of the code changes below can be found in the file custom-code.txt in the metadata folder for the LINK cartridge.

Real Time Shipping Rates

Controllers

COShipping.js

1. Require the ZenkraftModel at the top of the file:

2. In the UpdateShippingMethodList() function, add the following to get the shipping methods/rates from the Zenkraft API:

 

3.  Add the Zenkraft methods to the getView() call in UpdateShippingMethodList()

Client-side Javascript

shipping.js

In order for the shipping methods to work with the Zenkraft API, the need to be refreshed when the address changes. To make this happen, you’ll need to comment out the following section of the UpdateShippingMethodList() function in shipping.js:

calculate.js

To have the Zenkraft rates used in place of the SFCC rates, the following update needs to be made to calculate.js.

Templates

checkout/shipping/shippingmethods

In order to make sure that shipping methods are ONLY rendered if they have been returned from the Zenkraft API, you need to check to see if the methods are on the session and, if not, display a message telling the user they need to enter their address.

The check is done at the top of the template in the <isscript> section:

Then you’ll need to wrap the existing code in the template in the following conditional:

Return Labels for Customers

Templates

components/order/orderdetails.isml

To display a link in the order details so that a user can print a return label if the order has a shipping status of shipped, add the following code. You can customize the UI in any way you want so that it’s a link, button, etc. You just need to make sure that the zenkraft form definition is used and that the action is the Zenkraft-PrintLabel route.

Client-side Javascript

int_zenkraft/cartridge/js/zenkraft.js

For all of the client-side interactions, this file needs to be included in your compiled javascript. You can do this by simply adding the file to your js folder and requiring it in app.js in that same js folder. If, however, you have a custom implementation for handling your javascript, you’ll need to add it that way.

Drop Off Shipping Locations

Templates

checkout/shipping/shippingmethods.isml

To get the Drop Off Shipping Locations added to the shipping page, you’ll need to include the checkout/shipping/dropoffshipments template (included in int_zenkraft) into the checkout/shipping/shippingmethods.isml template.

Client-side Javascript

int_zenkraft/cartridge/js/zenkraft.js
For all of the client-side interactions, this file needs to be included in your compiled javascript. You can do this by simply adding the file to your js folder and requiring it in app.js in that same js folder. If, however, you have a custom implementation for handling your javascript, you’ll need to add it that way.

Shipment Tracking

One of the best things about the shipment tracking page is that once you have the Zenkraft cartridge set up, there’s nothing else you need to do in order to get it up and running. It is available at the Zenkraft-Track endpoint of your existing site. 

Shipment Tracking URL 

In order to send your customers to the shipment tracking page, you’ll need to construct the URL in the correct format. As mentioned earlier, the Zenkraft-Track route is where you’ll send them. The URL requires two query string parameters: tracknumber and carrier, with an optional order parameter

  • tracknumber: the tracking number associated with this shipment
  • carrier: thte carrier associated with this shipment
  • order: the SFCC order number

You can also set up seo-friendly URLs so that your resulting URL will look something like: https://www.yourbrandedsite.com/trackshipment?tracknumber=123456789&order=N1231231

External Interfaces

The Zenkraft LINK cartridge integrates with the Zenkraft API through the Salesforce Commerce Cloud Service Framework. In order to get access to the API, you’ll need to contact a representative at Zenkraft and obtain an API key.

Contents: