Requiring Kit Item Before Submitting Enrollment Application
Admin: eCommerce Admin
Page: Advanced Customization > Javascript Insertion
URL: {client_ID}.retailadmin.directscale.com/#/Insertion
With this example, you can restrict an Associate from submitting their enrollment application if they haven't added a kit to the cart.
Adding an Insertion
- In the JavaScript Insertions page, click + ADD INSERTION.
- Select Custom Script from the Insertion Type menu.
- Enter a sort Name.
- In the JavaScript Code Editor, paste the following code:
try {
console.log('loaded custom insertions');
var ct = window.customTriggers;
var itemsService = angular.element(document).injector().get('itemsService');
var userService = angular.element(document).injector().get('userService');
var isDisabled = function (items, cartID, CurrentItem, Quantity, QuantityLimit, isPlaceOrder) {
if (isPlaceOrder) {//on place order check
//if only one pack is required(submit button disabled)
if(userService.customerTypeID==1 && itemsService.selectedPacks.length == 0){
return true;
}
else{
return false;
}
}
}
//show required message and item limit exceed message
var tooltip = function (items, cartID, CurrentItem) {
return ((userService.customerTypeID==1 && itemsService.selectedPacks.length == 0)? "One Kit Item is required":'');
}
ct.addReviewOrderDisabledQTYFilter(isDisabled);
ct.setReviewOrderDisabledQTYTooltip(tooltip);
}
catch (e) {
console.log('Order Quantity Maximum Limit -- Insertion', e);
}
Updated over 3 years ago