<p>The snapshot is there so that the key details of an order are forever more available on the order record.</p>
<p>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.</p>
<p>You might simply disable ones you remove, or you might delete them.  If Commerce did <em>not</em> 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.</p>
<p>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.</p>
<p>It might even be the case that store operators are altering products actually <em>while</em> a customer has them in their cart and is busy making an order.</p>
<p>Thus the snapshot mechanism is an elegant, if perhaps poorly documented, solution to these issues.</p>
<p>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.</p>
<p>Of course the snapshot doesn't have <em>everything</em> 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.</p>

CC BY-SA 4.0
2020-06-24T11:31:28.630Z
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
CC BY-SA 4.0
2020-06-24T22:02:18.117Z
Yep, that's exactly it.
Jeremy Daalder
CC BY-SA 4.0
2020-10-26T20:18:45.953Z
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?
Piotr Pogorzelski
CC BY-SA 4.0
2020-10-26T21:21:48.753Z
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.
Jeremy Daalder
CC BY-SA 4.0
2020-06-24T01:32:42.673Z
2020-06-24T01:32:42.673Z
Jeremy Daalder
<p>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.</p>

CC BY-SA 4.0
2020-07-02T13:44:50.610Z
Update inspired by your question and Jeremy’s answer here: https://docs.craftcms.com/commerce/v3/purchasables.html :)
Matt Stein
CC BY-SA 4.0
2020-07-02T18:22:29.470Z
Thanks, Matt!!! I hope this helps others in the future :)
Ryan
<plugin-craftcommerce><plugin-craftcommerce2><ecommerce><plugin-craftcommerce3>
Commerce: what is the purpose of a line item's snapshot?
# Commerce: what is the purpose of a line item's snapshot?

(Asked by: username_0 on 2020-06-23)

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.

**Tags:** plugin-craftcommerce, plugin-craftcommerce2, ecommerce, plugin-craftcommerce3

> **Comments:**
> **username_1**: Update inspired by your question and Jeremy’s answer here: https://docs.craftcms.com/commerce/v3/purchasables.html :)  
> **username_0**: Thanks, Matt!!! I hope this helps others in the future :)  

---

## 1 answers

### Answer by username_2 on 2020-06-24. Score: 6 | Accepted answer

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.

> **Comments:**
> **username_0**: 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?  
> **username_2**: Yep, that's exactly it.  
> **username_3**: 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?  
> **username_2**: 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.  

---

