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:
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?
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.
$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);
// ...
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.