# Shopware 6 Payload of order line item is not updated

**URL:** <https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675>\
**Category:** Shopware 6 (English)\
**Tags:** programming\
**Created:** [29. Juni 2021 um 09:57 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675 "2021-06-29T09:57:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuncer.damat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/tuncer.damat/32/13987_2.png) [@tuncer.damat](https://forum.shopware.com/u/tuncer.damat)\
**Post date:** [29. Juni 2021 um 09:57 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/1 "2021-06-29T09:57:41Z")

</div>

Hello guys,

I try to update a cart line item’s payload in checkout which seems ok after setting the payload of the line item, I dump the payload value and see that it was set.  
But when I create the order I can’t see that new payload key/value in related order item’s payload field.

Here is how I set the payload value in my controller:

```auto
$lineItemData->setPayloadValue('test_payload', "test value");

```

I have tried the lines below but no luck:

```auto
$lineItemData->markModified();
$cart->markModified();
$this->cartService->recalculate($cart, $context);

```

Am I missing something?  
Did anyone encounter same/similar problem?  
How can I make sure that the payload I set in cart line item is passed to order line item?

Regards

Tunçer

---

<div class="post-metadata">

**Author:** ![finngu](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@finngu](https://forum.shopware.com/u/finngu)\
**Post date:** [30. Januar 2023 um 11:38 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/2 "2023-01-30T11:38:09Z")

</div>

Same question here. Are there any updates or docs on this?

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [30. Januar 2023 um 14:18 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/3 "2023-01-30T14:18:51Z")

</div>

if i remember correctly recalculate creates a new cart. So you should do the following:

```auto
$cart = $this->cartService->recalculate($cart, $context);

```

---

<div class="post-metadata">

**Author:** ![tuncer.damat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/tuncer.damat/32/13987_2.png) [@tuncer.damat](https://forum.shopware.com/u/tuncer.damat)\
**Post date:** [31. Januar 2023 um 10:39 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/4 "2023-01-31T10:39:28Z")

</div>

What we did was setting the value in a hidden input field and then reading it via POST parameters in OrderController.

---

<div class="post-metadata">

**Author:** ![chamaw](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@chamaw](https://forum.shopware.com/u/chamaw)\
**Post date:** [2. Februar 2023 um 19:28 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/5 "2023-02-02T19:28:13Z")

</div>

right. the main „problem“ is PHP.  
when you fetch the lineItem you will a get copy and NOT a reference. So you need to replace the changed item (here you changed the payload) before doing the recalc. Anyway the same for the items you fetched from the cart.

```auto
$lineItems = $cart->getLineItems();
$productId = "abcd";
$item = $lineItems->get($productId);
// here manipulate the $item
// ...
// and then push back the item
$lineItems->set($productId, $item);
// ...
// and push the items to the cart
$cart->setLineItems($lineItems);
// ...

```

---

<div class="post-metadata">

**Author:** ![tom.free](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@tom.free](https://forum.shopware.com/u/tom.free)\
**Post date:** [12. April 2023 um 08:44 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/6 "2023-04-12T08:44:59Z")

</div>

Hi,  
unfortunately that doesnt work for me. I also tried to use

> ```
> $this->cartService->setCart($cart);
> 
> ```

on top of your suggestion to make sure the updated is reflected. However inspite of doing that in my controller in the twig template that is then loaded i still get the old values.

Any other idea?

Thanks!  
Tom

---

<div class="post-metadata">

**Author:** ![chamaw](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@chamaw](https://forum.shopware.com/u/chamaw)\
**Post date:** [12. April 2023 um 12:36 UTC](https://forum.shopware.com/t/shopware-6-payload-of-order-line-item-is-not-updated/88675/7 "2023-04-12T12:36:37Z")

</div>

you might do something like:

```auto
$lineItem->markModified();
$lineItems->set($lineItem->getId(), $lineItem);
...
// 3rd parameter as the Cart
$toCalculate->setLineItems($lineItems);
$toCalculate->markModified();

```

Another thing what is important to find the right priority in the marking of the service. Here a prio which I mostly use :

```auto
<tag name="shopware.cart.processor" priority="4950"/>

```

(I think there is a list somewhere for the chain of core-processors)
