Creating Custom Modules in SuiteCommerce for Enhanced
Create custom modules in SuiteCommerce to add tailored functionality, manage dependencies, and follow best practices for development.
Creating custom modules in SuiteCommerce allows developers to enhance the functionality of their websites by adding specific features tailored to their needs. This guide outlines key requirements and best practices for creating custom modules effectively.
What Are Custom Modules?
Custom modules are user-defined extensions within SuiteCommerce that add specific functionalities not included in the standard implementation. Leveraging these modules can significantly improve site customization and user experience.
Requirements for Custom Module Creation
When creating a custom module, consider the following important requirements:
- File Naming: Source files for SuiteCommerce Advanced (SCA) versions prior to 2019.2 use the
.jsextension, while versions 2019.2 and onwards utilize.tsfor TypeScript. - Directory Structure: The module's top-level directory must follow the naming format
module_name@x.y.z, wheremodule_nameis unique, andx.y.zindicates the version.
Directory Locations
- SCA 2019.2 and Later: Custom modules reside within
Advanced,Backend, andCommons. Create a sub-directory for custom modules, e.g.,SC_20.1/extensions. - SCA 2019.1 and Earlier: Custom modules should be placed under the
Modules/extensionsdirectory.
Essential Files and Structure
Each module must include specific files and a structured approach:
-
Directory Structure: Create a search-based directory layout that includes JavaScript, Sass, SuiteScript, and Template subdirectories.
-
Entry Point: The module must export an object with a
mountToAppproperty.javascript1// MyNewModule.js2"text-purple-400">define('MyNewModule', [3 'MyNewModule.Router'4], "text-purple-400">function (Router) {5 'use strict';6 "text-purple-400">return {7 mountToApp: "text-purple-400">function (application) {8 "text-purple-400">return "text-purple-400">new Router(application);9 }10 };11}); -
Router: Connect module functions to defined URLs.
javascript1// MyNewModule.Router.js2"text-purple-400">define('MyNewModule.Router', [3 'MyNewModule.View', 'Backbone'4], "text-purple-400">function (MyNewModuleView, Backbone) {5 'use strict';6 "text-purple-400">return Backbone.Router.extend({7 routes: {8 'my-">new-module': 'myNewModuleRouter'9 },10 initialize: "text-purple-400">function (application) {11 "text-purple-400">this.application = application;12 },13 myNewModuleRouter: "text-purple-400">function () {14 "text-purple-400">var view = "text-purple-400">new MyNewModuleView({ application: "text-purple-400">this.application });15 view.showContent();16 }17 });18}); -
View: Implement the view which calls the corresponding template.
javascript1// MyNewModule.View.js2"text-purple-400">define('MyNewModule.View', [3 'my_new_module.tpl', 'Backbone', 'jQuery'4], "text-purple-400">function (MyNewModuleTemplate, Backbone, jQuery) {5 'use strict';6 "text-purple-400">return Backbone.View.extend({7 template: MyNewModuleTemplate,8 events: {9 'click [data-action="test"]': 'testAction'10 },11 testAction: "text-purple-400">function () {12 alert("This is a test action");13 },14 getContext: "text-purple-400">function () {15 "text-purple-400">return {16 myNewModuleContextVar: 'myVariable'17 };18 }19 });20}); -
Template: Create templates using Handlebars for rendering UI.
html<h2>This is my template file for my new module. It takes variables, {{myNewModuleContextVar}}, passed from the View.</h2>
Additional Steps for Module Integration
- Configuration: If needed, include a Configuration subdirectory in the module's directory, particularly in later versions of the SCA.
- ns.package.json: Define all module dependencies in this file, necessary for the build process. Example structure of this file includes keys for directories like JavaScript, templates, and services.
- Update
distro.json: This is critical for ensuring the application recognizes the new module. Include your module in both themodulesandjavascriptobjects within this configuration file.
After creating the module, you can test and view your changes on a local server or by deploying through the developer tools in NetSuite. This ensures all features work correctly within the SuiteCommerce environment.
Conclusion
Creating custom modules in SuiteCommerce enables tailored site functionalities that enhance user experience. By adhering to the specified structure and following best practices, developers can implement effective customizations while maintaining ease of future upgrades.
Key Takeaways
- Custom modules extend SuiteCommerce functionalities tailored to specific needs.
- The directory structure and file naming conventions are crucial for successful implementation.
- Always maintain unique file names and module names to avoid conflicts.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What prerequisites must be met before creating a custom module in SuiteCommerce?
How do I organize the directory structure for a custom module in SuiteCommerce Advanced 2019.2 and later?
What files are essential for a custom module in SuiteCommerce?
How do changes to the `distro.json` file affect custom modules in SuiteCommerce?
Was this article helpful?
More in Commerce
- Available Items Only Feature in NetSuite 2026.1
Available items only filtering boosts sales efficiency in NetSuite 2026.1 with Intelligent Item Recommendations.
- Commerce Extensions in NetSuite 2026.1
Commerce Extensions in NetSuite 2026.1 enhance performance and user experience in eCommerce.
- Convert Multiple Transaction Line Items into Configured Items in
Enhance transaction processing in NetSuite by converting multiple line items into configured items with improved session handling.
- New SuiteCommerce Features in NetSuite 2026.1
New SuiteCommerce features in NetSuite 2026.1 enhance user experience and improve eCommerce efficiency.
