Get the guide: Ship 10x faster with visual development + AI

Announcing Visual Copilot - Figma to production in half the time

Builder.io logo
Contact Sales
Platform
Developers
Contact Sales

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

Quickly connect your SalesForce B2C Commerce API to your Builder content.

To get the most out of this document, make sure:

Setup Salesforce Commerce API Access: visit the Salesforce guide, Setup API Access, to make sure you already have your Shopper Login and API Access Service (SLAS) client setup.

On any Builder Space:

  1. Go to Plugins.
  2. On the Salesforce B2C Commerce API integration, toggle the switch to the On position.
  3. The browser should refresh the page; however, you might have to do it manually. Once refreshed, the toggle is set to on and you should get a prompt to configure the plugin. Click Configure button.
  4. In the modal that opens, you'll be prompted to enter the Client ID and password, library name, API path, preview library name (optional), and the preview path (optional).
  5. Click the Connect button.

The screenshot below shows the SFCC plugin modal:

Salesforce configuration modal with a form where you put in your salesforce info.

Tip: If you're using Salesforce's Composable Storefront kit, refer to the configuration in your config/default.js file.

Custom targeting attributes

Custom targeting in Builder.io allow users to target content by a multitude of attributes, and in this plugin you'll be able to add specific content from SFCC products, for this you'll need first to set the target attributes on the host site, either by setting the userAttributes if you're rendering client side:

With custom targeting in Builder, you can direct content according to a wide array of attributes. With the Salesforce Commerce API plugin, you can seamlessly integrate SFCC product details into your targeting criteria. Here’s how to set up:

  • Client-side rendering: To fetch content specifically for a product on its detail page, utilize the builder.get function with userAttributes set to the product ID:
// example for fetching content specific for a product in a product details page
const productFooterContent = await builder.get('product-footer', {
  userAttributes: {
    product: product.productId,
  }
})
  • Server-side Rendering or API Requests: Pass the targeting attributes as a query parameter to your content API call or include them in your GraphQL query, as demonstrated in frameworks like Gatsby or Next.js.

For more details, visit the Content API documentation.

When you install the plugin, you can use specific SFCC data types as inputs for your custom components. These types enhance the interactivity and specificity of your components within the Visual Editor:

  • SFCommerceProduct: this input type allows the selection of an individual product, enabling the component to access and display product-specific information.
  • SFCommerceCategory: select a specific category to tailor content or retrieve an array of products within that category directly in your component.
  • SFCommerceProductsList: enables the selection of multiple products, ideal for creating product grids or list displays within your component.
  • SFCommerceCategoriesList: allows multiple category selections, useful for broader content targeting and display.

Example: Custom Component Configuration

Consider a custom component named ProductBox which integrates an SFCommerceProduct. Here’s how you might register it within Builder.io:

import React from 'react';
import { Builder } from '@builder.io/react';
import ProductBox from './ProductBox'; // Your custom component

Builder.registerComponent(ProductBox, {
  name: 'ProductBox',
  image: 'https://unpkg.com/css.gg@2.0.0/icons/svg/box.svg',
  inputs: [
    {
      name: 'productRef',
      friendlyName: 'Product',
      type: 'SFCommerceProduct',
      required: true
    }
  ]
});

For more details, visit Builder's SFCC Composable Storefront example on GitHub.

When fetching content from Builder, the includeRefs=true option fetches detailed data linked to specific references, such as an SFCommerceProduct, facilitating server-side rendering:

const page = await builder.get('page', {
  url: '...',
  options: {
    includeRefs: true
  }
});

Ensure this option is also enabled during the editing phase to automatically resolve data for your components:

<BuilderComponent model="page" options={{ includeRefs: true}} content={page} />

For more information on the available options, visit the Content API documentation.

With the SFCC plugin installed, you can create custom models, components, and symbols using any of the SFCC field types and edit as needed.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Newsletter

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy

Product

Visual Copilot

Visual Headless CMS

Integrations

What's New

Open Source

Builder

Builder

Mitosis

Mitosis

Qwik

Qwik

Partytown

Partytown

Popular Guides

From Design to Code Ebook

SaaS Marketing Site Ebook

Composable Commerce Ebook

Headless CMS Guide

Headless Commerce Guide

Design to Code

Resources

Blog

Knowledge Base

Community Forum

Partners

Performance Insights

Templates

Success Stories

Showcase

Resource Center

Frameworks

React

React

Next

Next.js

Qwik

Qwik

Gatsby

Gatsby

Angular

Angular

Vue

Vue

Svelte

Svelte

Remix logo

Remix

Nuxt

Nuxt

Hydrogen

Hydrogen

© 2024 Builder.io, Inc.

Security

Privacy Policy

SaaS Terms

Security & Compliance

Cookie Preferences