Take the community feedback survey now.

Quan Mai
Jan 17, 2018
  4592
(9 votes)

CartHelper is dead, long live IOrderRepository

As a framework provider, we take backward compatibilities seriously, and we keep supporting public APIs as long as it makes senses. If we can improve our framework by changing the internal implementation without having to change the singatures, we'll go with that.

But sometimes, to improve, we need to leave old APIs behind.

CartHelper is one of the oldest APIs in Episerver Commerce framework, and while it's convenient to use, it has several major drawbacks:

  • It ties to other "legacy" APIs, such as Entry, which are less then elegant to use .
  • It is tightly coupled with the concrete implementation (Cart, OrderForm, etc.), so it's impossible to switch to the new serializable cart mode for better performance. 
  • It is hard, if not impossible to unit test.
  • It always creates new carts if none exists, even if you don't really need them

We already introduced the new abstraction APIs - IOrderRepository, IOrderGroup, ICart... from Commerce 9.19, and fully recommend to use those new APIs to handle carts and orders. New abstraction APIs solves all of the problems above, and yet you have nicer, better looking code. There is no reason to keep using CartHelper now.

In Commerce 11.6.1, we push the recommendation further. CartHelper is now obsoleted and will be removed in a forseeable future - it will be removed in the first major release after Jan 2019.

As always, you should move away from obsoleted APIs, instead of ignoring the warnings with #pragma directives. For CartHelper, the migration path is clear, IOrderRepository is simply the better, future-proof way to go.

CartHelper is dead, long live IOrderRepository!

Jan 17, 2018

Comments

Please login to comment.
Latest blogs
Trigger DXP Warmup Locally to Catch Bugs & Performance Issues Early

Here’s our documentation on warmup in DXP : 🔗 https://docs.developers.optimizely.com/digital-experience-platform/docs/warming-up-sites What I didn...

dada | Sep 29, 2025

Creating Opal Tools for Stott Robots Handler

This summer, the Netcel Development team and I took part in Optimizely’s Opal Hackathon. The challenge from Optimizely was to extend Opal’s abiliti...

Mark Stott | Sep 28, 2025

Integrating Commerce Search v3 (Vertex AI) with Optimizely Configured Commerce

Introduction This blog provides a technical guide for integrating Commerce Search v3, which leverages Google Cloud's Vertex AI Search, into an...

Vaibhav | Sep 27, 2025

A day in the life of an Optimizely MVP - Opti Graph Extensions add-on v1.0.0 released

I am pleased to announce that the official v1.0.0 of the Opti Graph Extensions add-on has now been released and is generally available. Refer to my...

Graham Carr | Sep 25, 2025