Skip to content
Log in

Show a Salesforce field on the storefront

On this page

Use this process when you know the Salesforce field you want and need the Liquid that renders it. It works in the other direction too: given an attribute in a template, it tells you which Salesforce field feeds it.

Two things make this harder than it looks, and both have a fixed answer:

  • A Salesforce object and its Liquid object have different names. Product2 is product in a template, and s_c__Product_Category__c is product_category. Writing the Salesforce name in Liquid returns nothing.
  • The field name changes too. s_c__Display_Name__c is product.name. It is not a predictable transformation, so it has to be looked up.

Decide which case you are in

Before writing any template code, establish which of two situations applies. They have completely different answers.

Situation What you need
The field ships with StoreConnect (its API name starts s_c__, or it is a standard Salesforce field) Nothing. It is probably already on the drop. Look up the attribute.
You added the field yourself in Salesforce A Custom Data Mapping record, then read it from the drop’s data attribute

If you are not sure, check the object’s field reference. Every field listed there ships with the package.

Look up a field that ships with StoreConnect

  1. Open the object reference for the Salesforce object. If you do not know which article that is, find it in custom objects or standard objects.
  2. Go to the On the storefront section at the end of the article. It names the Liquid object that renders this Salesforce object, and the variable a theme writes.
  3. Find your field in the Salesforce field column. The Liquid attribute column is the code you write.

For example, on Product2 the On the storefront section gives:

Salesforce field Liquid attribute
s_c__Display_Name__c product.name
s_c__Slug__c product.identifier, product.slug

So the display name renders as:

```liquid

{{ product.name }} ```

If the field is not in that table, it is still likely available. The table lists fields read straight from Salesforce; a drop also exposes derived values such as product.can_purchase?. Check the Attributes table on the Liquid object’s own article, reached from the same section.

:::note Some objects are rendered by more than one Liquid object. Media is reached through five, including image and video, and Account through three, including brand. The On the storefront table qualifies each attribute with its variable so it is clear which one to use. :::

Working the other way

Given an attribute in a template and needing the Salesforce field behind it, use the mirror of that section. Open the Liquid object’s article and read Backed by, which names the Salesforce object and lists each attribute against the field it reads.

This is the faster direction when debugging a value that looks wrong, because it tells you exactly which field to inspect on the record.

Add a field you created yourself

A field you added in Salesforce is not on the drop, and no amount of template code will reach it until it is mapped. The route is:

  1. Create a Custom Data Mapping record for the object and field, with the access level you need.
  2. Wait for the backfill to finish. Adding a mapping triggers one, and the field reads blank until it completes.
  3. Read the value from the drop’s data attribute, keyed by the field’s API name.

```liquid

{{ product.data[‘field_1__c’] }} ```

Note that the object is product, not Product2, and the key is the Salesforce field API name. The On the storefront section gives the variable to use.

Add custom data fields to your store is the full procedure, including compound fields, multi-picklists, write-back, and the performance advice on batching mappings.

:::warning A mapping alone does not make a field readable in a POS template. The POS downloads a fixed set of columns per object and adds a mapped field only when a POS Layout references it. See Verify custom data is available in Liquid. :::

Confirm it worked

Render the attribute on the page or template you expect it on. The value should match the field on the record in Salesforce.

If it renders blank, the cause is almost always one of three things: the wrong Liquid object name, a mapping whose backfill has not finished, or a POS layout that does not reference the field. Verify custom data is available in Liquid lists the keys a drop actually holds, which settles it quickly.

Was this article helpful?

Was this article helpful?