Search code examples
shopwareshopware6

Payload vs Custom field on LineItemEntity


The LineItemEntity in Shopware has a payload field and a customFields field. Both are of the type JSON. When should one use payload for storing data and when customFields?


Solution

  • payload is populated when the line item is still in the cart, so before an order has been placed and is kept when the cart is converted to an order. For instance the property contains meta data of the original product and may be used to store such data that is used across the checkout. The payload ideally shouldn't be changed after the cart has been converted to retain the original state of the order.

    customFields contains the system specific custom fields that can either be populated by api or the administration. They can be used to attach data after an order has been placed. Custom fields should be properly created first.