Creating Custom Pricing for B2B Customers in Sitecore OrderCloud Portal

In this post, we’ll discuss defining your buyer-customers companies and how you can provide certain companies with better pricing on products.

A common scenario would be having anonymous or standard customers who receive the standard pricing for a product. Then, you have a logged-in buyer-user assigned to a company, which you define as a “large-volume” customer, for whom you want to offer better pricing on your products, like a 10% discount, etc.

In this post, I’ll be using my Vercel Marketplace that I set up with this video guide from Sitecore: https://www.youtube.com/watch?v=3bHgafJShGM

Setting up a buyer

The most common way to set up “companies” in Sitecore OrderCloud is to make them as individual Buyers. This is so that you can set elevated roles on the buyer if needed.

Go to the API Console in your OrderCloud portal: https://portal.ordercloud.io/console

Go to Buyers, change the request to POST Create a new buyer, and set the desired company name, a Default Catalog ID and Active to true, then press Send. This should return a 201 with some additional information about the company, like its assigned ID, etc. You’ll need that ID going forward.

In this case I only have 1 catalog. If I don’t set a Default Catalog ID, OrderCloud will create a new one for this company. Since I don’t want that I’ll set the Default Catalog ID

Setting up a User

Next, you want to set up a User in that company. So, go to Users and set the request to POST Create a new user.

Fill in the required fields for the user, as seen in the image, and the Buyer-ID should be the ID you got when creating the company in the previous step.

Setting up a Security Profile

If you already have your security profiles defined, you can skip this. Otherwise, go to Security Profiles, and here I’ve created a profile called Logged-in Shopper. This could be defined however you want. Maybe one Security Profile per company, etc.
Here, I’m just going with a general approach for now, and I’ve given it some standard shopping and buyer roles.

Now lets assign this profile to our company so all it’s users get the roles we’ve setup. Stay on Security Profiles and shut off the Enhanced UI (the thunder icon).

Change the request to POST Create or update a security profile assignment

Set the ID of your Security Profile, in my case the ID of Logged in Shopper, in the “Security Profile ID” and the ID of my company in “Buyer ID” and SEND.

Now we should have a new company, a user tied to that company and set roles for that company and it’s users.

Create Price-Schedules

Normally I would create my product first then the Price schedules. But since I would be jumping back and forth, I’ll start by creating the price schedules for a product called “Baseball“.

I’ll create two price schedules. One for the standard price, which goes for 5.99, and one for my buyer, which costs 3.99, as you can see below.

Create a product

Go to Products and make a POST Create a new product.

Fill in the required info and what else you want and make it active. In the DefaultPriceScheduleID, you want to set the ID of the standard price schedule, the one for 5.99.

Before we make the price schedule assignment we need to assign our new product to a catalog. Otherwise we’ll get an exception 🙂

So go to Catalogs and put in your catalog Id and your product Id for the new product. When we created our buyer/company we set the default catalog Id. It should be the same Id here in this case.

Now we want to make a price schedule assignment with the Product ID and our Buyer ID. This can be done like in the image below.

Lets review

Here’s what we’ve done:

  1. Set up a Buyer
  2. Set up a User
  3. Set up a Security Profile
  4. Create Price-Schedules
  5. Create Product
  6. Assigned Product to Catalog
  7. Assign Price-Schedules

It’s time to see it in action.
Let’s get the product as an anonymous user by switching my user context to an anonymous shopper – a user that has no connection to any company.

Then go down to the “Me and My stuff” section and call the “My Products“. As you can see in the JSON response, the Price is 5.99.

Now lets do the same, but as a context user that belongs to our company – the one we created at the beginning of this post.
Then, do the same request in “My Products” to see if the price has changed to 3.99. This is because OrderCloud will give me the appropriate price schedule from the buyer user.

Thanks for reading and hope this helps!
If you like, you can check out my Youtube version of this blogpost – https://www.youtube.com/watch?v=AnU6aBTiL_Y

Resources

https://ordercloud.io/knowledge-base/same-product-multiple-price-schedules

https://ordercloud.io/knowledge-base/catalog-visibility-rules

https://ordercloud.io/knowledge-base/product-visibility

Thanks to the OrderCloud team on Slack

Next.js Vercel – OrderCloud Storefront: Installation troubleshooting guide

I was following this amazing video guide from Rob at Sitecore on how to setup Vercel Next.js commerce site with OrderCloud integration. You should check it out for a fast and easy start with OrderCloud and and Vercel.

When I followed the video guide I got a lot of errors on some steps when setting it up locally. This is just because we all have different machines, versions running etc. So nothing unusual.

But I thought I’d do a blogpost about the errors I found during the installation process so it might help anyone else if they get stuck in the process following the guide to setup a Vercel project with OrderCloud.

Note

You shouldn’t just trust someone who says you should run terminal commands you don’t know what they do. Same goes for me. Therefore I’m linking to all the official sites on each step. If you’re still unsure talk with someone in your organization.

  • If you get the same error and did the solution, try restarting your terminal as this is required for some operations.
  • Run terminal as administrator

Let’s start

1. npm i -g vercel

npm i -g vercel doesn’t work.

Check your node version. It needs to be the same as in your Vercel project. Go to Settings -> General and scroll down to the section Node.

  • In your terminal in the project root. Run node -v
  • I recommend installing nvm – Node Version Manager. This makes it so you can have multiple node versions installed and you can switch between the different versions in your terminal like in the image below. (Link: https://github.com/nvm-sh/nvm)

If you’ve installed nvm check your node versions by running nvm list. If you don’t have the version in nvm list that you need. You can install LTS (Long term support) or a specific version like this:

  • nvm install –lts
  • nvm install 18.15.0

Then refer to the image above on how to switch between node versions. You should now be able to run npm i -g vercel as in the video guide.

2. vercel link

vercel link throws this error:
vercel : File C:\Program Files\nodejs\vercel.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

Run this command then restart your terminal (Can’t run command? Are you running terminal as administrator?):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

(Link to Microsoft explanation on Set-ExecutionPolicy https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.3)

Now try again running vercel link

3. exec: “pnpm”: executable file not found in %PATH%

When trying to run npm run dev you get this error?
exec: “pnpm”: executable file not found in %PATH%

You need to run this command to install pnpm (Link to pnpm https://pnpm.io/installation)

iwr https://get.pnpm.io/install.ps1 -useb | iex

4. command (<path>\packages\spree) pnpm run dev exited (1)

If you still get errors even after installing pnpm in previous step.

Run pnpm install in this context to install it to your repository.

Conclusion

After these steps I had my Vercel project running locally.

Hopefully someone stuck on any of these problems find their way here.

Good luck!