Skip to content

[5.x]: InvalidConfigException when calling toArray() on custom line item #4337

Description

@jmauzyk

What happened?

Description

Getting the following error when calling toArray() on a custom line item:

yii\base\InvalidConfigException: Cannot get a purchasable for a custom line item in /var/www/html/vendor/craftcms/commerce/src/models/LineItem.php:838

Steps to reproduce

  1. Create a custom line item object.
  2. Call toArray() on the line item object.

Expected behavior

Return a serialized representation of the custom line item object.

Actual behavior

Throws an InvalidConfigException.

Craft CMS version

Craft Pro 5.10.10

Craft Commerce version

5.6.7

PHP version

8.2.30

Operating system and version

Linux 6.12.76-linuxkit

Database type and version

PostgreSQL 14.20

Image driver and version

Imagick 3.8.1 (ImageMagick 7.1.1-43)

Installed plugins and versions

No response

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions