top of page
Blog Page(1902x420).jpg

Keep your business ahead with

Insights That Drive Innovation

Search

How to Create Custom Cartridges in Salesforce Commerce Cloud

Salesforce Commerce Cloud is a powerful eCommerce platform trusted by global brands to deliver seamless and personalized shopping experiences. But what truly sets it apart is its cartridge architecture—a flexible framework that lets businesses customize their storefront functionalities. 


With custom cartridges, teams can build and roll out new features quickly, respond to shifting customer expectations, and keep their e-commerce sites running smoothly as the business evolves.


In this blog, learn about Salesforce cartridges and the process of creating custom cartridges in a simple, practical way.


What is a Cartridge in Salesforce Commerce Cloud?


A cartridge in Commerce Cloud is like a building block that holds specific features or functionality for your online store. Think of it as a folder that contains code, templates, and configurations that control how parts of your website work such as checkout, product display, payment methods, etc.


Cartridges, primarily used in Salesforce Commerce Cloud and B2B Commerce Clouds, it makes easy to organize your code and customize your e-store without changing the core platform. You can stack multiple cartridges together, and the system reads them in a specific order. This lets you override or extend features as needed. This cartridge setup allows Salesforce developers to build customized, scalable eCommerce experiences on Commerce Cloud.


Why Create Custom Cartridges?


Creating a custom cartridge allows you to build what your business needs, in your own way. Here’s why it is so useful:


  1. Extend storefront features: You can add new sections like gift wrapping, custom filters, or loyalty programs

  2. Integrate external services: Connect your store with payment gateways, CRMs like Salesforce, Shipping APIs, etc.

  3. Override default SFRA behaviors: Let you change how things work in the storefront without touching the original code.

  4. Add new business logic without affecting core functionality: Create custom rules like discounts based on customer type or location.

  5. Keeps your code clean and organized: Separate your custom logic from core functionality, making it easier to maintain and grow.


How to Create a Custom Cartridge in Salesforce Commerce Cloud

Creating a custom Cartridge may sound technical to you, but it's about organizing your code in a smart, reusable way. Follow the below steps to build your own:


1. Set Up Your Development Environment


Before creating a cartridge, make sure you have:

  • A sandbox environment for SFCC

  • Access to the Business Manager (BM)

  • SFRA (Storefront Reference Architecture) setup locally

  • VS Code with SFCC extensions


2. Create a New Cartridge Folder


In your SFRA root directory/workspace, create a new folder named after your cartridge, Ex- `app_custom_blog`. This folder will hold all your custom logic, code, templates, and scripts.


mkdir app_custom_blog


3. Add the Standard Cartridge Structure


Inside your cartridge folder, add the following directories:

  • cartridge/controllers: For business logic (ex-handling checkout or product logic)

  • cartridge/scripts: For custom scripts like jobs or utilities

  • cartridge/templates: For ISML templates (your storefront views)

  • cartridge/config: For custom configurations (optional)

  • cartridge/static: For CSS, JS, and images (if needed)


cd app_custom_blog

mkdir -p cartridge/{controllers,models,scripts,templates,static}


4. Write Your Custom Logic


Add controllers or scripts to handle the specific functionality you want (ex, custom shipping rules, third-party integrations, etc).


Inside your new folder, create a controller file:

touch cartridge/controllers/Blog.js

Paste the following code inside the Blog.js:

'use strict';

var server = require('server');

server.get('Show', function (req, res, next) {

    res.render('blog/blogPage'); // This will point to your custom ISML template

    next();

});

module.exports = server.exports();

In the templates directory:

mkdir -p cartridge/templates/default/blog

touch cartridge/templates/default/blog/blogPage.isml

Add this sample ISML code:

<isdecorate template="common/layout/page">

    <isreplace name="main">

        <h1>Welcome to the Custom Blog Page!</h1>

        <p>This page is served using a custom cartridge.</p>

    </isreplace>

</isdecorate>


5. Register the Cartridge in the Business Manager


Go to Business Manager, Navigate to:

Administration > Sites > Manage Sites > (Your Site) > Settings


  • In the Cartridges field, add your custom cartridge name (`app_custom_blog`) to the beginning of the cartridge path.


Under Cartridges, prepend your cartridge like this:

app_custom_blog:app_storefront_base


  • Click Apply to save changes.


6. Test Your Cartridge

Deploy your cartridge to the sandbox, clear the cache, and test its functionality in your storefront. Navigate to the URL: 


/Blog-Show


If set up correctly, your custom blog page should appear!


How to Create Custom Settings in Salesforce?


To manage configurations dynamically, you can use Custom Preferences.


1. In Business Manager, go to Administration > Site Development > Custom    Preferences.

2. Create a new preference group and add key-value pairs.

3. Access these in your code using: Site.getCurrent().getCustomPreferenceValue('your_key')


This is useful when creating flexible cartridges that rely on admin-defined values.


How to Create a Custom Case in Salesforce?


While SFCC itself doesn’t handle Salesforce Service Cloud cases, integration is common in full Salesforce implementation projects. To create a case:


1. Use Salesforce Service Cloud.

2. Go to Cases > New Case.

3. Fill in customer details, case type, priority, and save.


A Salesforce Commerce Cloud consultant can help connect customer service systems with your eCommerce store, ensuring a seamless experience.


Conclusion


Custom cartridges are the building blocks of flexible and high-performing Commerce Cloud setup. They provide you the power to create new features, improve customer experiences, and adapt your online store to your exact business environment.


Once you understand the structure and workflow of cartridges, it becomes much easier and more appealing. With the right setup and best practices, Salesforce cartridges go a long way in growing your business.


At Cloud Science Labs, a Salesforce Cloud Consulting company, we specialize in helping brands implement, customize, and optimize their Commerce Cloud experience. From creating custom cartridges to building scalable and maintainable customizations, our team makes sure your e-commerce setup runs smoothly and delivers the desired results.


Do you need help building or improving your Salesforce Commerce Cloud store? Contact us today!



FAQs


1. How do I create a Salesforce cartridge?

To make a new cartridge, just create a new folder in your project with subfolders like controllers, templates, and scripts. Then, register it in Business Manager, and add your custom code and pages.


2. What is a cartridge in Salesforce Commerce Cloud?

A cartridge is like a building block for your website. It holds code, business logic, templates, settings, etc that help you add or change features on your storefront–no need to touch the whole system.


3. How to create custom settings in Salesforce?

You can use Custom Preferences in Business Manager. They let you create settings (like toggles or values) that your cartridge code can read and use when needed.


4. How to create a custom case in Salesforce?

In Salesforce Service Cloud, go to the Cases section. You can either add a case manually through the dashboard or use an API if you are automating it from your website or app.

 
 
 

Comments


bottom of page