Error: NotNormalizableValueException when normalizing Price object in cart ajax request with variations add-on

Created on 5 June 2025, 3 days ago

Problem/Motivation

When adding a product with variations add-on (commerce_vado) to the cart, an error occurs during the ajax cart update. This happens specifically when the system tries to normalize the `Drupal\commerce_price\Price` object to JSON for the `/cart?format=json` route.

The error message is:

Symfony\Component\Serializer\Exception\NotNormalizableValueException: Could not normalize object of type "Drupal\commerce_price\Price", no supporting normalizer found. in Symfony\Component\Serializer\Serializer->normalize() (line 190 of /app/vendor/symfony/serializer/Serializer.php).

This issue prevents the cart from loading correctly via ajax when VADO is involved.

Steps to reproduce

1. Install Drupal Commerce and the commerce_vado module.
2. Create a product with variations that uses variations add-ons.
3. Configure ajax cart to load on add to cart.
4. Add the product to the cart.
5. Observe the error in the browser console when the `/cart?format=json` request fails.

Proposed resolution

Modify the `VadoEventSubscriber` and `VadoOrderProcessor` to properly handle the `Price` object when setting and retrieving it as order item data. Convert the Price object into an array before saving it to order item data, and convert it back to a Price object when retrieving it.

Remaining tasks

* Review the patch.
* Test the patch.
* Commit the patch.

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇷Brazil vissini

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024