# B2B Commerce LE on Scratch Orgs (Winter '21) for Windows WSL

Now that SF B2B is also offered natively (as opposed to as a managed package), it will be possible to take advantage of scratch orgs for faster development or demo purposes. Here is how.

NOTE: These are instructions for the forked version of the b2b-commerce-for-lightning project, adapted to WSL.

# Requisites

  • SFDX installed
  • You have a devhub, and it's been authorized in your computer (you can even use a Traihead Org as a devhub!) <-- TIP: the command to authorize an org is sfdx force:auth:web:login -d
  • Your IDE of choice (I use VS Code)

# Steps

# Pre-flight:

  1. Clone this repo
  2. Open a WSL terminal window and change to the "sfdx" folder to where the repo was downloaded
  3. Run the project conversion script /convert-examples-to-sfdx.sh
  4. List available orgs: sfdx force:org:list --clean
  5. Set the default devhub: sfdx force:config:set defaultdevhubusername=<DEVHUB USERNAME>

# Creating the scratch org:

  1. Create an empty scratch org with a username of your choice (e.g. b2b54chi@salesforce.scratch01) : sfdx force:org:create -f config/project-scratch-def.json username=b2b54chi@salesforce.scratch01 -s -d 30
  2. Confirm that the scratchorg created was set as the default org. If it is not, you can set it using sfdx force:config:set defaultusername=b2b54chi@salesforce.scracth01 (this command is also useful to open a different scratch org if needed)

# Optional: going all the way:

  1. Push the code changes: sfdx force:source:push -f. This will deploy the sample integrations (Lightning Flow and classes)
  2. Create a store/community (e.g. 54chi01): sfdx force:community:create --name "54chi01" --templatename "B2B Commerce" --urlpathprefix "54chi01" --description "Sample store 54chi01 created with SFDX"
  3. Deploy the rest of the metadata: ./quickstart-setup-store.sh 54chi01
  4. Open the org: sfdx force:org:open
  5. Go to the Commerce app, select the store and refresh the Search Index.
  6. Go to the Contact view, open the generated contact and from the dropdown, select "Login As Customer". You should see a storefront up and ready for you to use.

# Additional useful commands

  1. To open the default org: sfdx force:org:open
  2. To delete a scratch org: sfdx force:org:delete -u <SCRATCH ORG USERNAME>

# Reference

  • https://github.com/forcedotcom/b2b-commerce-on-lightning-quickstart