Lightning B2B Commerce
Provide flexible and customizable shipping costs in Lightning B2B Commerce checkout process. You can mark up, mark down and apply rate cards to specific accounts.
- Prerequisites
- Configuration for Sharing Settings
- Sharing Rules for Store Guest User
- Custom Address Source for Shipping Options
- Configuration of Zenkraft B2B Settings
- Configure Shipping in Your Store Setup
- Configure the Checkout Flow
- Rebuild Your Store Search Index
- B2B Commerce Tracking
- B2B Commerce Returns
- B2B Commerce Classic (CloudCraze)
Prerequisites
Before you follow the guide, please ensure you have completed the following prerequisites:
- Installed the Multi-carrier app
- Installed the Lightning B2B app (sandbox) | (production)
- Verify with your Account Manager that you have a 'Site' license for Zenkraft
- Created a preference with your live credentials or test credentials
Configuration for Sharing Settings
To allow your Experience Cloud Store visitor Profile to access Zenkraft objects for shipping data retrieval and presentation, follow the steps below:
- Go to Salesforce Setup > Security > Sharing Settings
- Click 'Edit' on Organization-Wide Defaults
- In the 'Default External Access' column set access for these objects:
- Custom Address Source - 'Public Read-Only'
- Shipping Preference - 'Public Read-Only'
- Shipping Preference Info - 'Public Read-Only'
- MC B2B Configuration - 'Public Read-Only'
- MC B2B Log - 'Public Read/Write'
- Click Save and wait for the access re-calculation process to finish
Sharing Rules for Store Guest User (if Guest Checkout Enabled)
If you are allowing Guest access to shopping and checkout, you will need to create Sharing Rules for the Store Guest Account.
- Go to Salesforce Setup > Security > Sharing Settings
- Find the '[Object Name] Sharing Rules' entry for each of these objects:
- Custom Address Source
- Shipping Preference
- Shipping Preference Info
- MC B2B Configuration
- Click New
- Give your Rule a 'Name' and 'API Name' of your choice
- Click the radio button for 'Guest user access, based on criteria'
- Enter the 'Criteria' below for these Object sharing rules you are creating (screenshots of
completed rule criteria in Step 4 below):
- Custom Address Source: Name Field NOT EQUAL TO Null
- Shipping Preference: Shipping Preference Number NOT EQUAL TO Null
- Shipping Preference Info: Shipping Preference Info Name NOT EQUAL TO Null
- MC B2B Configuration: Disabled EQUALS False
- Select your Store Guest User account for 'Share With'
- Select Read Only access
- Click Save and wait for the access re-calculation process to finish
Custom Address Source for Shipping Options During Checkout
Next you need to create the Custom Address Source (CAS) to reference the information on the Cart object in order to retrieve and display shipping rates for the Cart and Checkout pages in your Experience Cloud Store.
1. Setup > Object Manager > find the Shipment object (zkmulti__MCShipment__c) and add a Lookup to the Cart (WebCart) object in a manner similar to the instructions here.
2. Go to the Custom Address Sources object and create a new CAS. Give the CAS a descriptive name like "My B2B Site Cart"
3. In the Object selection click the 'View all objects' checkbox, then then find the Cart (WebCart)
object lookup you created in Step 1
NOTE: If the "All Objects" checkbox is not available you need enable it under
CAS_VIEW_OBJECTS
in Zenkraft Other Settings.
4. Scroll down and fill in the Packages section as shown here if you want each Cart item to
ship in its own box - the Child Object collects all the items that are in the Cart to specify
what
is being sent.
NOTE: If your CartItem has a Weight field, use that instead.
5. Next you can set the standard fields for service types and packaging as shown here.
You can set
these values by using the Static Value button, entering the exact text shown above without the
brackets [ ]
7. Occasionally the carrier servers might have a maintenance window or traffic issues where they no longer return rates. Zenkraft has devised a solution for these occurrences so that the checkout process does not fail: you can specify a timeout on the CAS that tells the system the number of milliseconds to wait for an API request to return from the carrier before switching over to Fallback Rates.
To set the Timeout for shipping data retrieval, expand the Enhanced Functionality Settings
section
and start to type All Carriers: Callout Timeout into the search box, then select that option
from
the list.
Click the magnifying glass icon next to this option and enter a Static Value for the
timeout in milliseconds. The example below shows a timeout of 5 seconds. (The configuration of
Fallback Rates is detailed in the next section)
8. Your CAS for the Checkout process is now complete - scroll back to the top of the form and click Save. The next step is setting up the Zenkraft B2B Settings.
Configuration for Zenkraft B2B Settings
1. In the App Launcher, search for and choose the Zenkraft B2B Settings tab
2. First, click on the Post Install Action sub-tab and register the Zenkraft Apex Classes that
will be used in the Store settings to allow our solution to handle Shipping Options.
Click on each button to register the Zenkraft Classes.
After the classes are registered, they should appear in the list above the buttons. No need to
click Save for this step.
3. Go to the B2B Carrier Settings sub-tab and enable the carriers that will be used for shipping options. Later you can disable these carriers at will (for instance, to turn off options for a carrier that is not part of a 'Free Shipping' promotional period)
4. Go to the B2B Rate Settings sub-tab, click the Enabled selector, and choose the
"Cart" Custom Address Source that you have created.
5. Define the Rate Option Format. In this setting you can select which values you want to display on your checkout page. The default rate format is {serviceType} - {deliveryDays} {dayLabel} - {currency}{rate}. You can use the following options:
- {serviceType} - displays the service type Checkout Display Name, or if not configured then its API value
- {deliveryDays} - the estimated number of days it takes to deliver the shipment
- {dayLabel} - will write "days"
- {rate} - the quoted cost of the shipment (including any margins)
- {currency} - the currency of the quoted price
- {estimated_date} or {estimated_date:DATE_FORMAT} - provides the estimated date of delivery, where DATE_FORMAT follow the guidelines described in this guide. For example {estimated_date:d MMM} (4 Jul).
6. Configure the Rate Cards.
You will always have a "Default" Rate Card that you can set up with carriers and services as you see
fit.
Alternatively, you can create more rate options per your needs. In the screenshot you can see that
we are setting FedEx Ground as being Free from Shipping costs - if you need to add new options, or
edit existing entries, use the buttons highlighted below:
Once you create/edit a Rate option you can specify the Carrier, the Service Types to
include/exclude, and the rate modifying options for:
- Free - the shipping cost is set to 0
- Fixed - means that you can add a standard margin amount to the base shipping charge from the carrier
- Percentage - works along the same lines as Fixed, but instead of a fixed increase, you can add a percentage on top of the shipping charge. (So if shipping was $10 and you put a Percentage = 20, then the user would see $12 as the shipping cost)
In the screenshot below you can see that we have set the price to be an extra $15. If you do not
want to
add any margin, choose this option and set it to 0.
7. The Rate Card system allows you to provide different shipping options / rates for specific situations or customers (for example only 'Premier' Accounts get FREE Overnight Shipping)
- Create a new Rate Card using the plus (+) button and give it a unique "Name"
- In the example of Account-specific rates, you would need a field on your Account object that indicates the "Name" of the Rate Card to use
- Click the magnifier icon next to Rate Card Name Field to map this indicator by walking the object hierarchy from Cart > Account > [Field Name]
- Now any Account with the [Field Name] filled in with Rate Card "Name" will get shipping rates specific to
8. Under the Service Type Options sub-tab you can change the
display name of each service type and disable the ones you do not want to use.
You will also notice that the Fallback Text is available for you to set, allowing you to
display
hard-coded shipping options in case the carrier servers time out when your site makes a request.
9. Click on Save at the top of the page to register these settings in Salesforce
10. In the B2B Rate Advanced Settings sub-tab, you can choose a sort order for display of
shipping options. Remember to click Save at the top of the page to register your choice.
Configure Shipping in Your Store Setup
Go to your Store settings to add our integration or extension to manage retrieval and presentation of Carrier service levels and rates for Shipping during the Checkout process.
1. First, get to the administrative setup section for Shipping in your Store
- New Commerce App: Select your Store from the drop list, go to the Checkout
Configuration section, select the Shipping sub-tab
- Old Commerce - Admin / Console App: Go to the Stores tab, select the record for your
Store, open the Administration link, go to Shipping Calculation section
2. In the Shipping setup form set up the Providers - General Shipping Profile section
according to the needs of your storefront and customer base (consult Salesforce docs for more guidance
on this).
Configure required Processing time and Zones, you do not have to configure Rates in
this section.
3. Scroll down to the Custom Providers - Shipping Calculationsection
- For sites configured to use Integrations click on Link Integration
In the popup that appears choose the aligned integration handler:- B2B Commerce Store site: B2B Calculate Shipping
- D2C Commerce Store site: B2C Calculate Shipping
- For sites configured to use Extension Providers click on Select Provider
In the popup that appears, choose MCB2BShippingCalculator
4. Click Next and then on the following screen click Confirm
Configure the Checkout Flow - Aura-Based Lightning Commerce Sites Only
An Aura-based storefront will need to be configured to utilize our Checkout Flow by modifying the associated Experience Cloud site.
1. Go to the Experience Builder site for your Store.
- New Commerce App: Click on the Website Design link
- Old Commerce - Admin / Console App: Click on the Experience Builder link
2. Select Checkout from the site Pages drop list
3. Click on the Flow widget that should be in place on the Checkout page
4. Choose flow MC Checkout Flow on the configuration form
6. Click the Publish button and wait for the site to be re-built
Rebuild Your Store Search Index
If you want to show the tracking information on your order detail page please follow these steps below:
1. Go to Store Setting to rebuild the Store search index.
- New Commerce App: Go to the Search section
- Old Commerce - Admin / Console App: Click on the Search link
2. On the Search Index Summary section, click on the Rebuild Now button, then choose to do a Full
Reindex
on the popup that appears
3. Back on the Search Index Summary, you will see an entry on the Rebuild Log indicating that your index is in the process of being rebuilt - wait several minutes and hit the Refresh Status button, eventually you will see a green check mark indicating that the rebuild is complete.
B2B / D2C Commerce Tracking
If you want to show the Tracking Status on your Order detail page, please follow these steps below:
1. Add class MCB2BOrderService to Guest/Community Profile(s)
2. Create new Text fields on Order Summary Object, e.g. Tracking Number (api name: Tracking_Number__c) and Tracking Stage (api name: Tracking_Stage__c)
3. Go to Order Summary page, create new List View (e.g. Tracking List View)
- Go to Experience Builder and choose Order Summary
- Select Order Summary List Page
- Choose list component, set Filter Name as 'Tracking List View'
4. Go to Experience Builder, choose Order Summary -> Order Summary Detail Page
5. Add the following component to the page:
Order Summary Tracking Details.
Configuration
- Tracking Number Field as Tracking_Number__c (from step #2)
- Tracking Stage Field as Tracking_Stage__c (from step #2)
- Show Tracking URL (Branding Tracking URL)
6. Publish Changes
7. Guest Community Profiles: add access to the fields you created earlier: Tracking_Number__c/Tracking_Stage__c
B2B Commerce Returns
If you want to show a return button on your order detail page please follow these steps below:
- Add class 'MCB2BOrderService' to Guest/Community Profile
- Create new Checkbox field on Order Summary Object, e.g. Show Return Button (api name: Show_Return_Button__c)
- Go to Order Summary page, create new List View (e.g. Tracking List View)
- Go to Experience Builder, choose Order Summary -> Order Summary List Page
- Choose list component, set Filter Name as 'Tracking List View' - Go to Experience Builder, choose Order Summary -> Order Summary Detail Page
- Add the following components to page:
Order Summary Create Return Shipment
Configuration:
- Show Return Button as Show_Return_Button__c (from step #3) - Publish Changes
- Guest Community Profiles: add access to the fields you created earlier: Show_Return_Button__c
Next you need to create the Custom Address Source for a return shipment and also the related Process Builder or Flow to create the return label and another one to email the label to the user.
Custom Address Source
You need to create a Custom Address Source to map the values from your Order Summary into the carrier values. We have a guide on how the custom address source works here. We have also created a template of the custom address source that you can import. The link for the custom address source can be found here.
Once you have set up the Custom Address Source please copy the salesforce ID for it as it will be required in the next step.
Process Builder for Return Shipment Creation
Go to Setup > Process Builders and create a new Process Builder.
Under the object choose "Order Summary", and in the criteria select the field called Create Return Label.
Next in the immediate action select "Apex" and the Apex class "Create Shipment (Multi Carrier)". It sometimes times a while for the items to appear, so please be patient (it can take 3-4 minutes).
The customAddressId is the Salesforce ID of the Custom Address Source you created in the previous step.
The recordID is the Order Summary ID.
Make sure you save your Process Builder and you should now test that this works as expected.
To test please requests a return from the storefront order detail page. A new shipment should be created related to the Order Summary.
Please look at the APEX Logs to see if there are any errors. If you need assistance, please contact us.
Process Builder for Emailing the Label
Once the shipment has crated successfully, we want to send the email to the client. We do this using a process builder/flow. We will show you using the process builder.
Create a new Process Builder and select the Shipment object, and choose "Only when a Record is Created".
Under the criteria, make sure you set the filter to look for shipments that are of type Return.
Next set the process to run on a schedule, 0 hours after creation. We do this so that the shipment creation has time to save the labels to the object.
Now you can set extra values such as a send to email (otherwise we will use the recipient email address on the shipment object), and you can also set an email template to use, and you can set the emailTemplateID section. To use this email template ID make sure that the template is built with merge fields from the Shipment object.
Don't forget to save your process builder and to active it. If you need assistance, please contact us.