Commerce Server – Cart not persisting

So I was trying to get add the ‘add to cart’ functionality to my website. Basically I would get the cart, then create a cart line based on the product and add that to the cart object:

var cartLine = new CommerceCartLine(product[CommerceConstants.KnownFieldIds.CatalogName], product.Name, null, quantity); // null because I don't currently support variants.
var cart = GetCart();
var request = new AddCartLinesRequest(cart, new[] { cartLine });

And while I was stepping through the code I could see the cart being updated. The only problem was after a reload (or after adding another product to the cart) the cart would be empty again.

At first I thought the problem was my code, but no matter what I changed, it didn’t seem to get any better. I figured I’d better check the Commerce Server Customer and Order Manager tool to find out what was happening to my baskets, and it was there that I found the issue. It turns out that by default the Customer and Order Manager wants to have the Profiles webservice and the Orders webservice to run in https mode. As I was working on my local development environment that wasn’t really much of an option, so I had to figure something else out. Luckily I found a blog post on MSDN which explains what to do.

In short: There’s a CustomerAndOrdersManager.exe.config file, in the install directory of Commerce Server (by default C:\Program Files (x86)\Commerce Server 11\Business User Applications) . In the <applicationSettings> you’ll be able to find the setting “AllowHTTP” which is set to False by default. Set it to True, recycle the app pool and you’re in business!

<setting name="AllowHTTP" serializeAs="String">


Hidden settings: MinimalProfileScoreCount

I was running through the Sitecore Experience Editor the other day, where I wanted to check whether my various patterns would be showed the correct personalized content. The easiest thing to use is the Experience Explorer, which you can get to through the Other button in the Mode chunk.

Opening the Experience Explorer

This will open the Experience Explorer on the left-hand side of the website with the Experience Viewer on the right-hand side. In the Onsite Behavior tab I set the proper scores to match a particular pattern card. After clicking ‘Apply’ I didn’t see any difference until I checked the Onsite Behavior tab in the Experience Viewer.

Experience Viewer

Easily managed by just clicking ‘Apply’ 2 more times, but a bit annoying. Turns out, there’s a way of going around this: The Analytics.Patterns.MinimalProfileScoreCount setting. By default it won’t show up in your settings so you’ll have to manually add it. After applying this setting the profile personalization will be applied directly after setting the value of Analytics.Patterns.MinimalProfileScoreCount to 1.

Before you change it though, keep in mind that this will not only affect the Experience Explorer, but also the ‘normal’ website – and as such might have adverse effects.

Quick tip: Sitecore Security packages

If you ever want to move Sitecore items over to different environments the easiest way to do this is to create a Sitecore package. This is no different for Sitecore Users and Sitecore Roles. After opening the Package Designer, click the ‘Security Accounts’ button in the ribbon.

The package designer screen

Using the pop-up, you’ll be able to view which roles/ users you have in your package, or add/ remove them using the buttons. Clicking the Add button will pop up another window, which allows you to select your users and roles.

Adding roles and users

After you’ve created your package you can install this on your other environment, using the Package Installer. If the users or roles already exist you’ll get a message that Sitecore will skip the installation of that user or role.

Roles are now all ready for use. Users however need two additional steps to be active:

Firstly, they need to be activated.

Sitecore User Manager showing disabled users

As you can see, in the Locked column, they’ll show up as Disabled. To enable the users the Enable button in the ribbon can be used.

Secondly, the users need their password to be reset. Do this using the Change Password button.

The Reset Password popup

Clicking ‘Generate’ will randomly create a new password, which you can then select and copy to the Old Password field. Fill in the new password, and you’ll be ready to go!