Having nearly completed my first real Commerce project, I managed to utilize most of the features offered in Commerce 3. However, I never quite figured out what the use of a line item's snapshot is for. What is it and when would you need to use it? There isn't anything about it in Commerce's docs.


1 Answer 1


The snapshot is there so that the key details of an order are forever more available on the order record.

Imagine living with Commerce for a long time - you will of course most likely add, change and/or remove products (or variations) as time goes by.

You might simply disable ones you remove, or you might delete them. If Commerce did not have line item snapshots, old orders would refer only to these now deleted things - thus, for example, when presenting an order history view to your customers, the details would not be available and this would (at least) mean some order details could no longer be displayed accurately. And at worst, it might well cause serious errors with your templates/page rendering, if you're relying on those details being there.

Another example - prices change over time. The order snapshot shows the price at the time of the sale, not the price now - which might be substantially different.

It might even be the case that store operators are altering products actually while a customer has them in their cart and is busy making an order.

Thus the snapshot mechanism is an elegant, if perhaps poorly documented, solution to these issues.

Thus - and you're right, this should probably have its own explanation in the docs - the best practise with Commerce is to always use the snapshot details by preference once something is a line item - i.e. when dealing with carts (incomplete orders) at any point, or orders - always use the snapshot data.

Of course the snapshot doesn't have everything in it (like images etc) - so for prettier templates, you often end up with some conditional logic referring to the actual product / variant - but you must check if it is still available first, before using any data from it, and have a fall-back if it is no longer available.

  • Thank you so much for the great answer! So yeah, to be clear, basically just use the snapshot data whenever showing something that's already in the cart or when the order is completed (like in an invoice, etc). Am understanding that correctly?
    – Ryan
    Commented Jun 24, 2020 at 11:31
  • 1
    Yep, that's exactly it. Commented Jun 24, 2020 at 22:02
  • Should we really use snapshot for carts? If price of product changed after we added item to cart, our cart would show old one. But its not like we would pay old price, isnt it? I think it only makes sense to use snapshot for submitted order, am i wrong? Commented Oct 26, 2020 at 20:18
  • I think for carts, it's a choice really. If e.g. your customer has seen an old price, and you go and change that (up) during checkout, and their purchase suddenly goes up and they don't notice....they might be quite unhappy. But certainly it is mostly for the context of order records. Commented Oct 26, 2020 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.